Possible Duplicate:
sending email with GAE copies sender — how to stop?
Below is a code to send emails from google app engine in Python. I made a list (pythons) of email-ids to whom I desire to send email to and ran a loop, each time reassigning message.to and executing message.send().
Code below, when run on Google App Engine, sends a copy of email to the sender (AUTH_USER1@gmail.com) of the email (along with the email sent to the desired email-id). What could be possible reason for this?
from google.appengine.api import mail
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.api import users
class MainPage(webapp.RequestHandler):
def get(self):
user = users.get_current_user()
if user and user.nickname()=="AUTH_USER1":
self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write('Hello, ' + user.nickname())
else:
self.redirect(users.create_login_url(self.request.uri))
message = mail.EmailMessage(sender="Auth User1 <AUTH_USER1@gmail.com>",
subject="Testing Google App Engine")
message.html = """
hi, how have you been
"""
list = ['A@gmail.com','B@hotmail.com', 'C@yahoo.com']
for i in range(0,len(list)):
message.to = list[i]
message.send()
application = webapp.WSGIApplication(
[('/', MainPage)],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
This is by design. You cannot send email from a user in App Engine without the user getting a copy.