I wrote a sample code to send email from google app engine in Python. I’m not able to figure out why is it sending out every mail twice?
mail.py:-
from google.appengine.api import mail
mail.send_mail(sender="ALPHA <ALPHA@gmail.com>",
to="BETA <BETA@hotmail.com>",
subject="test mail",
body="""
Dear BETA,
How have you been?
Regards,
ALPHA
""")
app.yaml:-
application: MyUniqueAppID
version: 1
runtime: python
api_version: 1
handlers:
- url: .*
script: mail.py
If that really is your app.yaml, then any request to your app is going to result in a mail being sent.
If you visit the site with a web-browser, it will first make a request for
/, then probably also make a request for/favicon.icoand potentially other unintended requests. Each resulting in a mail being sent.You should:
urlroute in app.yaml more specific than .*webbappframework to create a propper application/handler within mail.py