Sending email using Gmail SMTP - Meteorjs

时光怂恿深爱的人放手 提交于 2019-12-03 14:35:42

Sucks that cloud9 does not permit the setting of environment variables. Perhaps you can set the Meteor.settings object rather than an environment variable?

http://docs.meteor.com/#/full/meteor_settings

Essentially, you can pass JSON to meteor when you start it using --settings. These will be available on the server side only, unless wrapped under a "public" object of the root.

{
  'public': {
     'some-setting': 'some-value'
  },
  'other-setting': 'other-value'
}

That is a work around for dealing with no envrionmental variables. As the core email package always looks at the MAIL_URL environmental variable, you will probably need to send email through another service/provider.

Mandrill (by Mailchimp) have a sizeable free tier and will allow you to send transactional email. You can even make a mail template in mailchimp, export to HTML, import to mandrill and pass in merge variables in your API calls.

Better yet, there is a kick-ass package for writing to the Mandrill API. https://atmospherejs.com/wylio/mandrill

Hope that helps!

Elliott

but decided to answer my own question anyway.

I didnt and I cant set the C9 or my testing site env variable, so that s why.

The Meteor.startup(callback) method is executed at the end of Meteor initialization, but you are sending your email before the startup, so you should send it in the same block, after process.env.MAIL_URL..

You CAN set environmental variables using C9! You just pass it in when you run meteor.

BUT you can not send email using SMTP though on c9!

To make my life easier I just don't test my emails on c9 with Meteor. If I absolutely need to I bypass the email function and use a custom emailer instead that sends using the MailGun REST API (NOT SMTP!!) See Sending email using Gmail SMTP - Meteorjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!