Best place for MAIL_URL?

I am wondering the best place to put the MAIL_URL configuration?

It needs to be loaded before some other functions, so I would think the Lib directory is a good place for it… but I am worried that since lib is shared on both client and server, there may be some security issues by doing that.

Any advice on where the best place to put the file is? Would a lib/server directory be sufficient, and not share the SMTP information with clients?

1 Like

The absolute best place to store your MAIL_URL setting is outside of your application completely. MAIL_URL is an environment variable, that should ideally be set within your environment, not through your application. There are several ways to handle this depending on your environment. With Galaxy for example you would add it to the env section of your settings.json:

{ "": { "env": { "MAIL_URL": "...", ... } }, ... }

With mupx you can set it in your mup.json:

  "env": {
    "MAIL_URL": "...",

You can set it as an environment variable MAIL_URL=... meteor

Ah I’m not going to be ready for deployment for awhile, should I not worry about this until then?

Or you can get the best of both by having a settings file


Then in server/lib/config.js you can have

Meteor.startup(function () {
  process.env.MAIL_URL = Meteor.settings.smtp;

Then you can just run meteor --settings settings.json and it will work the same.


If you’re in development phase you don’t have to set it at all. All “sent” emails will be sent to the terminal window where you started Meteor command. That way you can verify that they work correctly without setting up an actual email provider.

Of course it’s still beneficial to set up MAIL_URL later in the dev cycle to test how sent emails look like and whether your email provider handles them correctly.

1 Like

Thanks all for the advice! =)

What I’m wondering is what is the equivalent parent of env for localhost (or any other hypothetical environment)? Would that mean you could specify different env blocks in the same settings.json file?

1 Like