Hello everyone. I'm a very novice perl programmer that is trying to generate an automatic email that attaches a file and sends it to a constant recipient. Because of the version of perl that I am forced to use (CQPERL) I cannot make use of the wonderful perl modules like MIME::Lite. I am essentially forced to use the MIME functions with an HTML email. This script does not populate the body of the message nor attaches a file. However the email goes through fine
Any help would be appreciated.
-Matt
LM
#!perl -w
# THIS SCRIPT SENDS AN EMAIL WITH AN ATTACHMENT.
use Net::SMTP;
# Connect to the server
my $smtp = Net::SMTP->new("smtp_server_address", Debug => 1);
die "Couldn't connect to server" unless $smtp ;
#my $msg = "<b>Test text";
$smtp->mail("person\@person.com");
$smtp->to("person\@person.com");
$smtp->data();
#Send the header
$smtp->datasend("To: person\@person.com\n");
$smtp->datasend("Subject: Daily Defect Report\n");
#Start the multipart email message
$smtp->datasend("MIME-Version: 1.0\n");
$smtp->datasend("Content-Type: multipart/mixed; boundary='12345'\n");
#Create the body of the email message
$smtp->datasend("--12345\n");
$smtp->datasend("Content-Type: text/html\n");
$smtp->datasend("<b>This is a test of sending a text attachment.\n");
#Attach a .txt file to the email message
$smtp->datasend("--12345\n");
$smtp->datasend("Content-Type: application/octet-stream; name=output.txt\n");
$smtp->datasend("Content-Disposition: attachment; filename='C
utput.txt'\n");
$smtp->datasend("Content-Transfer-Encoding: base64\n");
$smtp->datasend("\n");
#End the multipart message
$smtp->datasend("--12345--\n");
#Send the termination string
$smtp->dataend();
$smtp->quit;
-Matt
LM
#!perl -w
# THIS SCRIPT SENDS AN EMAIL WITH AN ATTACHMENT.
use Net::SMTP;
# Connect to the server
my $smtp = Net::SMTP->new("smtp_server_address", Debug => 1);
die "Couldn't connect to server" unless $smtp ;
#my $msg = "<b>Test text";
$smtp->mail("person\@person.com");
$smtp->to("person\@person.com");
$smtp->data();
#Send the header
$smtp->datasend("To: person\@person.com\n");
$smtp->datasend("Subject: Daily Defect Report\n");
#Start the multipart email message
$smtp->datasend("MIME-Version: 1.0\n");
$smtp->datasend("Content-Type: multipart/mixed; boundary='12345'\n");
#Create the body of the email message
$smtp->datasend("--12345\n");
$smtp->datasend("Content-Type: text/html\n");
$smtp->datasend("<b>This is a test of sending a text attachment.\n");
#Attach a .txt file to the email message
$smtp->datasend("--12345\n");
$smtp->datasend("Content-Type: application/octet-stream; name=output.txt\n");
$smtp->datasend("Content-Disposition: attachment; filename='C
$smtp->datasend("Content-Transfer-Encoding: base64\n");
$smtp->datasend("\n");
#End the multipart message
$smtp->datasend("--12345--\n");
#Send the termination string
$smtp->dataend();
$smtp->quit;