tags:

views:

1262

answers:

9

For years I've been piping out to sendmail in my Perl programs to send email, but I have the strong sense I ought to use a module. It would make me feel less dirty.

Care to recommend me one module over the others, with reasons why? Thanks in advance!

+1  A: 

Most of the time, I use Mail::Sendmail which is simple, easy, fast, and does what it's supposed to do. It has always served me well, wether there's one or a thousand recipients in the message.

Now, depending on needs, you might want to use some MIME modules like MIME::Lite which you would grok together with something like Net::SMTP.

mat
A: 

I do still sometimes pipe to sendmail (when I'm just sending basic text and know I'll only ever need to run on a *nix box), but most of the time I go with MIME::Lite, because:

  • It handles the grunt work of sending attachments
  • Although it sends via local sendmail by default, it can also be set to send via SMTP for use on hosts without sendmail installed
  • Even when using sendmail, it figures out the path to sendmail and what options to give it on its own, so that's one less configuration setting to keep track of
  • It's quick and easy
Dave Sherohman
+18  A: 

I'd suggest the modules maintained by the Perl Email Project. Namely Email::MIME::Creator, Email::Simple::Creator and Email::Sender. Note that Email::Send is deprecated.

The interface is (mostly) consistent and simple and they try to Do The Right Thing.

kixx
Email::* is essentially the 3rd generation (and current) email API tree.
Gary Richardson
These all installed without issue on my Red Hat EL4 system, so I'm going to run with this one and see how I do. The unified approach of the Perl Email Project is compelling so I'll start here. Thanks to all for their input.
Marcus
Email::Send is depreciated, you should use Email::Sender instead
Nifle
Thank you Nifle, I've updated the answer accordingly.
kixx
+4  A: 

It doesn't get much simpler than Mail::Mailer, but I'm not sure I would use it for processing user-generated content (it offers minimal protection against web-scripting attacks). I use it all the time for mailing output of programs/cron jobs etc, and it's great for that.

Mime::Lite looks pretty good, although I haven't used it.

RET
I have used both of those for simple tasks and they work just fine. Haven't really tried anything in else in Perl, though.
Chris Kloberdanz
+2  A: 

I've been pretty attached to Mail::Sender for a while. It sends mail with minimal fuss and has pretty intelligent handling of attachments.

Josh McAdams
A: 

I have used Mail::SendEasy with good results.

Nifle
A: 

Somebody recommended MIME::Lite to me a long time ago, and it has always worked great for everything I needed to do. It may be using sendmail on the backend, though. I'm not sure.

I used it to send plaintext emails for years before I ever needed to send a MIME attachment.

skiphoppy
+6  A: 

As the maintainer of a few of the modules named, let me urge you to use Email::Sender. It is easy to use, based on code that has sent billion of messages, and is likely going to get much more work over the next few years than Email::Send, MIME::Lite, or others.

rjbs
A: 
sub happyQuickMail
{
use Mail::Sendmail;
%mail = (
To => '[email protected]',
From => '[email protected]',
Subject => 'amazing message',
Message => "good news
the server is working
someone used it
customer number $abc"
);
sendmail(%mail) or die $Mail::Sendmail::error;
}
Joe Blow