您的位置:首页 > 其它

发邮件时候遇到的一个问题

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。两种方案,根据实际情况选吧。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: