我的server.js文件包含以下代码段,应配置gmail地址并发送电子邮件。
Meteor.startup(() => {
// code to run on server at startup
process.env.MAIL_URL = 'smtps://email_address@gmail.com:password_without_special_keys@smtp.gmail.com:465';
Email.send({
from: "from_adddress@gmail.com",
to: "to_address@gmail.com",
subject: "Meteor Can Send Emails via Gmail",
text: "Its pretty easy to send emails via gmail."
})
});
当我使用命令
运行应用程序时,我的流星应用程序不应该发送电子邮件流星
?? 但它提供了以下错误。怎么了?
W20170718-15:36:37.701(6)? (STDERR) /home/forhadmethun/.meteor/packages/meteor-tool/.1.5.1.dvn6c8++os.linux.x86_32+web.browser+web.cordova/mt-os.linux.x86_32/dev_bundle/server-lib/node_modules/fibers/future.js:313
W20170718-15:36:37.766(6)? (STDERR) throw(ex);
W20170718-15:36:37.767(6)? (STDERR) ^
W20170718-15:36:37.769(6)? (STDERR)
W20170718-15:36:37.769(6)? (STDERR) Error: Connection timeout
W20170718-15:36:37.770(6)? (STDERR) at Object.Future.wait (/home/forhadmethun/.meteor/packages/meteor-tool/.1.5.1.dvn6c8++os.linux.x86_32+web.browser+web.cordova/mt-os.linux.x86_32/dev_bundle/server-lib/node_modules/fibers/future.js:449:15)
W20170718-15:36:37.771(6)? (STDERR) at Mail._syncSendMail (packages/meteor.js:213:24)
W20170718-15:36:37.772(6)? (STDERR) at smtpSend (packages/email.js:116:13)
W20170718-15:36:37.773(6)? (STDERR) at Object.Email.send (packages/email.js:174:5)
W20170718-15:36:37.774(6)? (STDERR) at server/main.js:28:11
W20170718-15:36:37.775(6)? (STDERR) at Function.time (/home/forhadmethun/WebstormProjects/EmailSEndProject/.meteor/local/build/programs/server/profile.js:309:28)
W20170718-15:36:37.776(6)? (STDERR) at /home/forhadmethun/WebstormProjects/EmailSEndProject/.meteor/local/build/programs/server/boot.js:347:13
W20170718-15:36:37.777(6)? (STDERR) at /home/forhadmethun/WebstormProjects/EmailSEndProject/.meteor/local/build/programs/server/boot.js:388:5
W20170718-15:36:37.779(6)? (STDERR) at Function.run (/home/forhadmethun/WebstormProjects/EmailSEndProject/.meteor/local/build/programs/server/profile.js:510:12)
W20170718-15:36:37.780(6)? (STDERR) at /home/forhadmethun/WebstormProjects/EmailSEndProject/.meteor/local/build/programs/server/boot.js:386:11
W20170718-15:36:37.781(6)? (STDERR) - - - - -
W20170718-15:36:37.782(6)? (STDERR) at SMTPConnection._formatError (/home/forhadmethun/.meteor/packages/email/.1.2.3.3ikb16++os+web.browser+web.cordova/npm/node_modules/node4mailer/lib/smtp-connection/index.js:558:19)
W20170718-15:36:37.784(6)? (STDERR) at SMTPConnection._onError (/home/forhadmethun/.meteor/packages/email/.1.2.3.3ikb16++os+web.browser+web.cordova/npm/node_modules/node4mailer/lib/smtp-connection/index.js:531:20)
W20170718-15:36:37.785(6)? (STDERR) at [object Object].<anonymous> (/home/forhadmethun/.meteor/packages/email/.1.2.3.3ikb16++os+web.browser+web.cordova/npm/node_modules/node4mailer/lib/smtp-connection/index.js:249:18)
W20170718-15:36:37.787(6)? (STDERR) at Timer.listOnTimeout (timers.js:92:15)
答案 0 :(得分:0)
您的MAIL_URL
变量应该是
smtps://username%40gmail.com:password@smtp.gmail.com:465
如果这样做无效,则需要allow the less secure applications和allow access to your account。如果操作正确,此步骤应允许从Gmail发送电子邮件。您可以通过查看此answer了解有关Gmail安全规则的更多信息。