my $from = 'xxx <coo@site.net>'; my $to = 'tester <me@gmail.com>'; my $subject_val = "Your recent order"; my $contents = qq|Thanks for your order. Please find your invoice +attached.|; my $write_path = "/srv/www/site.net/www/cgi-bin/admin/invoice_pdfs +/generator/created_invoices/403-8079250-7569948.pdf"; my $file_name = "403-8079250-7569948.pdf"; my $pt = 587; # or 587, 465, etc depending on what gmail uses my $mailer = new Net::SMTP::TLS( $CFG->{db_smtp_server}, Port => $pt, User => $CFG->{db_smtp_user}, Password => $CFG->{db_smtp_pass}, Timeout => 60, ) or die "Cannot create a TLS mailer instance!\n"; $mailer->mail($from); $mailer->to($to); $mailer->data(); my $msg = MIME::Lite->new( From => $from, 'Reply-to' => $from, To => $to, Subject => $subject_val, Type => 'multipart/related' ) or die "Cannot create a new email instance!\n"; $msg->attach( Type => 'TEXT', Data => $contents, ) or die "Error adding TXT: $!\n"; $msg->attach( Type => 'application/pdf', Path => $write_path, Filename => $file_name ) or die "Error adding PDF: $!\n"; $mailer->datasend($msg->as_string); $mailer->dataend(); $mailer->quit();
UPDATE: Mmm, I may have to scrap this method anyway - as the frigging IO::Socket::SSL.pm bug with regards to this line:
m{^(!?)(?:(SSL(?:v2|v3|v23|v2/3))|(TLSv1(?:_?[12])?))$}i...needing to be this line:
m{^(!?)(?:(SSL(?:v2|v3|v23|v2/3))|(TLSv1[12]?))}i
(or else it fails with Gmail)
totally screws up a load of other modules :( Back to the drawing board I guess
In reply to MIME::Lite - weird attachment issue by ultranerds
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |