1

To send e-mails I want to use SMTP url with different api key's and for that want to set env variable dynamically.
For example, on the server the below code would be used to set my env variable for setting up a mail smtp.

Meteor.startup( function() {
 process.env.MAIL_URL = "<Our URL here with dynamic api key value from Database>";
});

Because of this it sets env variable first time with single value and after that does not getting chanege once the value gets set. How can i change and modify the api key value to send e-mail? any help or suggestion with the implementation for the same will be appreciated.

Suhas Gavad
  • 1,199
  • 1
  • 8
  • 12
  • sounds like you could do it any time in theory, but it's not guaranteed to work. See http://meteorpedia.com/read/Environment_Variables#Setting%20the%20value%20of%20an%20Environment%20Variable - specifically the line "You can also set/change an environment variable from inside Meteor, but you need to set it before it's used." It does then go on to make a caveat about MAIL_URL, suggesting you can set this later as long as you haven't already sent any mail, but that doesn't sound like it's that helpful in your case. – ADyson Dec 09 '16 at 14:15
  • ok. I want to send e-mails using different sub-accounts and for that i need to add each sub-account credential i.e. apiKey in smtp url respectively. So the problem is, once I set the smtp url with specific sub-account credential at the time of sending first e-mail from project then after that I am unable to send e-mail using different apiKey. the key value I am fetching dynamically from database. how can i change and modify the api key value to send e-mail? any help or suggestion with the implementation for the same will be appreciated. – Suhas Gavad Dec 12 '16 at 06:52
  • Well I don't know much about Meteor / Node, but from that link I gave you it sounds like a fundamental limitation of the software. Again I don't know a lot about it but can you declare multiple instances of meteor? Then each one would have its own env settings? I've no idea if that would actually work or not, hence a comment not an answer! – ADyson Dec 12 '16 at 09:20

0 Answers0