ultranerds has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: MIME::Lite - weird attachment issue
by noxxi (Pilgrim) on Sep 06, 2015 at 05:59 UTC | |
|
Re: MIME::Lite - weird attachment issue
by Anonymous Monk on Sep 05, 2015 at 10:13 UTC | |
by ultranerds (Hermit) on Sep 05, 2015 at 11:13 UTC |