The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

INSTALLING MODULES

The Courriel and Email::Sender libraries can be installed from CPAN using any cpan client. For example, using cpanminus (https://metacpan.org/module/App::cpanminus) you would run the following shell command:

  cpanm Courriel Email::Sender

SMTP VERSUS A LOCAL MAIL SERVER

If you really want to ensure that emails get delivered, you need to handle the (rare) case where Sendgrid is unavailable and queue the email for retrying.

We could try to implement that in this code, but that would get complicated fast, and soon we'd have reimplemented an entire mail server. A better solution is to configure a local mail server running locally to deliver email using Sendgrid. See http://sendgrid.com/docs/Integrate/Mail_Servers/index.html for more details on how to do this. The mail server will queue the email if Sendgrid is unavailable and try to send it again later.

If you're using a local mail server, you don't need to use Email::Sender::Transport::SMTP at all. You can just use the sendmail() subroutine in its default mode:

  sendmail($email);

This looks for a sendmail binary program in the path and invokes it to send the email. On Unix systems, this binary should always do the right thing if you've installed a local mail server.

AUTHOR

David Rolsky <autarch@urth.org>

LICENSE

To the extent possible under law, David Rolsky has waived all copyright and related or neighboring rights to this example. This work is published from: United States.

See http://creativecommons.org/publicdomain/zero/1.0/ for details.