在回答這個問題Error sending e-mail via SMTP server on App Engine development server有一個nice solution by Blixt:發送從開發服務器電子郵件--smtp_host = smtp.gmail.com
"dev_appserver.py does not support TLS
which is required by Gmail. You can
enable it by adding a few lines in api/mail_stub.py:"
# After smtp.connect(self._smtp_host, self._smtp_port)
smtp.ehlo()
smtp.starttls()
smtp.ehlo()
但Windows Vista中不會讓我改變api/mail_stub.py
是否有另一種從開發服務器發送郵件的方法。其他選項(Sendmail和ISP不適合我)。謝謝!
編輯
我按照說明書here改變了api/mail_stub.py
我用下面的命令行選項:
dev_appserver.py
--smtp_host=smtp.gmail.com
--smtp_port=25
[email protected]
--smtp_password=gmail_pw
C:\Users\A\Desktop\repeater # path to root directory
但我從登錄控制檯此錯誤:
***********************************************************
2010-11-18 10:24:37 Running command: "['C:\\Python26\\pythonw.exe',
'C:\\Program Files(x86)\\Google\\google_appengine\\dev_appserver.py',
'--admin_console_server=',
'--port=8080',
u'dev_appserver.py',
u'--smtp_host=smtp.gmail.com',
u'--smtp_port=25',
u'[email protected]',
u'--smtp_password=gmail_pw
C:\\Users\\A\\Desktop\\repeater',
'C:\\Users\\A\\Desktop\\repeater']"
Runs a development application server for an application.
dev_appserver.py [options] <application root>
Application root must be the path to the application to run in this server.
Must contain a valid app.yaml or app.yml file.
****************************************************
這是app.yaml:
application: re-peater
version: 1
runtime: python
api_version: 1
handlers:
- url: /favicon.ico
static_files: static/images/favicon.ico
upload: static/images/favicon.ico
- url: /stylesheets
static_dir: stylesheets
- url: /.*
script: repeater.py
所有這些工作都沒有這些命令行選項。任何建議,爲什麼這是行不通的?
我看到兩個問題。首先是使用端口25. Gmail僅通過加密連接進行身份驗證。嘗試587,因爲它似乎工作時,端口465不會。這可能與STARTTLS有關。並且TLS必須通過命令行arg啓用dev_appserver.py。如果這是明顯的泥,那麼它準確地反映了SMTP的狀態。 – 2017-01-04 04:19:46