This is how I'm sending the contents of a file via mail:
($HC is the file path to the file I'm going to send)
open(MAIL, "|mail $EMAIL");
print MAIL "To: $EMAIL\n";
print MAIL "From: $mail_from\n";
print MAIL "Subject: $mail_sub\n";
print MAIL "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
open(MESSAGE, "<", "$HC") or die "$!";
print MAIL <MESSAGE>;
close(MESSAGE);
close(MAIL);
Update: I should note that the reason I don't use Corion's method listed above is because the file was already created before sending, and it seemed silly to me to read it all into a variable to send the variable. If the performance hit of reading/writing from a disk was already made, didn't seem much of a benefit to add more logic into the operation.
|