# Prepare the message
my $body = <<'AMBUSH_READY';
Dear Santa
I have killed Bun Bun.
Yes, I know what you are thinking... but it was actually a total accident. I
was in a crowded line at a BayWatch signing, and I tripped, and stood on his
head.
I know. Oops! :/
So anyways, I am willing to sell you the body for $1 million dollars. Be
near the pinhole to the Dimension of Pain at midnight.
Alias
AMBUSH_READY
# Create and send the email in one shot, and send via sendmail
Email::Stuff->from ('cpan@ali.as' )
->to ('santa@northpole.org' )
->bcc ('bunbun@sluggy.com' )
->text_body($body )
->attach (io('dead_bunbun_faked.gif')->all,
filename => 'dead_bunbun_proof.gif')
->send;
# Construct email before sending and send with SMTP.
my $mail = Email::Stuff->from('cpan@ali.as');
$mail->to('santa@northpole.org')
# and so on ...
my $mailer = Email::Send->new({mailer => 'SMTP'});
$mailer->mailer_args([Host => 'smtp.example.com:465', ssl => 1]);
$mail->send($mailer);

The basics should all work, but this module is still subject to name and/or API changes

Email::Stuff, as its name suggests, is a fairly casual module used to email "stuff" to people using the most common methods. It is a high-level module designed for ease of use when doing a very specific common task, but implemented on top of the tight and correct Email:: modules.

Email::Stuff is typically used to build emails and send them in a single statement, as seen in the synopsis. And it is certain only for use when creating and sending emails. As such, it contains no email parsing capability, and little to no modification support.

To re-iterate, this is very much a module for those "slap it together and fire it off" situations, but that still has enough grunt behind the scenes to do things properly.

Email::Stuff uses Email::Send to send messages. Although it cannot be relied upon to work, the default behaviour is to use sendmail to send mail, if you don't provide the mail send channel with either the using method, or as an argument to send.

The use of sendmail as the default mailer is consistent with the behaviour of the Email::Send module itself.

Why not just use Email::Simple or Email::MIME? After all, this just adds another layer of stuff around those. Wouldn't using them directly be better?

Certainly, if you know EXACTLY what you are doing. The docs are clear enough, but you really do need to have an understanding of the structure of MIME emails. This structure is going to be different depending on whether you have text body, HTML, both, with or without an attachment etc.

Then there's brevity... compare the following roughly equivalent code.

First, the Email::Stuff way.

Email::Stuff->to('Simon Cozens<simon@somewhere.jp>')
->from('Santa@northpole.org')
->text_body("You've been a good boy this year. No coal for you.")
->attach_file('choochoo.gif')
->send;

And now doing it directly with a knowledge of what your attachment is, and what the correct MIME structure is.

Adds a single named header to the email. Note I said add not set, so you can just keep shoving the headers on. But of course, if you want to use to overwrite a header, you're stuffed. Because this module is not for changing emails, just throwing stuff together and sending it.

Adds an attachment to the email. The first argument is the file contents followed by (as for text_body and html_body) the list of headers to use. Email::Stuff should TRY to guess the headers right, but you may wish to provide them anyway to be sure. Encoding is Base64 by default.