trying to send basic nodemailer email

时光总嘲笑我的痴心妄想 提交于 2020-02-02 06:10:41

问题


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,console

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


回答1:


package.json

"nodemailer": "~1.4.0",
"nodemailer-smtp-transport":"~1.0.3"

install them

Your controller code

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
  }
})));

You need to change the SMTP configuration as mentioned above. And the rest is same as 0.7 version code.




回答2:


Looks like nodemailer 1.0 has breaking changes so 0.7 must be used instead: http://www.nodemailer.com/

Message posted on nodemailer as of 12/17/15:

Do not upgrade Nodemailer from 0.7 or lower to 1.0 as there are breaking changes. You can continue to use the 0.7 branch as long as you like. See the documentation for 0.7 here.



来源:https://stackoverflow.com/questions/27499351/trying-to-send-basic-nodemailer-email

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!