Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change


by Corion (Pope)
on Mar 22, 2001 at 16:34 UTC ( #66313=modulereview: print w/ replies, xml ) Need Help??

Item Description: Send mail without any local mailer installed

Review Synopsis:

Every program expands until it can send mail.

Mail::Sendmail tries to make this task easier by providing an interface to any SMTP server you specify. In hindsight, the name should rather have been Mail::Simple, but it's too late for that. An alternative to Mail::Sendmail is Net::SMTP, which has about the same feature set except MIME, but I have not (yet) looked closely enough to make a qualified comparision.

Why use Mail::Sendmail ?

You need to send mail and you're not sure that there will be a local mailer installed. Mail::Sendmail works under Windows and Unix (most likely, Mac too) and it's a pure Perl solution. Installation is easy even if you don't have a make utility installed, as it consists of only one file to copy. If you install MIME::QuotedPrint, you'll also be able to easily send attachments and HTML encoded Email. It only makes one connection to the SMTP server for all recipients of the email.

Why not use Mail::Sendmail ?

Mail::Sendmail needs an existing network connection to the internet, or at least an existing network connection to the SMTP server you want it to use. It does not support local queuing or anything fancy. It modifies the headers of your email to have Content-Type and Content-transfer-encoding headers, and it will automagically try to do the right thing and quote high-ASCII characters. If you have warnings on, it will warn quite a bit about stuff. Mail::Sendmail only exports one function, &sendmail(). If you need finer grained feedback, like progress, etc. or if you don't have enough memory to keep your email twice! in it, Mail::Sendmail is not for you.


Mail::Sendmail tries to do the right thing. This might bring surprising results if you use high-ASCII stuff. Mail::Sendmail tries to parse the email adresses given, but it isn't completely RFC compliant. This might bite if you have really fancy email addresses.


The Mail::Sendmail documentation already has an exhaustive example, but I'm reposting my test script which I used to check whether Mail::Sendmail works under Win32 :

#!/usr/bin/perl -w # Simple test script to test Mail::Sendmail under Win32 use strict; use Mail::Sendmail; # Set up some default configuration unshift @{$Mail::Sendmail::mailcfg{'smtp'}} , ''; $Mail::Sendmail::mailcfg{'from'} = "Corion (script) <corion\ +spam>"; my %mail = ( Bcc => '', Subject => "Test 1", 'X-Mailer' => "Mail::Sendmail test script v0.01/$Mail::Sendmail::VER +SION", Message => "Test number 1", ); sendmail( %mail ) or die "Error: $Mail::Sendmail::error\n";

Comment on Mail::Sendmail
Download Code
Re: Mail::Sendmail
by rrwo (Friar) on Jul 11, 2001 at 04:08 UTC

    One caveat (which I think may be outdated in the latest version, if you look at the Changes file in v0.78): you may have to edit the module to remove the default <acronym>SMTP</acronym> server, otherwise it sends you mail through somebody else's server!

    However, I've long ago moved to MIME::Lite.

      I was just hoping someone might be able to answer some questions for me on this module. I'd like to know how exactly you could use it (sorry if this seems obvious to others).

      So, say I have a program, and I want to be able to have it send mail to me. Can I have this module search for a local SMTP connection to send it out? Or is what I'm trying to do something entirely different?

      Even if people just have some ideas of how this could be used, that would be helpful too.


Back to Reviews

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: modulereview [id://66313]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2014-09-02 11:09 GMT
Find Nodes?
    Voting Booth?

    My favorite cookbook is:

    Results (22 votes), past polls