Guest_imported
New member
- Jan 1, 1970
- 0
Is there an easy way to handle e-mail attachments in perl?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
my $input_file = './templates/'.$session_id.'.txt';
my $output_file = './templates/'.$session_id.'.met';
`unix2dos $input_file | uuencode header_desc >$output_file`;
# append attachment to $mail_buffer
my $mail_buffer;
open(MDR,"<$output_file") or
showError("Failed to open MDR, $!");
while (<MDR>) { $mail_buffer .= $_; }
close MDR;
my $mail_prog = '/some/path/to/sendmail';
open (MAIL, "|$mail_prog -f YOU $recipient") ||
showError("Can't open $mail_prog!, $!");
print MAIL "From: $recipient\n";
print MAIL "Reply-To: $recipient\n";
print MAIL "Errors-to: $recipient\n";
print MAIL "Subject: email with attachment\n";
print MAIL "Precedence: bulk\n\n";
print MAIL "-----------------------------------------------------------\n";
print MAIL "Your file is attached.\n";
print MAIL "$mail_buffer\n";
close (MAIL);