Photius has asked for the wisdom of the Perl Monks concerning the following question:

From a Perl script running on a Windows 2003 Server, I need to monitor a folder for the arrival of certain files and email those files as attachments to another party. I also need the ability to specify a Reply-To address that is different from the Sender address. I see a multitude of mail related modules that are available when I put "mail" in the filter of ActiveState's Perl Package Manager. Which one would you recommend for the simplest implementation? I don't need any whistles or bells other than what I mentioned above. I am using ActiveState's Perl v5.8.8 built for MSWin32-x86-multi-thread, binary build 820.

Replies are listed 'Best First'.
Re: How Best to Email From Perl
by ides (Deacon) on Nov 29, 2007 at 18:11 UTC

    My current favorite E-mail module is MIME::Lite::TT::HTML. It makes it trivial to attach files and allows you to use templates for your plain text and HTML versions of your messages. This keeps you from having the content of the message hard coded into your application. You could also use MIME::Lite::TT if you don't have a need for an HTML E-mail.

    I wrote a quick tutorial on using MIME::Lite::TT::HTML that you might find useful.

    Hope this helps!

    Frank Wiles <frank@revsys.com>
    www.revsys.com

Re: How Best to Email From Perl
by hsinclai (Deacon) on Nov 29, 2007 at 18:16 UTC
    Hiya, It's been a while, but I got Mail::SendEasy to work on Windows under Activestate -- it has no dependencies on other modules and has the features you're asking for, reply-to, attachments, smtp auth, plaintext/html body, etc etc... and I use it on *nix first, it's just so easy.

Re: How Best to Email From Perl
by jrsimmon (Hermit) on Nov 29, 2007 at 19:21 UTC
    I have just used Mail::Sender to implement similar functionality. I found it to be the simplest, most intuitive package to use. It has single function calls (MailMsg(...) and MailFile(...)) for sending emails or emails with attachments.
Re: How Best to Email From Perl
by olus (Curate) on Nov 29, 2007 at 18:37 UTC
    One solution is to use MIME::Lite, always worked for me.
    use Encode; use MIME::Lite; use MIME::Base64; # for email base_64 encode use POSIX qw{strftime}; my %paramhash = ( From => $from, Reply-To => $reply_to, To => $to, Subject => "=?iso-8859-1?B?".encode_base64($subject)."?=", Date => strftime("%a, %d %b %Y %H:%M:%S %z", localtime(time)), Type => "multipart/mixed", Encoding => "Base64", ); my $msg = new MIME::Lite(%paramhash); attach $msg Type => "TEXT/plain", Data => encode("iso-8859-1", $msg_body_text ); attach $msg Type => $contentType, Path => $path, Filename => $filename, Disposition => 'attachment'; $msg->send; # you must check for faillure

    --
    olus