The following bit of code *almost* works for me:
$email = "me@mydomain.com";
$me = "script@mydomain.com";
$subject = "poa file for me";
$file = "poa.txt";
my @boundaryv = (0..9, 'A'..'F');
srand(time ^ $$);
for (my $i = 0; $i++ < 24;) {
$boundary .= $boundaryv[rand(@boundaryv)];
}
open(MAIL,"|$mail -oi -t");
print MAIL "To: $email\n";
print MAIL "From: $me\n";
print MAIL "Subject: $subject\n";
print MAIL "Content-Type: multipart/mixed; boundary=\"------------$boundary\"\n";
print MAIL "\n";
print MAIL "This is a multi-part message in MIME format.\n";
print MAIL "--------------$boundary\n";
print MAIL "Content-Type: text/plain; charset=us-ascii\n";
print MAIL "Content-Transfer-Encoding: 7bit\n\n";
print MAIL "Hello\n";
print MAIL "\n";
print MAIL "--------------$boundary\n";
print MAIL "Content-Type: text/plain name=\"$file\"\n";
print MAIL "Content-Transfer-Encoding: base64 \n";
print MAIL "Content-Disposition: inline; filename=\"$file\"\n\n";
close INPUT;
print MAIL "\n--------------$boundary--\n";
print MAIL "\n";
close MAIL;
I get the email and attachment, but the attachment is blank. Can anyone see what may need to be tweaked?
It's a plain text file.
FYI - I used to use this one:
print MAIL <<"END";
From: $yourname
To: $youremail
Cc: $ccmail
Subject: POA Request
Requested File: $file
END
open(FILE, "uuencode $file $file|") or die;
while( <FILE>) { print MAIL; };
# Close the file and finish sending the mail
close(FILE);
close(MAIL);
Until our hosting company "upgraded" our servers and now it no longer works.
Code:
$mail = "/usr/sbin/sendmail"; $email = "me@mydomain.com";
$me = "script@mydomain.com";
$subject = "poa file for me";
$file = "poa.txt";
my @boundaryv = (0..9, 'A'..'F');
srand(time ^ $$);
for (my $i = 0; $i++ < 24;) {
$boundary .= $boundaryv[rand(@boundaryv)];
}
open(MAIL,"|$mail -oi -t");
print MAIL "To: $email\n";
print MAIL "From: $me\n";
print MAIL "Subject: $subject\n";
print MAIL "Content-Type: multipart/mixed; boundary=\"------------$boundary\"\n";
print MAIL "\n";
print MAIL "This is a multi-part message in MIME format.\n";
print MAIL "--------------$boundary\n";
print MAIL "Content-Type: text/plain; charset=us-ascii\n";
print MAIL "Content-Transfer-Encoding: 7bit\n\n";
print MAIL "Hello\n";
print MAIL "\n";
print MAIL "--------------$boundary\n";
print MAIL "Content-Type: text/plain name=\"$file\"\n";
print MAIL "Content-Transfer-Encoding: base64 \n";
print MAIL "Content-Disposition: inline; filename=\"$file\"\n\n";
close INPUT;
print MAIL "\n--------------$boundary--\n";
print MAIL "\n";
close MAIL;
I get the email and attachment, but the attachment is blank. Can anyone see what may need to be tweaked?
It's a plain text file.
FYI - I used to use this one:
Code:
open(MAIL, "|$mailprog -oi -t") or die; print MAIL <<"END";
From: $yourname
To: $youremail
Cc: $ccmail
Subject: POA Request
Requested File: $file
END
open(FILE, "uuencode $file $file|") or die;
while( <FILE>) { print MAIL; };
# Close the file and finish sending the mail
close(FILE);
close(MAIL);
Until our hosting company "upgraded" our servers and now it no longer works.