|
Prev: FAQ 1.4 What are Perl 4, Perl 5, or Perl 6?
Next: HTTP::Recorder and WWW::Mechanize for testing web sites
From: bl8n8r on 18 Apr 2008 10:05 #!/usr/bin/perl # the main user to send the email to $recip = 'mainuser(a)domain.org'; # a comma separated list of users to CC the email too $cclist = 'ccuser1(a)domain.org,ccuser2(a)domain.org'; # 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);
From: A. Sinan Unur on 18 Apr 2008 10:15 bl8n8r <bl8n8r(a)gmail.com> wrote in news:453ccec8-946e-48ea-ae92-827b8b5d0461@ 59g2000hsb.googlegroups.com : > #!/usr/bin/perl > > # the main user to send the email to > $recip = 'mainuser(a)domain.org'; > > # a comma separated list of users to CC the email too > $cclist = 'ccuser1(a)domain.org,ccuser2(a)domain.org'; > > # 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 <1usa(a)llenroc.ude.invalid> (remove .invalid and reverse each component for email address) comp.lang.perl.misc guidelines on the WWW: http://www.rehabitation.com/clpmisc/
From: szr on 18 Apr 2008 14:40 A. Sinan Unur wrote: > bl8n8r <bl8n8r(a)gmail.com> wrote in > news:453ccec8-946e-48ea-ae92-827b8b5d0461@ > 59g2000hsb.googlegroups.com >> > >> #!/usr/bin/perl >> >> # the main user to send the email to >> $recip = 'mainuser(a)domain.org'; >> >> # a comma separated list of users to CC the email too >> $cclist = 'ccuser1(a)domain.org,ccuser2(a)domain.org'; >> >> # 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? 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. -- szr
From: Glenn Jackman on 18 Apr 2008 15:55 At 2008-04-18 10:05AM, "bl8n8r" wrote: > #!/usr/bin/perl > > # the main user to send the email to > $recip = 'mainuser(a)domain.org'; > > # a comma separated list of users to CC the email too > $cclist = 'ccuser1(a)domain.org,ccuser2(a)domain.org'; > > # 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); If you're looking for feedback: #!/usr/bin/perl use strict; use warnings; my $to = 'mainuser(a)domain.org'; my $cc = 'ccuser1(a)domain.org,ccuser2(a)domain.org'; my $subj = 'TEST: New email message'; open my $pipe, '|-', '/usr/bin/mailx', '-s', $subj, '-c', $cc, $to or die "can't open pipe to mailx: $!\n"; print $pipe $body; close $pipe; die "mailx exited with a non-zero status: $?\n" if $?; -- Glenn Jackman "If there is anything the nonconformist hates worse than a conformist, it's another nonconformist who doesn't conform to the prevailing standard of nonconformity." -- Bill Vaughan
From: J�rgen Exner on 18 Apr 2008 16:49
bl8n8r <bl8n8r(a)gmail.com> wrote: >#!/usr/bin/perl Missing use strict; use warnings; ># the main user to send the email to >$recip = 'mainuser(a)domain.org'; > ># a comma separated list of users to CC the email too >$cclist = 'ccuser1(a)domain.org,ccuser2(a)domain.org'; > ># 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 |