MAIL_URL not being set


While trying to use the forgotPassword function from Meteor’s Account package I’ve encountered the following error:

Exception while invoking method ‘forgotPassword’ Error: Email protocol in $MAIL_URL (undefined) must be ‘smtp’ or 'smtps’
I20171102-15:48:25.560(-5)? at makeTransport (packages\email.js:45:11)
I20171102-15:48:25.561(-5)? at getTransport (packages\email.js:78:24)
I20171102-15:48:25.562(-5)? at new Email.send (packages\email.js:172:19)
I20171102-15:48:25.562(-5)? at Object.Email.send (packages\meteortoys_email.js:28:25)
I20171102-15:48:25.563(-5)? at AccountsServer.Accounts.sendResetPasswordEmail (packages/accounts-password/password_server.js:614:9)
I20171102-15:48:25.564(-5)? at [object Object].Meteor.methods.forgotPassword (packages/accounts-password/password_server.js:546:12)
I20171102-15:48:25.564(-5)? at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1768:12)
I20171102-15:48:25.565(-5)? at packages/ddp-server/livedata_server.js:719:19
I20171102-15:48:25.566(-5)? at [object Object]..extend.withValue (packages\meteor.js:1126:17)
I20171102-15:48:25.566(-5)? at packages/ddp-server/livedata_server.js:717:46
I20171102-15:48:25.567(-5)? at [object Object].
.extend.withValue (packages\meteor.js:1126:17)
I20171102-15:48:25.567(-5)? at packages/ddp-server/livedata_server.js:715:46
I20171102-15:48:25.568(-5)? at [object Object]._.extend.protocol_handlers.method (packages/ddp-server/livedata_server.js:689:23)
I20171102-15:48:25.568(-5)? at packages/ddp-server/livedata_server.js:559:43

It seems like my MAIL_URL is not being set, however I am doing so in the meteor start up function:

import { Meteor } from ‘meteor/meteor’;
Meteor.startup(function () {
process.env.MAIL_URL = Meteor.settings.mail;

if i do a console log i can see that MAIL_URL is set correctly, however i still get this error. Any ideas on what might be wrong?


IIRC, Meteor.startup runs after all the dependencies have been compiled and initialized, therefore MAIL_URL is not defined soon enough. Since MAIL_URL is meant to be an environment variable, you can export it before you run meteor.

For example, you should be able to run

MAIL_URL='smtp://username:pwd@address:port' meteor run --settings settings.json


Thanks for the reply, sadly that didn’t work either. The weird thing is that I’ve used the MAIL_URL set on startup on other projects and it worked fine, but i can’t figure out why it isn’t working out with this particular project.


NVM found the error elsewhere