我正在创建一个流星应用程序,我添加了mrt accounts-password包以及mrt accounts-ui-bootstrap-dropdown。
我添加了登录按钮,以便用户可以创建一个帐户,并且工作得很好。我正在使用所有默认值。
在服务器上我有代码:
Accounts.config({
sendVerificationEmail: true,
forbidClientAccountCreation: false
});
当我创建一个新帐户时,服务器控制台会打印:
I20130821-18:31:42.105(-4)? ====== BEGIN MAIL #0 ======
I20130821-18:31:42.106(-4)? MIME-Version: 1.0
I20130821-18:31:42.107(-4)? From: "Meteor Accounts" <no-reply@meteor.com>
I20130821-18:31:42.108(-4)? To: hidden@hidden.edu
I20130821-18:31:42.108(-4)? Subject: How to verify email address on localhost:3000
I20130821-18:31:42.109(-4)? Content-Type: text/plain; charset=utf-8
I20130821-18:31:42.109(-4)? Content-Transfer-Encoding: quoted-printable
I20130821-18:31:42.109(-4)? Hello,
I20130821-18:31:42.110(-4)? To verify your account email, simply click the link below.
I20130821-18:31:42.110(-4)? http://localhost:3000/#/verify-email/C2vJeaDLeMkkWmcRY
I20130821-18:31:42.111(-4)? Thanks.
I20130821-18:31:42.111(-4)? ====== END MAIL #0 ======
所以看起来它从服务器发送电子邮件但我从未在收件箱中收到验证邮件。我尝试过多次,已经超过一个小时了!我还查看了垃圾邮件文件夹。是什么给了什么?
提前致谢
答案 0 :(得分:18)
见这里:http://docs.meteor.com/#email
如果未设置MAIL_URL(例如,在本地运行应用程序时),则Email.send会将消息输出到标准输出
Meteor等Web服务器无法自行发送电子邮件,需要SMTP服务器来执行此操作。您需要设置一个并使用MAIL_URL
变量进行设置。
答案 1 :(得分:14)
要配置MAIL_URL
,请不要忘记添加核心电子邮件包:
meteor add email
然后,服务器端:
// server/smtp.js
Meteor.startup(function () {
smtp = {
username: 'your_username', // eg: server@gentlenode.com
password: 'your_password', // eg: 3eeP1gtizk5eziohfervU
server: 'smtp.gmail.com', // eg: mail.gandi.net
port: 25
}
process.env.MAIL_URL = 'smtp://' + encodeURIComponent(smtp.username) + ':' + encodeURIComponent(smtp.password) + '@' + encodeURIComponent(smtp.server) + ':' + smtp.port;
});