#!/usr/bin/perl -w ###################################################################### # Libraries # --------- use strict; use warnings; use diagnostics; use MIME::Lite; use Email::Valid; # If we have a valid email address. my $to_email = 'youremail@somedomain.com'; my $email_valid = Email::Valid->new(mxcheck => 1,tldcheck => 1); if ($email_valid->address($to_email)) { # Everything looks good, make up our message my $message = MIME::Lite->build ( From => $to_email, To => $to_email, Subject => 'This is the subject', #Type => 'multipart/alternative' If I default to this then it never gets updated with a attachment. ); # Did we get a attachment? my $attachment = '/tmp/38293132401.pdf'; if (-e $attachment) { #$message->replace(Type => ''); # Tried this #$message->replace(Type => 'multipart/mixed'); # Tried this $message->add(Type => 'multipart/mixed'); $message->attach( Type => 'AUTO', Path => $attachment, Filename => '38293132401.pdf', Disposition => 'attachment' ); } else { $message->add(Type => 'multipart/alternative'); } my $text_email = 'yadda yadda yadda'; my $html_email = 'yadda yadda yadda'; # Do up the message $message->attach(Type => 'TEXT', Data => $text_email ); $message->attach(Type => 'text/html', Data => $html_email ); $message->send('smtp','###.###.###.###',Debug=>1,Timeout=>60,Port=>26); }