0
votes

On my local server, I get this error when trying to send a mail

INFO 2017-03-01 16:54:06,819 mail_stub.py:143] MailService.Send
From: None "no-reply@None.appspotmail.com"
To: v*****@d******.com
Subject: Du contenu arrive à expiration (alldigital@test.gpartner.eu)
Body:
Content-type: text/plain
Data length: 50
INFO 2017-03-01 16:54:06,819 mail_stub.py:306] You are not currently sending out real email. If you have sendmail installed you can use it by using the server with --enable_sendmail

ERROR 2017-03-01 16:48:43,630 wsgi.py:279] Traceback (most recent call last):
File "/home/*****/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 268, in Handle
for chunk in result:
TypeError: 'NoneType' object is not iterable

My code is:

def send(recipient, subject, body):
    message = mail.EmailMessage(
        sender=u'{} <no-reply@{}.appspotmail.com>'.format(app_identity.get_application_id(),
                                                           app_identity.get_application_id()),
        subject=subject,
        body=body,
        to=recipient
    )
    message.check_initialized()
    message.send()

And I have no clue of what's wrong. D you have any to solve this issue or some things I could try to debug ?

Thanks for your help

2
Can you show the code calling send()? The error message is following the info msg from mail_stub.py, meaning it could actually be caused by something else after send() completes. Maybe add a debug print after send() to check this theory?Dan Cornilescu

2 Answers

1
votes

Ok my bad. It has nothing to do with the mails, I was just not returning anything at the end of the route handler. The error comes from there. Thanks for the help.

0
votes

In your logs, this is the sending email address:

From: None "no-reply@None.appspotmail.com"

I've never used app_identity.get_application_id() but it isn't working for you since it return "None". Rather than delve into that, why not hardcode the app id to see if that fixes the problem, i.e.:

sender=u'no-reply@myapp.appspotmail.com'