how to detect bounce mail in google app engine?
sometime due to wrong input from user side, mail bounce and did not reach the recipient. ( sent from google app engine.)
How to detect such email ?
edit: may be i was not clear in my question :
I want to know to which mail i have sent the mail which was return ( so that i may alert the user or delete the email id ). this is more related to how email bounce works. normally the bounce mail does not come exactly same as sent but with different information, is there any particular header or something there to know which email id was that ? ... i think i have figure out while writing these, i am keeping 开发者_如何学编程this question so it might help somebody.
i will simply mail from base64encodedrecipientemailaddress@myapp.appspot.com and create a mail receive handler. :)
so one more question : what is the maximum length does app-engine ( or any mail server ) allows for email address ?
Google has actually since added a method for receiving bounced messages via an HTTP Request. It requires adding to your app.yaml:
inbound_services:
- mail_bounce
Which will cause a request to hit /_ah/bounce
each time a bounce is received. You can then handle the bounce by adding a handler for it. See the section there on Handling Bounce Notifications for more details on how to glean the additional information from those requests.
Sadly, this is not possible.
GAE adds a "Return-Path" header to your email message automatically. Bounced messages will be send to the address identified by this header. You cannot modify the value of this header.
See http://code.google.com/p/googleappengine/issues/detail?id=1800 for details.
Use one of your app's addresses as the from address (anything@yourapp.appspotmail.com) and register a handler for that address. Then, you can intercept and interpret any responses (automated or otherwise).
easiest is to encode an email address via base64 or simiar encoding and prefixed it to from address.
all address from something@myapp.appspotmail.com are valid email address for from in gae.
simply create a mail receive handler. decode the from string and get the email address to whom you send the email originally.
sad thing is maximum 64 character length allowed for local part. in that case storing email address in datastore and using its key as a local part to email can be a option.
精彩评论