Meteorite mail is not sent despite changing the environment variable MAIL_URL

I get this error message in the “Mail not sent” terminal to enable sending, set the MAIL_URL environment variable. Despite setting the MAIL_URL environment variable. After this message, all html mail content is dumped to the terminal. I use 2 meteor packets to send electronic Mail: yogiben: beautiful emails and emails using the api mailgun service.

Here is the source code for configuring mail 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 stored inside the Project_Directory / both / _config directory. I am currently developing this application on a local ubuntu server.

+1
source share
2 answers

I think the sendVerificationEmail call should be:

 Accounts.sendVerificationEmail Meteor.userId() 

according to docs http://docs.meteor.com/#/full/accounts_sendverificationemail

If this code is the exact code that you are using, you may have problems due to the order in which each part of the code is executed (callbacks are executed asynchronously). The launch callback is triggered after PrettyEmail.options and Accounts.sendVerificationEmail

If you insert these two sections in the following order, they should work as expected:

 if Meteor.isServer Meteor.startup -> process.env.MAIL_URL = 'smtp://sandboxid.mailgun.org: mypassword@smtp.mailgun.org :587' 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() 

Otherwise, it might be worth setting MAIL_URL before starting the application, for example:

 MAIL_URL="smtp://sandboxid.mailgun.org: mypassword@smtp.mailgun.org :587" meteor 

EDIT: Example code is not secure: If you save this code in the “both” directory, any user accessing your website will be able to see your email credentials. You must put the server code in the server directory, or at least set MAIL_URL outside your code, as shown above.

0
source

I came across the same error. The trick was not to include MAIL_URL in the application, but in the terminal where you launch the meteor itself.

To start the meteor, use the following command:

MAIL_URL = "smtp: // postmaster@sandbox ****. Mailgun.org: XXXX@smtp.mailgun.org : 587" meteor

I tried this on a Ubuntu terminal, so it should work on a Mac too.

0
source

All Articles