2017-04-20 95 views
1

我只是試圖發送Meteor的驗證電子郵件,根據此文檔:https://github.com/Shekharrajak/meteor-email,它返回下面的錯誤。我逐字跟蹤了文檔。郵件未發送;啓用發送,設置MAIL_URL環境變量

我的代碼

import { Meteor } from 'meteor/meteor'; 

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

    Email.send({ 
    to: "[email protected]", 
    from: "[email protected]", 
    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: [email protected] 
I20170420-14:49:35.023(1)? To: [email protected] 
I20170420-14:49:35.026(1)? Subject: Example Email 
I20170420-14:49:35.027(1)? Message-ID: <[email protected]> 
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 ====== 

我是什麼做的嗎?請協助。

+2

你確定要發送電子郵件之前的過程中的環境變量設置?嘗試在啓動塊中放入Email.send。 – bergjs

+1

如果您在此處使用'Meteor.isServer',則表示您的祕密正在發送給客戶端。這個文件應該在'server /'目錄下。 – Brendon

回答

1

檢查這個link也許你錯誤地配置了系統與mailgun。

使用軟件包meteorhacks:ssr更實用的發送和個性化郵件。

0

雖然我終於使用了gmail,但我做的簡單的錯誤並不是在流星中添加電子郵件是服務器方法:謝謝貢獻。

import { Meteor } from 'meteor/meteor'; 

if (Meteor.isServer){ 
    Meteor.startup(() => { 
process.env.MAIL_URL="smtp://mygmailaddress%40gmail.com:[email protected]:465/"; 
Email.send({ 
    to: "[email protected]", 
    from: "[email protected]", 
    subject: "Example Email", 
    text: "The contents of our email in plain text.", 
}); 
    }); 
} 
1
import { Meteor } from 'meteor/meteor'; 

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

Email.send({ 
    to: to, 
    from: "[email protected]", 
    subject: "Example Email", 
    text: "The contents of our email in plain text.", 
    }); 
    }); 
} 
0

或者之前運行流星,這樣你可以導出MAIL_URL在終端:

export MAIL_URL="smtp://yourGmailAddress:[email protected]:587"