Mailer

Composing and sending MIME email from Perl, with validation done locally rather than by asking a third party whether an address is real.

Validate an address and compose a message →

Delivery is switched off here — deliberately

This host blocks outbound port 25, so the demo does everything except hand the message to a transport: it validates the addresses, builds the full MIME message, and shows you the exact RFC 5322 bytes it would have sent. Messages are written to disk instead, and cleared with everything else each hour.

That is the honest arrangement. The interesting parts of this library are the validation and the composition, and both are real on that page.

Validation, done locally

No lookup service. The checks are the ones the RFCs actually specify:

Composition

use Mailer;

my $mailer = Mailer->new( from => 'me@example.com' );

$mailer->send(
    to      => 'you@example.com',
    name    => 'Jane Doe',
    subject => 'Quarterly report',
    body    => "Hi Jane,\n\nReport attached.\n",
    cc      => [ 'boss@example.com' ],
    bcc     => 'archive@example.com',
    attach  => [ '/path/report.pdf', '/path/data.csv' ],
);

Attachment MIME types are detected in three escalating steps: MIME::Types if it happens to be installed, then libmagic via the file command, then a built-in extension table, falling back to application/octet-stream.

BCC is envelope-only. Recipients listed in bcc are delivered to but never appear in the message headers — the mistake that leaks a mailing list.

Two transports

The default is the local sendmail binary. For a relay, core Net::SMTP is loaded on demand:

my $mailer = Mailer->new(
    from => 'me@example.com',
    smtp => {
        host => 'smtp.example.com',
        port => 587,
        user => 'login',
        pass => 'secret',
        ssl  => 0,      # 0 = STARTTLS on 587, 1 = implicit TLS on 465
    },
);

Requirements

Core only on the default path: POSIX, MIME::Base64, File::Basename, Scalar::Util. Net::SMTP (core libnet) is loaded only if you use SMTP; MIME::Types is used if present but never required.