Reputation: 5254
I'm using this Mandrill package:
https://atmospherejs.com/wylio/mandrill
When I try to send an email I get this error:
I20150423-22:09:09.078(-7)? ====== BEGIN MAIL #0 ======
I20150423-22:09:09.078(-7)? (Mail not sent; to enable sending, set the MAIL_URL environment variable.)
I20150423-22:09:09.079(-7)? MIME-Version: 1.0
I20150423-22:09:09.079(-7)? From: [email protected]
I20150423-22:09:09.079(-7)? To: [email protected]
I20150423-22:09:09.079(-7)? Subject: Something something
I20150423-22:09:09.079(-7)? Content-Type: text/html; charset=utf-8
I20150423-22:09:09.079(-7)? Content-Transfer-Encoding: quoted-printable
I20150423-22:09:09.079(-7)?
I20150423-22:09:09.079(-7)? Some kind of message content.
I20150423-22:09:09.079(-7)? ====== END MAIL #0 ======
So I go into the Meteor Shell and I get this:
> process.env.MAIL_URL
'smtp://MY_MANDRILL_EMAIL:[email protected]:587/'
Uh, so the MAIL_URL variable IS being set....
Just to be sure, I put this in a mailer.js
file under the server
folder.
Meteor.startup(function () {
process.env.MAIL_URL = 'smtp://MY_MANDRILL_EMAIL:[email protected]:587/';
});
The same error happens. This is just running everything in localhost.
EDIT - I got it working, but I don't know why I'm doing this:
I noticed through some console logging that the email was trying to be shot off before the environmental variable was being set, despite setting the environmental variable inside of Meteor.startup()
What I ended up doing was creating a mailer_variable.js
file inside server/lib
process.env.MAIL_URL = 'smtp://MY_MANDRILL_EMAIL:[email protected]:587';
console.log('this is the mail_url: ', process.env.MAIL_URL);
This works. But I'm not sure why. It certainly isn't what the Mandrill package author says I should be doing...
Upvotes: 4
Views: 3476
Reputation: 3816
I believe this has to do with the load order of Meteor. I don't recommend setting environment variables in the startup script precisely for this reason.
The correct way to set this is on Linux/Mac is to start Meteor like this:
MAIL_URL="smtp://.../" meteor
or
export MAIL_URL="smtp://.../"
meteor
More details are documented here: http://meteorpedia.com/read/Environment_Variables
Upvotes: 2