3
votes

Here's the code I'm using to send mail (not exactly, I have a different body, subject and the sender's mail that I haven't put up for privacy reasons):

body="Some body"
subject="Some Subject"
email = user.email # user.email returns a valid email address

mail.send_mail('[email protected]', email, subject, body)

The code executes without Exception, my App Engine Quota for calls to the Mail API increases, as does the quota for the number of emails sent, indicating a successful email send. However, when I check my mail, I do not get the email.

I've tried changing the subject, body, sender email etc. but whether or not I receive the mail seems totally random - I receive it sometimes (rarely) and don't at other times. The mails aren't even there in my spam folder.

What's going on? And how do I ensure that the mail is received each time?

1
Did you configure your app to receive bounce notifications? cloud.google.com/appengine/docs/python/mail/bounce - that's how you'd normally know why messages aren't delivered. - Dan Cornilescu
can you check if the difference is the presence in the msg body of a link to the app's appspot.com domain or not? - Dan Cornilescu

1 Answers

0
votes

For the 2nd question: you can't ensure the messages are received (without an additional extra receipt acknowledging service - a different beast), you can, at best, detect if they are passed successfully to the mail sending infrastructure or not. See also mail.send() feature in web2py for bounced email/ email address that doesnt exist.