PostFix Mail to QQ denied

66 views
Skip to first unread message

van14...@gmail.com

unread,
Mar 14, 2014, 8:55:37 PM3/14/14
to ustc_lug
I finally got how to make postfix work in freeshell...
I try to mail to some mail servece, the results are: 
1. sina.com (ok), 
2. gmail.com (ok, but reply to is cj...@freeshell.ustc.edu.cn),
4. 126.com (ok, but in spam, reply to is right)
My Postfix configuation(/etc/postfix/main.cf):

# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = freeshell.ustc.edu.cn
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydomain = ustc.edu.cn
myorigin = $mydomain
mydestination = $myhostname, cjcx, localhost.$mydomain, localhost, $mydomain
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
default_transport = smtp
relay_transport = smtp
inet_protocols = ipv4 
# change www-data to cj...@freeshell.ustc.edu.cn
#And create a file named /etc/postfix/generic with :
#www-data sup...@example.com
#then command do:
#postmap /etc/postfix/generic
smtp_generic_maps = hash:/etc/postfix/generic 

The last lines are functionally to change the sender from www-data to sup...@example.com.

Testing mail to qq(the log is in mail.info, I think it should be in mail.log or mail.err. I have replace the test qq by x, if you find any other sensitive info, Let me know please):

> Mar 15 08:19:15 cjcx postfix/pickup[7514]: B826F5422D9: uid=33 from=<www-data> 
> Mar 15 08:19:15 cjcx postfix/cleanup[7662]: B826F5422D9: message-id=<2014031500191...@freeshell.ustc.edu.cn>
> Mar 15 08:19:15 cjcx postfix/qmgr[4796]: B826F5422D9: from=<www-...@ustc.edu.cn>, size=3156, nrcpt=1 (queue active)
> Mar 15 08:19:16 cjcx postfix/smtp[7664]: B826F5422D9: to=<xxxxxxxxx@qq.com>, relay=mx3.qq.com[182.254.3.61]:25, delay=0.82, delays=0.08/0.01/0.14/0.6, dsn=5.0.0, status=bounced (host mx3.qq.com[182.254.3.61] said: 550 Mail content denied. http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=20022&&no=1000726 (in reply to end of DATA command))
> Mar 15 08:19:16 cjcx postfix/cleanup[7662]: 8ADDC5422DA: message-id=<2014031500191...@freeshell.ustc.edu.cn>
> Mar 15 08:19:16 cjcx postfix/bounce[7665]: B826F5422D9: sender non-delivery notification: 8ADDC5422DA
> Mar 15 08:19:16 cjcx postfix/qmgr[4796]: 8ADDC5422DA: from=<>, size=5187, nrcpt=1 (queue active)
> Mar 15 08:19:16 cjcx postfix/qmgr[4796]: B826F5422D9: removed
> Mar 15 08:19:16 cjcx postfix/local[7666]: 8ADDC5422DA: to=<www-...@ustc.edu.cn>, relay=local, delay=0.09, delays=0.04/0.01/0/0.04, dsn=2.0.0, status=sent (delivered to command: procmail -a "$EXTENSION")
> Mar 15 08:19:16 cjcx postfix/qmgr[4796]: 8ADDC5422DA: removed
> Mar 15 08:20:01 cjcx postfix/pickup[7514]: 526315422D9: uid=105 from=<smmsp>
> Mar 15 08:20:01 cjcx postfix/cleanup[7662]: 526315422D9: message-id=<2014031500200...@freeshell.ustc.edu.cn>
> Mar 15 08:20:01 cjcx postfix/qmgr[4796]: 526315422D9: from=<sm...@ustc.edu.cn>, size=657, nrcpt=1 (queue active)
> Mar 15 08:20:01 cjcx postfix/local[7666]: 526315422D9: to=<ro...@ustc.edu.cn>, orig_to=<root>, relay=local, delay=0.15, delays=0.09/0/0/0.06, dsn=2.0.0, status=sent (delivered to command: procmail -a "$EXTENSION")
> Mar 15 08:20:01 cjcx postfix/qmgr[4796]: 526315422D9: removed

My qustion is:
1. how to make all reply to right: The reply to is set in header as they are in a mail function:

// To send HTML mail, the Content-type header must be set
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=UTF-8" . "\r\n";
$headers .= "To: ".$to_name."<".$to.">"."\r\n";
$headers .= "From: cjcx<cj...@freeshell.ustc.edu.cn>"."\r\n";
$headers .= "Reply-To: ".$from_name."<".$from.">"."\r\n";
$headers .= "X-Mailer: PHP/".phpversion(); 

2. how to solve the 550 problem when mail to qq?

Thanks a lot!

Bojie Li

unread,
Mar 15, 2014, 12:02:06 AM3/15/14
to USTC_LUG

腾讯帮助中心那个链接说的不是很清楚吗,邮件内容被当成垃圾邮件了,直接拒收。

另外不知道为什么把 mydomain 设成 ustc.edu.cn,应该设成自己的域名 (不过这个无所谓了)。

--
-- 来自USTC LUG
请使用gmail订阅,不要灌水。
更多信息more info:http://groups.google.com/group/ustc_lug?hl=en?hl=en

---
You received this message because you are subscribed to the Google Groups "USTC_LUG" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ustc_lug+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Abel Van

unread,
Mar 15, 2014, 1:24:02 AM3/15/14
to ustc...@googlegroups.com
难道没办法解决?

在 2014年3月15日星期六UTC+8下午12时02分06秒,Bojie Li写道:
> Mar 15 08:19:15 cjcx postfix/cleanup[7662]: B826F5422D9: message-id=<20140315001915.B826F...@freeshell.ustc.edu.cn>
> Mar 15 08:19:15 cjcx postfix/qmgr[4796]: B826F5422D9: from=<www-...@ustc.edu.cn>, size=3156, nrcpt=1 (queue active)
> Mar 15 08:19:16 cjcx postfix/smtp[7664]: B826F5422D9: to=<xxxxxxxxx@qq.com>, relay=mx3.qq.com[182.254.3.61]:25, delay=0.82, delays=0.08/0.01/0.14/0.6, dsn=5.0.0, status=bounced (host mx3.qq.com[182.254.3.61] said: 550 Mail content denied. http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=20022&&no=1000726 (in reply to end of DATA command))
> Mar 15 08:19:16 cjcx postfix/cleanup[7662]: 8ADDC5422DA: message-id=<20140315001916.8ADDC...@freeshell.ustc.edu.cn>
> Mar 15 08:19:16 cjcx postfix/bounce[7665]: B826F5422D9: sender non-delivery notification: 8ADDC5422DA
> Mar 15 08:19:16 cjcx postfix/qmgr[4796]: 8ADDC5422DA: from=<>, size=5187, nrcpt=1 (queue active)
> Mar 15 08:19:16 cjcx postfix/qmgr[4796]: B826F5422D9: removed
> Mar 15 08:19:16 cjcx postfix/local[7666]: 8ADDC5422DA: to=<www-...@ustc.edu.cn>, relay=local, delay=0.09, delays=0.04/0.01/0/0.04, dsn=2.0.0, status=sent (delivered to command: procmail -a "$EXTENSION")
> Mar 15 08:19:16 cjcx postfix/qmgr[4796]: 8ADDC5422DA: removed
> Mar 15 08:20:01 cjcx postfix/pickup[7514]: 526315422D9: uid=105 from=<smmsp>
> Mar 15 08:20:01 cjcx postfix/cleanup[7662]: 526315422D9: message-id=<20140315002001.52631...@freeshell.ustc.edu.cn>
> Mar 15 08:20:01 cjcx postfix/qmgr[4796]: 526315422D9: from=<sm...@ustc.edu.cn>, size=657, nrcpt=1 (queue active)
> Mar 15 08:20:01 cjcx postfix/local[7666]: 526315422D9: to=<ro...@ustc.edu.cn>, orig_to=<root>, relay=local, delay=0.15, delays=0.09/0/0/0.06, dsn=2.0.0, status=sent (delivered to command: procmail -a "$EXTENSION")
> Mar 15 08:20:01 cjcx postfix/qmgr[4796]: 526315422D9: removed

My qustion is:
1. how to make all reply to right: The reply to is set in header as they are in a mail function:

// To send HTML mail, the Content-type header must be set
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=UTF-8" . "\r\n";
$headers .= "To: ".$to_name."<".$to.">"."\r\n";
$headers .= "From: cjcx<cj...@freeshell.ustc.edu.cn>"."\r\n";
$headers .= "Reply-To: ".$from_name."<".$from.">"."\r\n";
$headers .= "X-Mailer: PHP/".phpversion(); 

2. how to solve the 550 problem when mail to qq?

Thanks a lot!

Bojie Li

unread,
Mar 15, 2014, 2:09:05 AM3/15/14
to USTC_LUG

如果要保证邮件收到,建议申请一个第三方邮箱,比如 Gmail,用 smtp 发信。如果是自己的域名,也可以用腾讯企业邮箱。

Zhang Cheng

unread,
Mar 15, 2014, 4:15:09 AM3/15/14
to USTC LUG
这个没有办法解决。搭一个邮箱成本太低了,所以现在的垃圾邮件横行。大型的邮件服务商都会有人工维护的白名单,只对白名单进行保证邮件的投递,对于白名单以外的邮箱域转信时都有很强的限制。并且大多数邮件服务商(比如腾讯)并不对外提供客服接口来添加白名单(这需要很大的人力,我要添加你为白名单,我需要验证你的身份,甚至实名认证,以遍追责,万一有人大量发垃圾邮件,服务商还得承受损失(如客户流失),因此一般来说服务商是不会接受个人的白名单申请,他们内部应该会有一套流程、规则来制定这个白名单)。
--
Cheng,
Best Regards

van14...@gmail.com

unread,
Mar 15, 2014, 5:47:12 AM3/15/14
to ustc_lug
的确, 现在配置了relay, 解决了qq认为垃圾邮件的问题. 但是第一个问题还是没搞定, 有时回复地址是对的, 有时回复地址又不对. 看来写到header不太保险?


You received this message because you are subscribed to a topic in the Google Groups "USTC_LUG" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ustc_lug/jjIYa8t7cOE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ustc_lug+u...@googlegroups.com.

Zhang Cheng

unread,
Mar 15, 2014, 5:52:23 AM3/15/14
to USTC LUG

On Sat, Mar 15, 2014 at 5:47 PM, van14...@gmail.com <van14...@gmail.com> wrote:
的确, 现在配置了relay, 解决了qq认为垃圾邮件的问题. 但是第一个问题还是没搞定, 有时回复地址是对的, 有时回复地址又不对. 看来写到header不太保险?

​按理说Reply-To头算是一个比较标准的头,客户端都应该支持的很好才对。你在有问题的邮箱里,导出收到的邮件的original,看看长什么样的。​



--
Cheng,
Best Regards

van14...@gmail.com

unread,
Mar 15, 2014, 6:01:26 AM3/15/14
to ustc_lug
那我顺便报个问题, 科大邮箱用foxmail收信总出现"错误信息::ssl连接错误, errorCode: 5", 链接进去: http://service.foxmail.com/cgi-bin/selfhelp?subtype=1&no=1001151&id=20060&version=7.1 

试了半天没搞定怎么设定:
收件服务器:email.ustc.edu.cn 993
发件服务器:email.ustc.edu.cn 465
后面是端口号.
我没发现邮箱主页怎么配置科大邮箱?  只看到一个Ip地址, 替换后问题依旧.

事实上, 我想问在科大邮箱web版上可以查看header?
foxmail 里面我应该能够google到.


--

Bojie Li

unread,
Mar 15, 2014, 6:04:56 AM3/15/14
to USTC_LUG

这事到 BBS 的 ustcnet 板上反映啊。

You received this message because you are subscribed to the Google Groups "USTC_LUG" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ustc_lug+u...@googlegroups.com.

van14...@gmail.com

unread,
Mar 15, 2014, 6:05:03 AM3/15/14
to ustc_lug
Foxmail里面看到了, 好像是编码问题?
因为我设置的回复格式是: 张山<x...@xxx.xxx>
结果在头里显示乱码:
Reply-To: 鏂潶鍥?x...@xxx.xxx>


 
Date: 2014-03-15 17:52
--

Zhang Cheng

unread,
Mar 15, 2014, 6:11:20 AM3/15/14
to USTC LUG

2014-03-15 18:05 GMT+08:00 van14...@gmail.com <van14...@gmail.com>:
Foxmail里面看到了, 好像是编码问题?
因为我设置的回复格式是: 张山<x...@xxx.xxx>
结果在头里显示乱码:
Reply-To: 鏂潶鍥?x...@xxx.xxx>

​你这个用的是什么库?似乎比较lowlevel啊,mail的header都是自己手写的。我在python下用email的库,我写进去的header,它都会自动处理一下字符集编码,进行一些encode操作。​



--
Cheng,
Best Regards

Bojie Li

unread,
Mar 15, 2014, 6:10:59 AM3/15/14
to USTC_LUG

那是你的邮件没使用 UTF8 格式编码导致的,你用科大邮箱给 Gmail 发个中文邮件,show original,看人家是怎么编码的,跟你发的邮件的 original 比较一下。

You received this message because you are subscribed to the Google Groups "USTC_LUG" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ustc_lug+u...@googlegroups.com.

van14...@gmail.com

unread,
Mar 15, 2014, 6:14:55 AM3/15/14
to ustc_lug
好像 header的charset=utf8只是对body, 而不是对header本身? 昨天出现subject乱码时看到网上的说法.


van14...@gmail.com

unread,
Mar 15, 2014, 6:13:38 AM3/15/14
to ustc_lug
php mail 函数 + postfix作为后台. 其他我不懂的. 代码(header)是看的php mail函数的例子.

以前主题汉字是乱码, 用了
$subject = '=?UTF-8?B?'.base64_encode($subject).'?=';
解决, 我再试试同样的办法能不能解决...


 
Date: 2014-03-15 18:11
Subject: Re: Re: [USTC-LUG] PostFix Mail to QQ denied

--

Zhang Cheng

unread,
Mar 15, 2014, 6:22:47 AM3/15/14
to USTC LUG

2014-03-15 18:14 GMT+08:00 van14...@gmail.com <van14...@gmail.com>:
好像 header的charset=utf8只是对body, 而不是对header本身? 昨天出现subject乱码时看到网上的说法.

email里面所有出现文字的地方都可以单独编码​,例如我从gmail发出一封邮件,几个header是这个样子的:

Subject: =?UTF-8?B?5rWL6K+V6YKu5Lu2?=
​​

To: =?UTF-8?B?5pS25Lu25Lq65aeT5ZCN?= <
​xxx​@xxx.xxx
>

​标题内容为“测试邮件”,收件人名字为“收件人姓名”​

​邮件的内容也可以有多个part,每个part又可以有自己的字符集编码以及传输编码(常用的有base64和​quoted-print)。


--
Cheng,
Best Regards

Bojie Li

unread,
Mar 15, 2014, 6:23:09 AM3/15/14
to USTC_LUG

话说,如果用 php 的话,可以用 phpmailer 库。php 默认的 mail 函数是比较底层的。

如果你对自己实现邮件协议感兴趣,可以看一篇文章 How samba was written,不仅要看协议文本,还要与已有的实现做比较,发现和理解一些不成文的规矩。
https://www.samba.org/ftp/tridge/misc/french_cafe.txt

Zhang Cheng

unread,
Mar 15, 2014, 6:27:18 AM3/15/14
to USTC LUG

2014-03-15 18:13 GMT+08:00 van14...@gmail.com <van14...@gmail.com>:
以前主题汉字是乱码, 用了
$subject = '=?UTF-8?B?'.base64_encode($subject).'?=';
解决, 我再试试同样的办法能不能解决...

​要注意,base64跟utf-8是两个维度的编码方式,他们不互斥。

base64的目的是将二进制内容转化为全部由可打印字符组成的内容。而所有的文本信息本质上都是二进制内容,包括ascii在内都有一些不可打印的字符。
怎么说呢,如果你对一个 gbk(中文) 进行base64,那么对方拿到你的串并base64解码之后得到的内容,也需要用gbk才能解析。对utf8一样。
你这个例子里,你需要保证你的$subject里面保存的是一个utf8的二进制串。​



--
Cheng,
Best Regards

van14...@gmail.com

unread,
Mar 15, 2014, 7:08:57 AM3/15/14
to ustc_lug
啊, 还有这个区别. 以前不懂, 随便选了一种. 如果是一般的字符串呢? 

我当时看到还有个imap8bit, 估计是单字节的编码, 就选了base64的. 



 
Date: 2014-03-15 18:27
Subject: Re: Re: [USTC-LUG] PostFix Mail to QQ denied

--

van14...@gmail.com

unread,
Mar 15, 2014, 7:28:53 AM3/15/14
to Bojie Li, USTC_LUG
话说, 我原来用的是phpmailer, 每次发邮件要用10来秒钟. 后来想配置个服务器, postfix似乎是把发邮件转到后台一样(新开了进程), 使得发件快很多.

不知道怎么使得phpmailer也是一种postfix代发, 而不是去直接连接smtp服务器.

看了下参考:http://www.aslibra.com/blog/post/postfix_smtp_mail.php
没搞定. 
 

 
From: Bojie Li
Date: 2014-03-15 18:23
Subject: Re: Re: [USTC-LUG] PostFix Mail to QQ denied

话说,如果用 php 的话,可以用 phpmailer 库。php 默认的 mail 函数是比较底层的。

如果你对自己实现邮件协议感兴趣,可以看一篇文章 How samba was written,不仅要看协议文本,还要与已有的实现做比较,发现和理解一些不成文的规矩。
https://www.samba.org/ftp/tridge/misc/french_cafe.txt

2014-3-15 下午6:15于 "van14...@gmail.com" <van14...@gmail.com>写道:

Bojie Li

unread,
Mar 15, 2014, 9:16:23 AM3/15/14
to van14...@gmail.com, ustc...@googlegroups.com
phpmailer 支持 mail 和 smtp 等 mailer,我一般用 mail,就是调用 php 的 mail 函数,跟 shell 中的 mail 命令一样,会用本地装的 sendmail,postfix 或 exim 等发邮件。你是不是用的 smtp?

Google “phpmailer postfix”,第二条结果就行:
Reply all
Reply to author
Forward
0 new messages