use strict; use MIME::Lite; my $subject="A first MIME::Lite test on gmail"; my $message="A Daily PDF report is attached.Just to see if this works"; my $to = "r.ted.byers\@gmail.com"; my $file = "mysamplefile.pdf"; my $from = "\"Me\" "; print "Sending test email.\n"; make_and_send_email($from,$to,$subject,$message,$file); print "Test email sent.\n"; sub make_and_send_email{ my ($from, $to,$subject,$message, $path) =@_; my $un='myun'; my $pw='mypwd'; my $msg = MIME::Lite->new( From => $from, 'Reply-to' => $from, To => $to, Subject => $subject, Type =>'multipart/related' ) or die "Cannot create a new email instance!"; $msg->attach(Type => 'TEXT', Data => $message, ) or die "Error adding TXT: $!\n"; $msg->attach(Type => 'aplication/pdf', Path => $path, Disposition => 'attachment' ) or die "Error adding PDF: $!\n"; MIME::Lite->send('smtp','smtp.gmail.com',AuthUser=>$un, AuthPass=>$pw, Timeout => 60); $msg->send(); return 0; }