0

Please don't mark this as a duplicate [it is not]. If we had a complete answer to this question, we wouldn't have so many people asking related but differing questions about emailing, account signup, etc. We need a complete tutorial on how to make account signup scenarios work for both GAE standard and flexible environments.

What is the best way to implement signup email confirmation using django-allauth on Google App Engine flexible environment? This seems to be a glaring hole in Google App Engine documentation.

After reading tens of articles, each with a piece or two (sometimes incompatible) information, and wasting time, we are still left not know why our setup is not working. Judging by the amount of questions relating to this issue on Stackoverflow, I would recommend either this tutorial or GAE sample projects dealing with account signup and email confirmation.

We would like to see a complete tutorial also include other third party email options on GAE--like SendGrid, Mailgun or Mail-jet--for both GAE standard and flexible environments.

Sunny
  • 1,464
  • 14
  • 26
  • 1
    Possible duplicate of [Django - SendMail on Google App Engine Flexible ENV](https://stackoverflow.com/questions/48629072/django-sendmail-on-google-app-engine-flexible-env) – BrettJ Feb 06 '18 at 05:45
  • 1
    It is quite confusing to read more than twenty different documents with bits and pieces of information just to get this simple activity completed. As a topic, verification of email addresses is a common scenario that needs a clear documentation that currently do not exist anywhere at the moment for GAE. – Sunny Feb 06 '18 at 16:27

1 Answers1

1

The documentation for GAE Flex includes instructions for sending emails with Mailgun, Mailjet and Sendgrid.

More detailed examples can be found on the respective pages of each of these options, which are linked to in the App Engine articles.

One thing you really have to pay attention to while researching how to do something on App Engine is that there's a lot of difference between Standard and Flex. I'm guessing that this is the source of conflicting information you've seen.

EDIT: I've created a free SendGrid account from the Cloud Launcher and then call the following code in one of my views:

import sendgrid
def send_message(to):
    sg = sendgrid.SendGridAPIClient(apikey=SENDGRID_API_KEY_GOES_HERE)

    to_email = mail.Email(to)
    from_email = mail.Email(SENDING_ADDRESS_GOES_HERE)
    subject = 'This is a test email'
    content = mail.Content('text/plain', 'Example message.')
    message = mail.Mail(from_email, subject, to_email, content)
    response = sg.client.mail.send.post(request_body=message.get())
    return response.body

Note, I'm using the SendGrid API python library as per the example on the GAE documentation.

You'll need to create a SendGrid API key and set up (and verify) a SendGrid sender and use them in the sample above.

With this I was able to send emails using SendGrid.

You'll need to implement the verification flow as well.

Edo Akse
  • 4,051
  • 2
  • 10
  • 21
  • I followed the instructions carefully. However, when django-allauth calls send_mail, we see '[CRITICAL] WORKER TIMEOUT' on the app log and 502 Bad Gateway / nginx on the page. It appears that the request never got to sendgrid servers (there is no activity recorded on our SendGrid profile) for the send_request. So the documentations you referenced are hardly complete. – Sunny Feb 08 '18 at 00:41
  • I've edited my answer to provide a working example using SendGrid's API python library. – Edo Akse Feb 23 '18 at 09:56