0
我想使用Inbox.py創建本地SMTP服務器,並通過Telnet從它發送電子郵件。如何使用Inbox.py通過Telnet發送電子郵件?
由於回購沒有一個完整的例子,我發現在回購問題有人had specified a full example,但我似乎無法得到它的工作。
他們指定此代碼:
"""
Proxy smtp to a starttls server with authentication, from a local
connection.
"""
from inbox import Inbox
from smtplib import SMTP
inbox = Inbox()
SMTP_HOST = 'mail.example.com'
SMTP_USERNAME = 'username'
SMTP_PASSWORD = 'password'
@inbox.collate
def handle(to, sender, body):
"""
Forward a message via an authenticated SMTP connection with
starttls.
"""
conn = SMTP(SMTP_HOST, 25, 'localhost')
conn.starttls()
conn.ehlo_or_helo_if_needed()
conn.login(SMTP_USERNAME, SMTP_PASSWORD)
conn.sendmail(sender, to, body)
conn.quit()
inbox.serve(address='0.0.0.0', port=4467)
但我不能確定究竟是什麼在做什麼。我只想通過SMTP命令通過Telnet發送電子郵件。
如果我telnet 0.0.0.0 4467
,它失敗的時候我指定我的數據,然後輸入.
,聲明:
error: uncaptured python exception, closing channel <smtpd.SMTPChannel connected 127.0.0.1:52779 at 0x10864f950> (<type 'exceptions.TypeError'>:handle() got an unexpected keyword argument 'subject' [/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py|read|83] [/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py|handle_read_event|449] [/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asynchat.py|handle_read|158] [/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtpd.py|found_terminator|181] [/Users/Desktop/inbox.py|process_message|18])