in reply to Need a Mail::SendEasy example using attachments
I don't have one for Mail::SendEasy, but I have one I did a while ago using Mime::Lite and Net::SMTP. Here it is, if it'll help...
#!/usr/bin/perl #------------------------------------------------------------------- # faxer.pl <recipient> <file> # # Send file <file> to <recipient>. Note that the recipient field is # a specially formatted field that contains recipient name, fax #, # and email address of the fax server, like so: # # "/name=Lonnie Phillips/fax=5551234/<rfax@npc.net>" # # 20050111 Roboticus - Added comments, some error checking # ???????? LPhillips - originally written #------------------------------------------------------------------- use strict; use MIME::Lite; MIME::Lite->send('smtp','mail.your.domain',Timeout=>60); use Net::SMTP; my $smtp = Net::SMTP->new('mail.your.domain', Debug=>1); print $smtp->domain,"\n"; my $usage= 'usage: faxer.pl <recipient> where: <recipient> = Fax address, formatted like: "/name=Roboticus/fax=5551234/<rfax@your.domain>" '; #my $fax_dest = @ARGV[0] or die $usage . "\nmissing <recipient>"; my $msg = MIME::Lite->new( To => '/name=%fromName%/fax=%toFax%/<rfax@your.domain>', From => 'MailBot@your.domain', Subject => 'Roboticus\'s test fax', Type => 'multipart/related', ) or die "Error creating MIME container!\n"; $msg->attach( Type => 'text/html', Data => qq {<html> <body> <img src="cid:ltrhead.gif"> </p> <div align="center"> <table border="1"> <tr align="center"><td colspan="2">TO</td><td colspan="2">FROM</td></ +tr> <tr><td align="right">Name:</td><td>%toName%</td><td align="right">Na +me:</td><t d>%fromName%</tr> <tr><td align="right">Fax:</td><td>%toFax%</td><td align="right">Fax: +</td><td>% fromFax%</td></tr> <tr><td></td><td></td><td align="right">Phone:</td><td>%fromPhone%</t +d></tr> <tr><td></td><td></td><td align="right">EMail:</td><td>%fromEMail%</t +d></tr> </table> </div> <hr> </p> To Whom It May Concern,</p> Regional Security is currently conducting a review on merchant %MerchID% "%MerchName%" for a batch of \$%MerchBatch%.</p> All funds are on hold until the review is complete. If you have any questions or information, please feel free to contact me at %fromPhone +% or email me at %fromEMail%.</p> Thank You,</p> %fromName% </body> </html> }, ) or die "Error creating HTML!\n"; $msg->attach( Type => 'image/gif', Id => 'ltrhead.gif', Path => 'fake_letterhead.gif', ) or die "Error adding image!\n"; open(OUTF,">faxer.mht") or die "Can't open output file"; print OUTF $msg->as_string; close(OUTF); $smtp->mail('mmason@npc.net'); ##$smtp->to('/name=Roboticus/fax=5551234/<rfax@your.domain>'); $smtp->to('roboticus@your.domain'); $smtp->data(); $smtp->datasend($msg->as_string); $smtp->dataend(); $smtp->quit();
Note: I've hacked out a little proprietary stuff, and this is just an experimental (proof of concept) program I wrote some time ago. It functions, but will need some tweaking!
--roboticus
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Need a Mail::SendEasy example using attachments
by duckyd (Hermit) on Aug 16, 2006 at 22:02 UTC | |
by roboticus (Chancellor) on Aug 17, 2006 at 03:49 UTC | |
|
Sending an attachment with MIME::Lite. RFC2111 Content-Id requirements
by imp (Priest) on May 14, 2007 at 19:13 UTC |