Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Attachments in perl

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Is there an easy way to handle e-mail attachments in perl?
 
Send or receive?



If on a *nix system, you can send like ....
Code:
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,&quot;<$output_file&quot;) or 
     showError(&quot;Failed to open MDR, $!&quot;);
while (<MDR>) { $mail_buffer .= $_; }
close MDR;

my $mail_prog = '/some/path/to/sendmail';
open (MAIL, &quot;|$mail_prog -f YOU $recipient&quot;) ||    
      showError(&quot;Can't open $mail_prog!, $!&quot;);
print MAIL &quot;From: $recipient\n&quot;;
print MAIL &quot;Reply-To: $recipient\n&quot;;
print MAIL &quot;Errors-to: $recipient\n&quot;;
print MAIL &quot;Subject: email with attachment\n&quot;;
print MAIL &quot;Precedence: bulk\n\n&quot;;
print MAIL &quot;-----------------------------------------------------------\n&quot;;
print MAIL &quot;Your file is attached.\n&quot;;
print MAIL &quot;$mail_buffer\n&quot;;
close (MAIL);

If that is not barking up the correct tree, try taking a look at the NET::SMTP module. 'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
and then there are the simple interfaces that utilize NET::SMTP the modules Mail::Mailer and Mime::Lite.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top