邮件未发送;要启用发送,请设置MAIL_URL环境变量

时间:2017-04-20 13:56:40

标签: meteor smtp gmail meteor-blaze email-verification

我只是尝试在Meteor中发送验证电子邮件,根据此文档:https://github.com/Shekharrajak/meteor-email,它会返回以下错误。我按照文件逐字逐句。

我的代码

import { Meteor } from 'meteor/meteor';

if (Meteor.isServer){
  Meteor.startup(() => {
    process.env.MAIL_URL="smtp://mygmailaddress%40gmail.com:mypassword@smtp.gmail.com:465/";
  });

  Email.send({
  to: "sendeto@yahoo.com",
  from: "sendfrom@gmail.com",
  subject: "Example Email",
  text: "The contents of our email in plain text.",
});

}

错误讯息:

W20170420-14:49:33.820(1)? (STDERR) js-bson: Failed to load c++ bson extension, using pure JS version
I20170420-14:49:34.997(1)? ====== BEGIN MAIL #0 ======
I20170420-14:49:34.998(1)? (Mail not sent; to enable sending, set the MAIL_URL environment variable.)
I20170420-14:49:35.019(1)? Content-Type: text/plain
I20170420-14:49:35.021(1)? From: kehindeadeoya@gmail.com
I20170420-14:49:35.023(1)? To: ken4ward@yahoo.com
I20170420-14:49:35.026(1)? Subject: Example Email
I20170420-14:49:35.027(1)? Message-ID: <6b59f210-f727-aff3-2695-335a774e936a@gmail.com>
I20170420-14:49:35.028(1)? Content-Transfer-Encoding: 7bit
I20170420-14:49:35.031(1)? Date: Thu, 20 Apr 2017 13:49:35 +0000
I20170420-14:49:35.032(1)? MIME-Version: 1.0
I20170420-14:49:35.034(1)?
I20170420-14:49:35.050(1)? The contents of our email in plain text.
I20170420-14:49:35.052(1)? ====== END MAIL #0 ======

我该怎么做?请协助。

4 个答案:

答案 0 :(得分:1)

检查link可能是您使用mailgun错误配置了系统。

使用包meteorhacks:ssr更实用,可以发送和个性化邮件。

答案 1 :(得分:1)

import { Meteor } from 'meteor/meteor';

Meteor.startup(function () {
  if(Meteor.isServer) {
 process.env.MAIL_URL="smtp://mygmailaddress%40gmail.com:mypassword@smtp.gmail.com:465/";

Email.send({
  to: to,
  from: "sendfrom@gmail.com",
  subject: "Example Email",
  text: "The contents of our email in plain text.",
     });
  });
}

答案 2 :(得分:1)

或者您可以在运行meteor之前导出终端中的MAIL_URL,如下所示:

export MAIL_URL="smtp://yourGmailAddress:yourPassword@smtp.gmail.com:587"

答案 3 :(得分:0)

虽然我最终使用了gmail,但我所犯的简单错误并不是在流星中添加电子邮件是服务器方法:感谢您的贡献。

    #include <iostream>    
    #include <fstream>      // std::ofstream

    int main () 
    {
      std::ofstream ofs;
      ofs.open ("hye.txt");
      if (ofs.is_open())
      {
        ofs << "hellow world";
        cout << "successfully written to file";
        ofs.close();
      }
      else
      {
        cout << "Error opening file";
      }
      return 0;
    }