1

Basically, I'm trying to send some email thru uucp to some especial accounts using the RFC 5322 standard that includes !#$%&'*+-/=?^_`{|}~; (https://en.wikipedia.org/wiki/Email_address#Local-part)

I'm trying to execute the following command in a Centos 6 box from the CLI (/bin/bash) and from a perl script.

# cat /root/my_msg | uux -r -aroot@my.centosbox.com - 'my_remailserv!rmoc.pl' root@my.centosbox.com  "CP&O-AP@qatargas.com.qa" my_email@gsmail.com

I have managed to escape an email address of the kind Massimo.L'ala@enix.com passing it as "Massimo.L\'ala@enix.com" but with & is splitting the string in CP & O-AP@qatargas.com.qa

Any ideas on how to avoid these extra 2 spaces? I have tried "CP\&O-AP@qatargas.com.qa" 'CP\&O-AP@qatargas.com.qa' and many more with no happy result.

  • uux, really? Does the recipient not understand MIME email? – roaima Jun 27 at 18:59
  • 1
    I think it has more to do with a very unreliable and expensive internet connection. Sending the email via uucp is not the problem, it has always worked in that way. The problem are the special characters in those email addresses. – Ozono1796 Jun 27 at 22:42
1

Instead of guessing at what the shell will need escaped (or not), bypass the shell with a handle to a pipe connected to uux:

open my $uux, '|-', 'uux', '-r', 
                           '-aroot@my.centosbox.com', 
                           '-', 
                           'my_remailserv!rmoc.pl', 
                           'root@my.centosbox.com', 
                           'CP&O-AP@qatargas.com.qa', 
                           'my_email@gsmail.com' 
  or die $!;
open my $data, '<', '/root/my_msg' 
  or die $!;
print $uux (<$data>);
close $data 
  or die $!;
close $uux 
  or die $!;

You would substitute the static strings (that I copied from your example) with the corresponding perl variables. The basic idea here is to open the pipe-handle to the uux program (giving it all the arguments you want it to have), then open a second handle for the message contents; then print the contents of that second file handle to the pipe, then close everything out.

To test this independently, I created a local "uux" program:

#!/bin/sh
echo I am "$0" with arguments:
printf '<%s>\n' "$@"
echo Here is stdin:
cat

and a sample data file consisting of two date lines. The sample output from such a run is:

$ ./go.pl
I am ./uux with arguments:
<-r>
<-aroot@my.centosbox.com>
<->
<my_remailserv!rmoc.pl>
<root@my.centosbox.com>
<CP&O-AP@qatargas.com.qa>
<my_email@gsmail.com>
Here is stdin:
Thu Jun 27 14:20:46
Thu Jun 27 14:30:36
  • Thank you Jeff for your help. I am not familiarised with pipes in perl, or with much of perl to be honest. So I am a bit confused with the "uux" program and the date lines... So I suppose those lines are the contents of the file /root/my_msg? As you will noticed I'm just trying to send an email message with the body in /root/my_msg to a list of different email addresses that I usually pass as an array... – Ozono1796 Jun 27 at 22:53
  • You indicated that you were calling uux via Perl (and shell), so I wanted to show how you could safely call uux from Perl. – Jeff Schaller Jun 27 at 23:22
  • This is the way it is currently done in perl: open( UUX, "| uux $flag -a$sender - $mailsvr\!thing.pl $sender @recip" ); It looks to me as a pipe but as I said I know nothing about them in perl. – Ozono1796 Jun 28 at 9:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.