email - sending multipart mail in perl -


i trying send mail through perl script using net::smtp module.it works fine when send normal mail without attachment.i wont receive mail.

    use net::smtp;     use mime::base64;     use file::basename;       use mime::base64 qw( encode_base64 );     use mime::base64 qw( decode_base64 );     @attachments = 'c:\users\ups7kor\desktop\scripts\commadnline\appending.pl';     $toaddress = '***';     $fromaddress = '***';     $servername = '***';     $boundary = 'end of mail';      $smtp = net::smtp->new($servername, timeout => 60) or print $failureloghandler  ++$errrorcount.")error:could not create smtp object . \n\t please check smpt adress in $inifiledata{ini_smtp_server_name} of $inifilesection{ini_email} section ";      $smtp->mail($fromaddress);     $smtp->recipient($toaddress, { skipbad => 1 });     $smtp->data();     $smtp->datasend("to: $toaddress\n");     $smtp->datasend("from: $fromaddress\n");     $smtp->datasend("subject: $subject\n");     $smtp->datasend("mime-version: 1.0\n");     $smtp->datasend("content-type: multipart/mixed;\n\tboundary=\"$boundary\"\n");     $smtp->datasend("--$boundary\n");     $smtp->datasend("content-type: text/plain\n");     $smtp->datasend("content-disposition: quoted-printable\n");     $smtp->datasend("\n $messagebody\n");      if(@attachments)     {     $smtp->datasend("--$boundary\n");     foreach $attachment (@attachments)     {         open(dat, $attachment) || die("could not open text file!");         @textfile = <dat>;         close(dat);          $filename = basename($attachment);         $smtp->datasend("content-type: application/text; name=\"$filename\"\n");         $smtp->datasend("content-disposition: attachment; filename=\"$filename\"\n");         $smtp->datasend("\n");         $smtp->datasend("@textfile\n");    }    }        $smtp->datasend("--$boundary --\n");     $smtp->dataend();     $smtp->quit; 

but if try same code in other machine works file. why same code not working in machine , working fine in other machine.

please out.

you're using rather low-level tools building message. work, you'd need implement of rules building mime messages - sounds far hard work.

whenever want email , perl, appropriate module in email::* namespace. i'd start email::mime, note includes pointer email::stuffer, might simpler.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -