尝试发送基本的 nodemailer 电子邮件 [英] trying to send basic nodemailer email
问题描述
我正在尝试将一些带有硬编码电子邮件数据的测试代码直接插入到我的 nodemailer server.js 文件中,以开始使用一个基本的工作示例.请参阅以下网址中的测试代码"部分:
I'm trying to insert some test code with hard-coded email data directly into my nodemailer server.js file to get started with a basic working example. See the "test code" section at the following url:
http://jsbin.com/sibubi/1/edit?html,js,控制台
Server.js 加载没有问题,没有测试代码.但是,当包含测试代码"部分时会发生错误.它抱怨不受支持的配置"并建议降级,但我从 nodemailer 网站复制了测试代码.知道问题可能是什么以及如何解决吗?这是错误:
Server.js loads without issue without the test code. However, an error occurs when the "test code" section is included. It complains about "unsupported configuration" and suggests a downgrade but I copied the test code from the nodemailer website. Any idea what the issue might be and how to fix? Here's the error:
http://jsbin.com/kehofe/1/edit
推荐答案
package.json
package.json
"nodemailer": "~1.4.0",
"nodemailer-smtp-transport":"~1.0.3"
安装
您的控制器代码
var nodemailer = require('nodemailer');
var smtpTransport = require('nodemailer-smtp-transport');
var transport = nodemailer.createTransport((smtpTransport({
host: YOUR_HOST,
secureConnection: false, // use SSL
port: 587, // port for secure SMTP
auth: {
user: YOUR_USERNAME,
pass: YOUR_PASSWORD
}
})));
您需要如上所述更改 SMTP 配置.其余同0.7版本代码.
You need to change the SMTP configuration as mentioned above. And the rest is same as 0.7 version code.
这篇关于尝试发送基本的 nodemailer 电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!