sending email from perl using a pipe and mailx

B

bl8n8r

#!/usr/bin/perl

# the main user to send the email to
$recip = '(e-mail address removed)';

# a comma separated list of users to CC the email too
$cclist = '(e-mail address removed),[email protected]';

# open a pipe to the mailx utility and feed it a subject along with
# recipients and the cclist
open (FI, "|/usr/bin/mailx -s 'TEST: New email message' $recip -c
$cclist");

# send the body of the email message and close.
# note: the email is not sent until the pipe is closed.
printf (FI "blah\nblah blah\n");
close (FI);
 
A

A. Sinan Unur

59g2000hsb.googlegroups.com
:
#!/usr/bin/perl

# the main user to send the email to
$recip = '(e-mail address removed)';

# a comma separated list of users to CC the email too
$cclist = '(e-mail address removed),[email protected]';

# open a pipe to the mailx utility and feed it a subject along
with # recipients and the cclist
open (FI, "|/usr/bin/mailx -s 'TEST: New email message' $recip -c
$cclist");

# send the body of the email message and close.
# note: the email is not sent until the pipe is closed.
printf (FI "blah\nblah blah\n");
close (FI);

Do you have a question?

Sinan

--
A. Sinan Unur <[email protected]>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
 
S

szr

A. Sinan Unur said:
59g2000hsb.googlegroups.com


Do you have a question?

Why assume everything that is posted is always going to be a question?
Looks to me like someone was just sharing some code they had written. It
may not be the most complex of programs, but hey, everyone's gotta'
start somewhere.
 
J

Jürgen Exner

bl8n8r said:
#!/usr/bin/perl

Missing
use strict;
use warnings;
# the main user to send the email to
$recip = '(e-mail address removed)';

# a comma separated list of users to CC the email too
$cclist = '(e-mail address removed),[email protected]';

# open a pipe to the mailx utility and feed it a subject along with
# recipients and the cclist
open (FI, "|/usr/bin/mailx -s 'TEST: New email message' $recip -c
$cclist");

Missing error handling.
Would be better to use 3-argument form of open.
# send the body of the email message and close.
# note: the email is not sent until the pipe is closed.
printf (FI "blah\nblah blah\n");

Why are you using printf() when you don't have a format specifier?
close (FI);

jue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top