[Chicago-talk] emailing from perl

Mike Fragassi frag at ripco.com
Thu Aug 2 11:04:26 PDT 2007


First, some pointers:

The Perl Email Project Wiki:
   http://emailproject.perl.org/wiki/Main_Page
Ricardo Signes' talk on the P.E.P. at YAPC 2007:
   http://www.slideshare.net/rjbs/how-i-learned-to-stop-worrying-and-love-email-the-2007-pep-talk/
   (click the "Download" link)

The slides have numerous examples for sending mail, about half-way in.

Finally, can you send plain old email from your host's command line?
I.e.:
    mail -s "test" you at somewhere.com < file

If that works, then if you continue to have problems with mailing 
via Perl, there's a very hacky solution.  Just replace this:

   # Mail HTML document.
   # Params: filename, subject, recipient
   # Returns: none
   sub MailDocument() {

with this:

   sub MailDocument {
      my ($file, $subj, $to) = @_;
      `mail -s $subj $to < $file`;

Just add some parameter testing for validity & taintedness, and 
checking of the output/error from the mail command.

-- Mike F.


More information about the Chicago-talk mailing list