The meteor says the MAIL_URL variable is not set, but it

I am 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: admin@example.com
I20150423-22:09:09.079(-7)? To: victor@example.com
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 went into the Meteor Shell, and I realized:

> process.env.MAIL_URL
'smtp://MY_MANDRILL_EMAIL:MY_MANDRILL_API_KEY@smtp.mandrillapp.com:587/'

Uh, so the MAIL_URL IS variable is set ....

To be sure, I put this in a file mailer.jsin a folder server.

Meteor.startup(function () {
  process.env.MAIL_URL = 'smtp://MY_MANDRILL_EMAIL:MY_MANDRILL_API_KEY@smtp.mandrillapp.com:587/';
});

The same error will occur. It just works in the local host.

EDIT - I got it working, but I don't know why I am doing this:

I noticed through some console logging that the letter tried to be knocked down before the environment variable was set, despite setting the environment variable inside Meteor.startup()

As a result, I created the file mailer_variable.jsinsideserver/lib

process.env.MAIL_URL = 'smtp://MY_MANDRILL_EMAIL:MY_MANDRILL_API_KEY@smtp.mandrillapp.com:587';
console.log('this is the mail_url: ', process.env.MAIL_URL);

. , . , , , Mandrill , ...

+4
1

, Meteor. startup script.

Linux/Mac - Meteor :

MAIL_URL="smtp://.../" meteor

export MAIL_URL="smtp://.../"
meteor

: http://meteorpedia.com/read/Environment_Variables

+2

Source: https://habr.com/ru/post/1584413/


All Articles