aio-libs / aio-libs/aiosmtpd

SMTP AUTH extension not supported by server.

未关闭
#283 12 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
need more info
主要语言
Python
星标
373
派生
105
平均合并
4 分钟
30 天内合并 PR
2

描述

hello, i'am using aiosmtpd as a server proxy mail, i want analyze traffic mail, it's normal if i'm not use Authentication, i can send a mail. but if i use authenticator on Controller my client side give me an error **"SMTP AUTH extension not supported by server."**

i try example of aiosmtpd/examples/authenticated_relayer/server.py , but same result.

python version : 3.6
OS : MacOS BigSur 11.5.2 , i try running on docker with base ubuntu 20.04, same result on me

Server Code :
```
class Authenticator:
def __init__(self, auth_database):
self.auth_db = Path(auth_database)

def __call__(self, server, session, envelope, mechanism, auth_data):
fail_nothandled = AuthResult(success=False, handled=False)
if mechanism not in ("LOGIN", "PLAIN"):
return fail_nothandled
if not isinstance(auth_data, LoginPassword):
return fail_nothandled
username = auth_data.login
password = auth_data.password
hashpass = password
conn = sqlite3.connect(self.auth_db)
curs = conn.execute(
"SELECT hashpass FROM userauth WHERE username=?", (username,)
)
hash_db = curs.fetchone()
conn.close()
if not hash_db:
return fail_nothandled
if hashpass != hash_db[0]:
return fail_nothandled
return AuthResult(success=True)

logging.basicConfig(level=logging.DEBUG)
controller = Controller(
MailProxyHandler(
host=config.get('remote', 'host'),
port=config.getint('remote', 'port', fallback=25),
auth=remote_auth,
use_ssl=config.getboolean('remote', 'use_ssl', fallback=False),
starttls=config.getboolean('remote', 'starttls', fallback=False),
),
hostname=config.get('local', 'host', fallback='127.0.0.1'),
port=config.getint('local', 'port', fallback=25),
authenticator=Authenticator(DB_AUTH),
auth_required=True
)
controller.start()

print("Mail proxy started ...")
print("Remote Server : " + config.get('remote', 'host'))
while controller.loop.is_running():
sleep(0.2)
```

Client Code :
```
port = 8465
smtp_server = "127.0.0.1"
sender_email = "lalala@gmail.com" # Enter your address
to = "FF " # Enter receiver address
cc = ["lalala@lalala.co.id", "YOYO HE "]
bcc = "lalala@gmail.com"

text = "Hi!\nHow are you?\nHere is the link you wanted:\nhttp://www.python.org"
html = """\



Hi!

How are you?

Here is the link you wanted.


"""

part1 = MIMEText(text, 'plain')
part2 = MIMEText(html, 'html')

msg = MIMEMultipart()
msg['Subject'] = "This is subject"
msg['From'] = 'hehehe@gmail.com'
msg['To'] = to
msg['Cc'] = ", ".join(cc)

msg.attach(part1)
msg.attach(part2)

rcpt = [to]
with smtplib.SMTP(smtp_server, port) as server:
server.connect(smtp_server, port)
server.set_debuglevel(1)
server.login("user1", "password1")
server.sendmail(sender_email, rcpt, msg.as_string())
```

Server LOG :
Screen Shot 2021-09-14 at 16 43 13

Client LOG :
Screen Shot 2021-09-14 at 16 43 27

Thank you for your help

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。