标题: [原创教程] Perl用Mail::Sender批量发送带附件的邮件 [打印本页]
作者: sxw 时间: 2013-5-15 21:04 标题: Perl用Mail::Sender批量发送带附件的邮件
- use strict;
- use warnings;
- use Mail::Sender;
- my @mailto=('123456@qq.com','234567@qq.com','fg789@sina.com','s123456@163.com');
-
- eval {
- (new Mail::Sender)
- ->OpenMultipart({
- smtp => 'smtp.163.com',
- from => 's1234567@163.com',
- auth=> 'LOGIN',
- authid => 's1234567',
- authpwd => '01123',
- to => \@mailto,
- subject => 'Another Way to Embedded Image Test',
- boundary => 'boundary-test-1',
- type => 'multipart/related',
- skip_bad_recipients => 'true'
- })
- ->Part({ctype => 'multipart/alternative'})
- ->Part({ ctype => 'text/plain', disposition => 'NONE',msg => <<'*END*' })
- A long
- mail
- message.
- *END*
-
-
- #*END*一定要在最左边
- ->Part({ctype => 'text/html', disposition => 'NONE', msg => <<'*END*'})
- <html><body><h1>A long</h1><p align=center>
- mail
- message.
- <img src="cid:img1">
- </p></body></html>
- *END*
-
- ->EndPart("multipart/alternative")
- ->Attach({
- description => 'ed\'s jpg',
- ctype => 'image/jpeg',
- encoding => 'base64',
- disposition => "inline; filename=\"0518m_b.jpg\";\r\nContent-ID: <img1>",
- file => 'hf.jpg'
- })
- ->Close();
- } or print "Error sending mail: $Mail::Sender::Error\n";
-
-
复制代码
#还有,最后一个邮箱我故意写错了,导致所有邮件都不能发送成功,加上一句 skip_bad_recipients => 'true'就OK了。。
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |