Skip to content
This repository has been archived by the owner on Jun 29, 2021. It is now read-only.

Support for multiple sender emails #409

Open
diavrank opened this issue Oct 29, 2020 · 3 comments
Open

Support for multiple sender emails #409

diavrank opened this issue Oct 29, 2020 · 3 comments

Comments

@diavrank
Copy link

Before opening a new feature request, please note:

The problem:

Currently, if you want to send emails from a meteor app you can do it only with a sender email, which is configured in the MAIL_URL environment variable. So, I think if you have a small app that is enough but if you are going to build enterprise applications, it is very common to send emails from different senders such as promotions@yourcompany.com, support@yourcompany.com, sales@yourcompany.com, etc. So, yo can't do that with the package of Email Meteor.

Suggested solution:

I was researching and I found out that you have to use third dependencies such as nodemailer or ostrio:mailer, but I think that this feature should be in Email Meteor because I noticed that this package uses nodemailer, so, I think it shouldn't be a lot of work to take that feature of nodemailer into the Email package.

@StorytellerCZ
Copy link
Collaborator

I have started to move the email package to make this a bit easier. First step is making the send email hook public so that you can intercept emails being send out and based on that change their properties or you can stop them being send out completely and instead use your own api. That is also a common practice that for stuff that is not Meteor sending out email you use the API of the service you use.

@diavrank
Copy link
Author

diavrank commented Oct 30, 2020

Thank you. Also, I want to share you how I was imagining the usage of that part:

At the beginning of your file (for example MailServ.js) of email configuration put the following:

Email.config({//By default, the sender email will be established from **MAIL_URL**.
transports:[
{
    sender: "sales",
    host: "smtp.gmail.com",
    port: 587,
    secure: false, // true for 465, false for other ports
    auth: {
      user: "sales@yourcompany.com", 
      pass: "password",
    },
  },
....//more senders if you want
]
});

Once you have configured the email configuration, you can send emails as follow:

Email.send({
   sender:"sales",//this option is optional. By default, takes the default sender defined from MAIL_URL.
   to:"",
   from:"",
   subject:"",
   ...
});

This will be great on Meteor 2 :) .

I don't know if this can be possible or is difficult to implement it, but I think that is a simple way to use it.

References:
https://nodemailer.com/about/


On the other hand, I found out how to do it with G-Suite (gmail enterprise service). I had to configure some "aliases" for the email sender. These "aliases" are emails used for departments (sales, support, marketing, etc) in a company. So, I used a sender email as master (this is configured in the MAIL_URL environment variable) and for each Email.send({from}) I used the aliases and it worked!!!. However, I don't know if this is possible for other email providers (such as mailgun, microsoft outlook, etc). so, I still see it convenient to implement that feature for email package. Later, I will publish a post (on forum) to share this solution

@StorytellerCZ
Copy link
Collaborator

@diavrank I will consider this for the next major version of the email package.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants