0

I have a web app built on React, and backend on NestJs. I want to integrate email platforms to my app. Let's say a user signed up in my app and then he uses other functionalities in the app. Then he wants to receive and send emails using my app and for that, he must integrate his email account (whether Gmail, Hotmail or any other email provider) with my app.

How can I provide such functionality? and What does it call?

I have tried to research a bit on it on Google and found some options like Nylas and MailGun. But I'm not sure if they are according to my case scenario.

Any lead and suggestion is appreciated. Thanks

Afzal Zubair
  • 202
  • 5
  • 13

2 Answers2

1

You will need an IMAP client to retrieve received emails from the remote servers (of Google, Microsoft etc.) you should be able to use IMAP Simple package.

Additionally you will also need an SMTP client to send emails and for this, you would need SMTP Client.

This would require the users to disclose their SMTP/IMAP details or in some cases their actual login details which might make them uncomfortable; however this approach is universal with almost all mail service providers/servers.

Alternatively if you are just targeting Gmail you can use the Gmail API where users would grant your app the permissions to send and access their mails.

You can also use the Microsoft Graph interface to access their Mail API to both send and receive emails from Hotmail / Outlook.

itsezc
  • 692
  • 2
  • 7
  • 20
  • 1
    Thanks for commenting. I understand what you are trying to explain here. But the thing is I won't be having SMTP/IMAP details (as normal users are not familiar with them) but I can have their authentication like Gmail or Outlook. One user logged in to my app can attach his/her Gmail as well as Outlook. and another user can have another email provider like Yahoo. Is there any other way to handle these scenarios? – Afzal Zubair Jan 15 '21 at 12:29
  • Yes, Gmail and Microsoft do allow you to authenticate users via OAuth or similar methods, and once completed you will be provided a token per user, which can be used to call the respective API to both retrieve and send email as the user. With Yahoo this is also possible have a look at Verizon Mail API documentation for reference. – itsezc Jan 15 '21 at 13:34
  • 1
    Thanks a lot, EZ-C. It's much clear now. I'm accepting this answer. – Afzal Zubair Jan 15 '21 at 13:39
1

Nylas absolutely fits this use case: the primary purpose is to enable developers to integrate their user's email accounts into an app. You can connect your own email account via the dashboard for testing purposes, or use the hosted auth service to automatically detect email providers and provide the appropriate login flow to connect the user email accounts. Once an account is connected, you can use the Threads and Messages endpoints to ingest email content and the Send and Outbox endpoints to send emails.

Mailgun, on the other hand, is a transactional email API service that is intended primarily for things like mass marketing emails, account management (password reset, email verification), etc. Afaik, it doesn't connect to your user's email accounts, even when it's being used to send emails from a specific user (the emails come from Mailgun's SMTP servers, not the user's provider). You can learn more about the difference between transactional email APIs (Mailgun) and contextual email APIs (Nylas) here.

  • I'm glad you replied and the information is useful. I did research on Nylas and MailGun a bit and I found that MailGun is for transactional emails but I read somewhere that it can also receive emails, haven't found anything with contextual emails from MailGun yet. On the other hand, Nylas fits my purpose. Good Ben Lloyd Pearson. – Afzal Zubair Jan 16 '21 at 06:00