2009-06-09 308 views
12

我試圖用this sample code這些命令行選項來發送電子郵件:錯誤通過SMTP服務器App Engine開發服務器上發送電子郵件

dev_appserver.py --smtp_host=smtp.gmail.com --smtp_port=25 [email protected]_password=k1tt3ns myapp 

不過,我收到以下錯誤,當我的應用程序試圖發送電子郵件(在開發服務器上):

Traceback (most recent call last): 
    File "C:\Program Files\Google\google_appengine\google\appengine\ext\webapp\__init__.py", line 500, in __call__ 
    handler.post(*groups) 
    File "C:\Documents and Settings\desk\Desktop\apps\temp\main.py", line 139, in post 
    """) 
    File "C:\Program Files\Google\google_appengine\google\appengine\api\mail.py", line 205, in send_mail 
    message.send(make_sync_call) 
    File "C:\Program Files\Google\google_appengine\google\appengine\api\mail.py", line 474, in send 
    make_sync_call('mail', self._API_CALL, message, response) 
    File "C:\Program Files\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py", line 68, in MakeSyncCall 
    apiproxy.MakeSyncCall(service, call, request, response) 
    File "C:\Program Files\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py", line 240, in MakeSyncCall 
    stub.MakeSyncCall(service, call, request, response) 
    File "C:\Program Files\Google\google_appengine\google\appengine\api\apiproxy_stub.py", line 80, in MakeSyncCall 
    method(request, response) 
    File "C:\Program Files\Google\google_appengine\google\appengine\api\mail_stub.py", line 203, in _Send 
    self._SendSMTP(mime_message, smtp_lib) 
    File "C:\Program Files\Google\google_appengine\google\appengine\api\mail_stub.py", line 133, in _SendSMTP 
    smtp.login(self._smtp_user, self._smtp_password) 
    File "C:\Python26\lib\smtplib.py", line 552, in login 
    raise SMTPException("SMTP AUTH extension not supported by server.") 
SMTPException: SMTP AUTH extension not supported by server. 
+0

&活動首先確保您的ISP允許您使用第三方SMTP服務器發送電子郵件。大多數人會這樣做,但有些提供商會阻止訪問SMTP服務器,以確保他們的客戶不會開始發送垃圾郵件。 – 2009-06-09 08:06:10

回答

18

dev_appserver.py不支持Gmail所需的TLS。您可以通過API/mail_stub.py添加幾行啓用:

# After smtp.connect(self._smtp_host, self._smtp_port) 
smtp.ehlo() 
smtp.starttls() 
smtp.ehlo() 

注意!這是快速和骯髒的解決方案。您應該添加某種標誌來告訴您是否要使用TLS,因爲它並不總是需要的。

+0

嗨Blixt,感謝您給我的請求解決方案,與上述更改它工作正常...與Gmail一樣,我的公司是在谷歌的一個域,與我公司的詳細信息的變化,它不工作..意味着gmail的地方我給出了我的公司名稱......是否正確? 正如你所說的,上面的解決方案並不是首選的解決方案。 – SKSK 2009-06-09 10:40:32

4

@Raymond

在終端執行以下命令:

find/-name "mail_stub.py" -type f 2>/dev/null 

在我的情況下,它返回:

/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/mail_stub.py 
0

其他方法已不再需要:

/appengine/api/mail_stub.py

01中設置以下內容部
if self._allow_tls and smtp.has_extn ('STARTTLS'): 
    smtp.starttls() 

作品對我來說AppEngine上SDK版本15年1月9日

相關問題