13

I am trying to send Email using this sample code and these command-line options:

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

However, I receive the following error when my app tries to send e-mail (on the development server):

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.
1
  • First make sure your ISP allows you to use a third-party SMTP server for sending emails. Most do, but some providers will block access to SMTP servers to make sure their customers won't start spamming the World. Jun 9, 2009 at 8:06

5 Answers 5

18

dev_appserver.py doesn't 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()

Note! That's the quick and dirty solution. You should add some kind of flag to tell it whether you want to use TLS or not, as it is not always desired.

4
  • hi Blixt, Thanks for u given solution of my request , with the above changes it was working fine... same as gmail, my company is one domain in Google, with the changes of my company details its not working .. means in place of gmail I given my company name... is it correct? as u said above solution is not preferred one what could be the correct solution.
    – SKSK
    Jun 9, 2009 at 10:40
  • and then in deploy, it still works? i don't think I can edit a file from the google app engine api sdk
    – Totty.js
    Mar 11, 2011 at 11:04
  • Yes. The mail API live is configured by Google themselves so you don't need to worry about how the connection to mail servers is made.
    – Blixt
    Mar 11, 2011 at 11:56
  • @Blixt. I think this workaround may have stopped working. At least, it has for me in the latest dev_appserver 1.8.6. If you had in your heart to check out my other question about it I would owe you 1 million upvotes. Oct 30, 2013 at 11:35
4

@Raymond

Execute the following command in the Terminal:

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

In my case it returns:

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

The other methods are no longer necessary:

Setting the following in /appengine/api/mail_stub.py

if self._allow_tls and smtp.has_extn ('STARTTLS'):
  smtp.starttls ()

works for me on appengine sdk version 1.9.15

0

The Google account being used to send emails from an application must have some security settings disabled in https://security.google.com/settings.

  • Disable access for less secure apps : Access for less secure apps: Turn On

If you continue to have authentication issues you may have to review the Devices & activity at the https://security.google.com/settings/security/activity

0

For anyone looking up this answer in 2018 or later: this workaround is no longer needed. You can now use the command like the original poster wrote it:

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

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.