I'm getting this error message in the terminal "Mail not sent; to enable sending, set the MAIL_URL environment variable." despite setting MAIL_URL environment variable. After this message the whole mail content html gets dumped in the terminal. I'm using 2 meteor packages for sending email: yogiben:pretty-emails and email with mailgun api service.
Here's the source code for the mail config and sending email:
if Meteor.isServer
Meteor.startup ->
process.env.MAIL_URL = 'smtp://sandboxid.mailgun.org:mypassword@smtp.mailgun.org:587'
return
PrettyEmail.options =
from: 'primaryemail@gmail.com'
siteName: 'Meteor Test'
companyAddress: 'sdfsf, gdfg-df'
companyName: 'Code to Create'
companyUrl: 'http://example.com'
Accounts.sendVerificationEmail ->
Meteor.userId()
This file is kept inside Project_Directory/both/_config directory. I'm currently developing this app on local ubuntu server.
I came across the same error. The trick was to not include the MAIL_URL in the application, but in the terminal where you run meteor itself.
Use the following command to run meteor:
MAIL_URL="smtp://postmaster@sandbox****.mailgun.org:XXXX@smtp.mailgun.org:587" meteor
I tried this on Ubuntu Terminal, hence should work on Mac as well.
I think the call to
sendVerificationEmail
should be:as per the docs at http://docs.meteor.com/#/full/accounts_sendverificationemail
If that code is the exact code you're using, then you may be having issues because of the order in which each piece of code runs (callbacks run asynchronously). The startup callback will run after
PrettyEmail.options
andAccounts.sendVerificationEmail
If you indent those two sections as follows it should work as expected:
Failing that it may also be worth setting
MAIL_URL
before running the app, for example:EDIT: Your example code is not secure: If you are keeping this code in the 'both' directory, then anyone accessing your website will be able to see your mailgun credentials. You should put server code in the 'server' directory or at the very least set the MAIL_URL outside of your code as shown above.