***** infoCopter.com/perl *****

Send Mail Attachments

Newsgroups:comp.lang.perl.misc

Betrifft:Re: Emailing with a file attached 
Newsgroups:comp.lang.perl.misc
View: Complete Thread (3 articles) | Original Format 
Datum:2001-02-06 03:27:39 PST 
 

Use MIME::Lite for that task!


Sample code snippet:


    	eval("use MIME::Lite");
    	Error "Seems MIME::Lite is'nt installed yet on this machine $@" if $@;

	my $message = MIME::Lite->new(
		From     => 'reply@yourhost.com' ,
		To       => 'your-customer@custhost.com' ,
		Subject  => 'your attachment in this mail',
		Type     => 'text/plain',
		Encoding => '8bit',
		Data     => "Dear Sirs,\nBest regards,\nbla bla"
	);

    	my ($mime_type, $encoding) = ('application/octet-stream', 'base64');

	$message->attach (
		Type     => $mime_type ,
		Encoding => $encoding ,
		Path     => '/home/attachments/offer.doc' ,
		Filename => 'offer.doc'
	);

	# -----  Tell MIME::Lite to use Net::SMTP instead of sendmail
	MIME::Lite->send('smtp', 'smtp.your-smtp-host.com', Timeout => 20);

	$message->send;
© reto :)