Hi,

I'm trying to send an email to someone using, using MIME::Lite, to send via GMail SMTP. This is the code I have:
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();


The problem I'm getting, is that it DOES send, but when it comes out my end, the attachments are all screwed:

http://www.tiikoni.com/tis/view/?id=bfa8ee3

(none of them open)

What am I doing wrong?

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



TIA

Andy

In reply to MIME::Lite - weird attachment issue by ultranerds

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.