in reply to Re^3: MIME::Lite and Multipart
in thread MIME::Lite and Multipart
But if that would do it, here it is... I have the same exact problem when I run the below, whenever I try to set the type as I go, it fails with that "no data in this part". If I set the type to "multipart/alternative" when I create "my $message...." it works (but I don't get the attachment if there is one because it doesn't get switched to multipart/mixed)
#!/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 thi +s 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'); # Tri +ed 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 = '<em>yadda</em> <strong>yadda</strong> <u>yad +da</u>'; # 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,P +ort=>26); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: MIME::Lite and Multipart
by jakobi (Pilgrim) on Sep 29, 2009 at 19:38 UTC | |
by Analog (Novice) on Sep 29, 2009 at 21:15 UTC | |
by ww (Archbishop) on Sep 30, 2009 at 02:36 UTC | |
by jakobi (Pilgrim) on Sep 29, 2009 at 21:26 UTC |