发邮件时候遇到的一个问题
2007-09-24 15:27
447 查看
发邮件的程序比较简单,在网上一搜一堆。我用的是自己架的postfix,基本都是默认配置,只改了发送权限的机器跟一些发送重试机制的参数。
但是在真正发邮件的时候,却遇到了一个令我比较郁闷的问题。找了几天也没有找到答案。我用的是Net::Smtp模块发送的,起初我怀疑是没有用好。之后又怀疑一次的tcp连接太多等等,总之,问题没有解决。
无奈之下,我到postfix官网上找到了Kyle Dent的联系方式。 (之前熟悉postfix也是看他写得那本书)
我去信请教的大概内容:
Hi kdent,
I get some puzzled problem when i use PostFix.
My program snatched some email list( About 30,000). Then i use my Postfix to send email.
You know,to reduce connection times,I ONLY set up ONEC time connection to Postfix.
That is to say,I did it as following step:
<mockcode>
1) connect the PostFix.
2) call the mail function in loop.
3) quit the connect.
</mockcode>
After ran the program(The program spent 20s or so),i check the postfix log (/var/log/maillog/) ,Only about 1,000 lists have been sent.
Remainder lists didn't been recorded any info.
Do I need some special config for this aim?
BTW,My postconf is :
。。。
两天之后,kyle给我了答复:
You should take a look at the smtpd limit configuration parameters. They
are all named starting with smtpd and end in limit (smtpd_*_limit). No
doubt you're running into one of those. Also Postfix will report to your
client the reason for not accepting a message. Be sure to check the
response from Postfix to see if a message was accepted or not. If not
then check the error message for the reason.
按图索骥,我又找了一下postfix的配置 ,最终将问题定位在 smptd_recipient_limit 这个参数上。其默认值是1000。
我的代码:
sug smail {
###(1)$smtp = Net::SMTP->new('xx.xx.xx.xx');
$smtp->mail('test@g.com');
$smtp->to('test@g.com');
$smtp->data();
$smtp->datasend('From: test@g.com');
$smtp->datasend("/n");
$smtp->datasend('To: test@g.com');
$smtp->datasend("/n");
$smtp->datasend('Content-type:text/html;Charset=gb2312');
$smtp->datasend("/n");
$smtp->datasend("Subject: test!");
$smtp->datasend("/n/n");
$smtp->datasend("<b>how are you!</b>/n");
$smtp->dataend();
$smtp->dataend();
###(2) $smtp->quit;
}
如此一来,只要将smptd_recipient_limit 调大,把注释1,2放到发送邮件的外部,就可以只建立一次NET socket,然后不停的发送邮件了。
当然去掉注释1,2其逻辑就是每发一封邮件,就new一个Net::SMTP。两种方案,根据实际情况选吧。
但是在真正发邮件的时候,却遇到了一个令我比较郁闷的问题。找了几天也没有找到答案。我用的是Net::Smtp模块发送的,起初我怀疑是没有用好。之后又怀疑一次的tcp连接太多等等,总之,问题没有解决。
无奈之下,我到postfix官网上找到了Kyle Dent的联系方式。 (之前熟悉postfix也是看他写得那本书)
我去信请教的大概内容:
Hi kdent,
I get some puzzled problem when i use PostFix.
My program snatched some email list( About 30,000). Then i use my Postfix to send email.
You know,to reduce connection times,I ONLY set up ONEC time connection to Postfix.
That is to say,I did it as following step:
<mockcode>
1) connect the PostFix.
2) call the mail function in loop.
3) quit the connect.
</mockcode>
After ran the program(The program spent 20s or so),i check the postfix log (/var/log/maillog/) ,Only about 1,000 lists have been sent.
Remainder lists didn't been recorded any info.
Do I need some special config for this aim?
BTW,My postconf is :
。。。
两天之后,kyle给我了答复:
You should take a look at the smtpd limit configuration parameters. They
are all named starting with smtpd and end in limit (smtpd_*_limit). No
doubt you're running into one of those. Also Postfix will report to your
client the reason for not accepting a message. Be sure to check the
response from Postfix to see if a message was accepted or not. If not
then check the error message for the reason.
按图索骥,我又找了一下postfix的配置 ,最终将问题定位在 smptd_recipient_limit 这个参数上。其默认值是1000。
我的代码:
sug smail {
###(1)$smtp = Net::SMTP->new('xx.xx.xx.xx');
$smtp->mail('test@g.com');
$smtp->to('test@g.com');
$smtp->data();
$smtp->datasend('From: test@g.com');
$smtp->datasend("/n");
$smtp->datasend('To: test@g.com');
$smtp->datasend("/n");
$smtp->datasend('Content-type:text/html;Charset=gb2312');
$smtp->datasend("/n");
$smtp->datasend("Subject: test!");
$smtp->datasend("/n/n");
$smtp->datasend("<b>how are you!</b>/n");
$smtp->dataend();
$smtp->dataend();
###(2) $smtp->quit;
}
如此一来,只要将smptd_recipient_limit 调大,把注释1,2放到发送邮件的外部,就可以只建立一次NET socket,然后不停的发送邮件了。
当然去掉注释1,2其逻辑就是每发一封邮件,就new一个Net::SMTP。两种方案,根据实际情况选吧。
相关文章推荐
- 在django下写一个邮件群发系统遇到的编码问题(转)做笔记
- 从 CWinThread 派生一个子类:CConnectThread,在CConnectThread中作消息映射的时候遇到问题
- 关于Android使用Instrumentation做功能测试的时候遇到的一个问题
- 在调试stage3D项目的时候遇到一个很尴尬的问题
- 集群搭建时候遇到的一个问题
- 昨天做项目的时候,遇到了一个tabbar 影响底部按钮的问题
- 处理数据的时候遇到的一个小问题
- oracle 数据泵 通过表空间导入导出的时候遇到的一个问题
- 使用spymemcached spring整合的时候遇到的一个配置问题
- java -- 写时间的时候遇到一个问题,大家有没有遇到过
- 想必大家在做参数验证的时候,都会遇到一个问题,就是如何验证枚举? 自定义annotation 自定义Validator
- iOS forin遍历时候遇到的一个问题
- 在使用mybaitis传参数的时候,仅传入一个类型为String的参数所遇到的问题
- js函数参数传值的时候遇到的一个小问题
- vs2013 编译的时候遇到的一个问题
- 今天再做上传图片时候遇到了一个JS 图片预览问题
- 使用session时候,遇到的一个问题(请求解决方法)
- 最近遇到一个非常棘手的需求是关于邮件转发的问题,请大家来帮忙给出出主意如何实现。
- 从爬网时候遇到的一个问题看如何找到错误的根源
- 今天实现二叉树的时候遇到了一个很有意思的问题