tags:

views:

180

answers:

6

Which package from CPAN should I use to send mail?

Sometime the timtowtdi approach is very tiring. For me, especially when it comes to package selection.

So all I want is to send email, potentially HTML emails. Between Mail-Sendmail, Mail-Sender, NET-SMTP (by the way - not available in PPM), Mail-SendEasy, and the 80 or so other packages that have 'Mail' in their package name - which one should I choose?

And while in this subject, what is your general apprach to choose the "canonical" package for a jog. I.e. the package that "everybody is using". Is there any rating or popularity billboard somewhere?

A: 

If you don't need more than the basic features, I suggest looking at Mime::Lite.

use MIME::Lite; 
my $msg = new MIME::Lite
From => 'Your friendly neighbourhood spiderman',
To => '[email protected]', 
CC => '[email protected]',
BCC => '[email protected]',
'Reply-to' => '[email protected]',
Subject => 'Please stop',
Data     => $data; #Email body

die 'Could not send mail' unless ($msg->send);
Konerak
Well I don't mind the downvotes, but could ya leave a comment as to why? I'm here to learn, too :)
Konerak
I didn't vote, so I can only guess: indirect object syntax is despised. (That's "new Foo" instead of "Foo->new") MIME::Lite is pretty mediocre. Spider-Man is a hyphenate.
rjbs
A: 

You can use Email::Send
http://search.cpan.org/dist/Email-Send/lib/Email/Send.pm

karthi_ms
Deprecated in favour of [Email::Sender](http://p3rl.org/Email::Sender).
daxim
Email::Sender is a virtually undocumented module with a dependency hell which makes it difficult to install even on standard Unix machines. Email::Send is a stable, documented, mature module, which actually works.
Snake Plissken
As the maintainer of both Email::Send and Email::Sender, I seriously recommend Email::Sender. Email::Send has serious bugs that can be very dangerous during testing and cannot be easily fixed. Its interface is a nightmare for anything other than, "hey, let's send a piece of mail or something."I am happy to document things that you feel are not covered by http://search.cpan.org/dist/Email-Sender/lib/Email/Sender/Manual/QuickStart.pm but I don't know what those are.
rjbs
+1  A: 

What I prefer is

Mail::Sendmail

MIME::Lite

If you require SSL then include

Net::SMTP::SSL

Space
why downvote? are these modules not useful for sending emails? Please leave a comment, I want to learn.
Space
+3  A: 

I'll throw in Email::Stuff. It's a nice wrapper for Email::MIME. You don't need to care about the MIME structure of the mail, the module does it for you.

Email::Stuff->from     ('[email protected]'                      )
            ->to       ('[email protected]'              )
            ->bcc      ('[email protected]'                )
            ->text_body($body                              )
            ->attach   (io('dead_bunbun_faked.gif')->all,
                        filename => 'dead_bunbun_proof.gif')
            ->send;

As for selecting modules,

Thomas Kappler
It's convenient, but doesn't have good error checking. Instead of calling the method `send`, take the object and feed it into [Email::Sender](http://p3rl.org/Email::Sender).
daxim
+8  A: 

Task::Kensho generally makes good recommendations. For sending email it suggests Email::Sender

David Dorward
Upvote for best module.
daxim
+9  A: 

what is your general apprach to choose the "canonical" package for a jog. I.e. the package that "everybody is using". Is there any rating or popularity billboard somewhere?

When I want to pick which of several CPAN modules to use, the things I look at are

Documentation:

The litmus test for CPAN modules is the first page of the documentation. If there is a messy synopsis, or a synopsis without a simple working example, I guess that the module is probably not a good one. Untidy, messy, or misformatted documentation is also a red flag.

State of repair:

  • the date of release of the last version of the module tells you if it is being maintained,
  • the CPAN tester's reports tell you whether the module is likely to install without a struggle
  • the bugs list on rt.cpan.org gives you some idea of how active the author is about maintaining the module.

Also, is there a mailing list for the module? Having a mailing list is a pretty good sign of a good-quality, maintained, stable, documented and popular module.

Author:

  • What is the name of the module author?
  • How many other modules has the author released?
  • What kind of modules has the author released?

The author is a big factor. There are some authors who create things which have excellent quality, like Gisle Aas, Graham Barr, Andy Wardley, or Jan DuBois, and some people who turn out a lot of things which could be described as "experimental", like Damian Conway or Tatsuhiko Miyagawa. Be wary of people who've released a lot of Acme:: (joke) modules. Also, beware of things written by people who only maintain one or two modules. People who have fewer than five modules in total usually don't maintain them.

Other things:

cpanratings.perl.org is often helpful, but take it with a grain of salt.

Apart from that, a lot of it is just trial and error. Download and see if it passes its own tests, see if it even has any tests, write a test script, etc.

Things which often don't give a meaningful ranking:

  • The top results on Google tend to be ancient Perlmonks or perl.com or Dr. Dobbs' Journal articles, and these often point you towards outdated things.
  • search.cpan.org's search function puts modules which haven't been updated for ten years on page one, and the latest and greatest on page ten or something.

Beware of "hype":

One more thing I want to say: Be wary of advice on blogs, stackoverflow, Usenet news, etc. - people tend to guide you to whatever module happens to be flavour of the month, rather than a stable, proven solution. The "trendy" modules usually lack documentation, are unstable, have nightmarish dependencies, and quite often yesterday's fashionable modules suddenly fall out of favour and are abandoned, to be replaced by another flavour of the month, leaving you in the lurch if you decide to use them.

Snake Plissken