下面是我的代码。这适用于Gmail 邮件服务器。
但是当我使用我的办公室(不需要身份验证)时它失败了
可能是我使用的语法是错误的。
下面是使用 gmail smtp 的代码:
var mailOptions = {
from: '[email protected] /cdn-cgi/l/email-protection',
to: '[email protected] /cdn-cgi/l/email-protection',
subject: 'hello world!',
html: '<img src="cid:logo">',
attachments: [{
filename: 'test.png',
path: 'D:/bbbbb/mmmm/src/test.png',
cid: 'logo' //same cid value as in the html img src
}]
};
transport.sendMail(mailOptions, (error, info) => {
if (error) {
console.log(error);
}
console.log(`Message sent: ${info.response}`);
});
作为我们公司smtp
不需要身份验证,
我试过下面的代码:
var transport = nodemailer.createTransport("smtps://[email protected] /cdn-cgi/l/email-protection:"+encodeURIComponent('') + "@xxxx.xxxrxx.com:25");
OR
var transport = nodemailer.createTransport("smtps://xxx.xxx.com:25");
但一切都导致错误
{ Error: 101057795:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:openssl\ssl\s23_clnt.c:797:
at Error (native) code: 'ECONNECTION', command: 'CONN' }
我的猜测是语法错误。
有人可以纠正我吗
感谢致敬。