python smtp发送邮件:500 Error: bad syntax
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python smtp发送邮件:500 Error: bad syntax相关的知识,希望对你有一定的参考价值。
reply: b‘220 126.com Anti-spam GT for Coremail System (126com[20140526])\r\n‘ reply: retcode (220); Msg: b‘126.com Anti-spam GT for Coremail System (126com[20140526])‘ connect: b‘126.com Anti-spam GT for Coremail System (126com[20140526])‘ send: ‘ehlo TOMAS-PC.DHCP HOST\r\n‘ reply: b‘500 Error: bad syntax\r\n‘ reply: retcode (500); Msg: b‘Error: bad syntax‘ send: ‘helo TOMAS-PC.DHCP HOST\r\n‘ reply: b‘500 Error: bad syntax\r\n‘ reply: retcode (500); Msg: b‘Error: bad syntax‘ (500, b‘Error: bad syntax‘)
fqdn = socket.getfqdn() if ‘.‘ in fqdn: self.local_hostname = fqdn else: # We can‘t find an fqdn hostname, so use a domain literal addr = ‘127.0.0.1‘ try: addr = socket.gethostbyname(socket.gethostname()) except socket.gaierror: pass self.local_hostname = ‘[%s]‘ % addr
python3.6 smtplib模块中的
fqdn = socket.getfqdn()
返回值是: TOMAS-PC.DHCP HOST
但是126邮件服务器认为"TOMAS-PC.DHCP HOST"不是主机名,也不是域名,
所以出现使用python发邮件时,提示语法错误。
以上是关于python smtp发送邮件:500 Error: bad syntax的主要内容,如果未能解决你的问题,请参考以下文章