'How can I allow users to send emails through my django app but coming from their own gmail account?

I have a django app where users can send emails through the app to contacts that they upload themselves. I use Sendgrid to send the email and the recipient receives an email from a "white-label" address like [email protected]

Now, I would like to implement a system where I can allow users to send emails through our app but that those emails are sent by their own email address. To make it simple, let's just consider "Gmail" and if a user want they can "login with their gmail account" on my app and then send emails from my app that are sent from their account... I know that Gmail has an API and I wonder if I can leverage it to do what I need.



Solution 1:[1]

You can definitely send emails using Gmail API methods but keep in mind the below stated in their official documentation:

Note: The Gmail API shouldn't be used to replace IMAP for developing a full-fledged email client. Instead, see IMAP, POP, and SMTP.

As they recommend, you could integrate IMAP/SMTP features in your application so users can authenticate/provide access to their accounts and achieve your goal of having emails sent from their accounts.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Yancy Godoy