Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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.

Caveats

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.

Example

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'}} , 'smtprelay.t-online.de'; $Mail::Sendmail::mailcfg{'from'} = "Corion (script) <corion\@sends.no. +spam>"; my %mail = ( Bcc => 'corion@wants.no.spam', 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";

In reply to Mail::Sendmail by Corion

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-03-28 22:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found