python smtp发送邮件:500 Error: bad syntax

核能气质少年 提交于 2020-01-28 11:27:16
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发邮件时,提示语法错误。

 


 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!