Receiving email with SMTPServer in python:

若如初见. 提交于 2019-12-06 02:01:16

1) Postfix is an SMTP server, it has nothing to do with python's smtpd EHLO implementation. If you want your custom SMTP server, you don't need postfix, so feel free to remove it.

2) EHLO is a ESMTP command, not SMTP, standard smtpd python module implements SMTP, therefore it doesn't have an EHLO implementation.

Try this. Of course, it does not implement the EHLO command, but makes it treat it the same as the HELO command. Of course, it might only get you past the first stumbling block, however if the rest of the smtp commands are compatible it might get you by:

You will probably find the smtpd.py file in /usr/lib/python2.7

def smtp_HELO(self, arg):
    if not arg:
        self.push('501 Syntax: HELO hostname')
        return
    if self.__greeting:
        self.push('503 Duplicate HELO/EHLO')
    else:
        self.__greeting = arg
        self.push('250 %s' % self.__fqdn)

#copy the above function and rename it smtp_EHLO

def smtp_EHLO(self, arg):
    if not arg:
        self.push('501 Syntax: HELO hostname')
        return
    if self.__greeting:
        self.push('503 Duplicate HELO/EHLO')
    else:
        self.__greeting = arg
        self.push('250 %s' % self.__fqdn)

Also, I note the python3.5 version of the same library looks like it supports EHLO, so maybe you could try and use python3. But apparently python3 is not backwards compatible it seems - so good luck.

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