【问题标题】:Mail not sent; to enable sending, set the MAIL_URL environment variable邮件未发送;要启用发送,请设置 MAIL_URL 环境变量
【发布时间】:2017-04-20 13:56:39
【问题描述】:

我只是想在 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 ======

我该怎么做?请帮忙。

【问题讨论】:

  • 您确定在尝试发送电子邮件之前设置了进程环境变量吗?尝试将Email.send 放在启动块中。
  • 如果您在此处使用Meteor.isServer,则表明您的机密正在发送给客户端。此文件应位于server/ 目录中。

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


【解决方案1】:

检查这个link也许你用mailgun错误地配置了系统。

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

【讨论】:

    【解决方案2】:
    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.",
         });
      });
    }
    

    【讨论】:

      【解决方案3】:

      或者你可以在运行meteor之前在终端中导出MAIL_URL,像这样:

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

      【讨论】:

        【解决方案4】:

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

        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.",
        });
          });
        }
        

        【讨论】:

          猜你喜欢
          • 2015-07-11
          • 2014-04-21
          • 2015-03-20
          • 1970-01-01
          • 2019-11-17
          • 2016-04-08
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多