1.Mail::Sendmail,用這個模塊發郵件很簡單,但是貌似也只能處理簡單的郵件...
use Mail::Sendmail;
%mail = ( To => 'you@there.com',
From => 'me@here.com',
Message => "This is a very short message"
);
sendmail(%mail) or die $Mail::Sendmail::error;
print "OK. Log says:\n", $Mail::Sendmail::log;
2.Mail::Sender
這傢伙能發送帶附件的,不過得經過SMTP服務器,我測試了一下失敗...
找到一個例子是用網易的,不過我測試一下Login not accepted...好吧
use Mail::Sender;
$sender = new Mail::Sender
{smtp => 'mail.yourdomain.com', from => 'your@address.com'};
$sender->MailFile({to => 'some@address.com',
subject => 'Here is the file',
msg => "I'm sending you the list you wanted.",
3
file => 'filename.txt'});
3.找到MIME::Lite.
初看一眼,丫看名字跟郵件好像關係不大.可是仔細一看丫貌似什麼功能都有
靠..藏得太深了.我好不容易找到.這傢伙好用極了! use MIME::Lite; $msg = MIME::Lite->new( From => 'me@myhost.com', To => 'me@ahaha.com', #Cc => 'some@other.com, some@more.com', Subject => 'you have got a message', Type => 'multipart/mixed' ); ### Add parts (each "attach" has same arguments as "new"): $msg->attach( Type => 'TEXT', Data => "Here's the GIF file you wanted" ); $msg->attach( Type => 'AUTO', Path => '111.txt', Disposition => 'p_w_upload' ); ### use Net:SMTP to do the sending $msg->send();