Mail send-receive in Google App Engine (reply_to field)
I am reading about mail send/receive in GAE and I have a question about how to use reply_to
and the form o开发者_运维技巧f the email address replied to.
My register.py
simply writes message.sender
to database:
class User(db.Model):
userEmail = db.StringProperty()
userEmailContent = db.StringProperty()
class Register(InboundMailHandler):
def receive(self, message):
newUser = User(userEmail = message.sender)
db.put(newUser)
application = webapp.WSGIApplication([
Register.mapping()
], debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
From incoming.py
I am replying to an applicant's mail with this email:
mail.send_mail(sender="<az@example.com>",
to=message.sender,
body="reply to this email to register"
reply_to=/_ah/mail/register@hello-1-world.appspotmail.com)
I am imagining that when the applicant replies to this email register.py
will handle the email and write the applicant's email address to the database. I am not sure how to test this in dev server. Before deploying the app I wanted to ask advice about the correct email address to assign to reply_to
and if this is the correct way of handling this. Thanks.
The reply_to
address should be a canonical email address without the /_ah/mail/
prefix and it follows the same restriction of the sender
mail address.
The sender address of a message must be the email address of an administrator for the application, the Google Account email address of the current user who is signed in, or any valid email receiving address for the app.
To test it on your dev server, you could configure sendmail and send a mail from your program.
Once received, clicking reply from your mail client should show the reply_to mail address set in your code.
mail.send_mail(sender="<az@example.com>",
to=message.sender,
body="reply to this email to register"
reply_to="register@hello-1-world.appspotmail.com")
精彩评论