我正在尝试通过没有SMTP传输的nodemailer发送电子邮件。因此,我做到了:
I am trying to send emails via nodemailer without SMTP transport. So i've done that:
var mail = require("nodemailer").mail; mail({ from: "Fred Foo ✔ <foo@blurdybloop>", // sender address to: "******@gmail", // list of receivers subject: "Hello ✔", // Subject line text: "Hello world ✔", // plaintext body html: "<b>Hello world ✔</b>" // html body });但是当我跑步时我会得到:
But when I run I get that :
> node sendmail.js Queued message #1 from foo@blurdybloop, to vinz243@gmail Retrieved message #1 from the queue, reolving gmail gmail resolved to gmail-smtp-in.l.google for #1 Connecting to gmail-smtp-in.l.google:25 for message #1 Failed processing message #1 Message #1 requeued for 15 minutes Closing connection to the server Error: read ECONNRESET at errnoException (net.js:901:11) at TCP.onread (net.js:556:19)我在Windows 7 32上。
I am on windows 7 32.
编辑 这似乎是与Windows相关的错误,因为它可以在Linux上运行
EDIT This seems to be a windows related bug for it worked on linux
编辑#2
在git shell上,如果输入 telnet smtp.gmail 587 在此处被阻止:
On the git shell, if I enter telnet smtp.gmail 587 it is blocked here:
220 mx.google ESMTP f7...y.24 -gsmtp推荐答案
从您的示例输出中看,它似乎连接到错误的端口25,已打开的gmail smtp端口为465(用于SSL)和其他587 TLS。
From your example output it seems to connecting to wrong port 25, gmail smtp ports which are opened are 465 for SSL and the other 587 TLS.
Nodemailer根据电子邮件域检测到正确的配置,在您的示例中,您尚未设置运输对象,因此它使用已配置的默认端口25。要更改端口,请在选项中指定类型。
Nodemailer detects the correct configuration based on the email domain, in your example you have not set the transporter object so it uses the default port 25 configured. To change the port specify in options the type.
以下是应该与gmail配合使用的小示例:
Here's the small example that should work with gmail:
var nodemailer = require('nodemailer'); // Create a SMTP transport object var transport = nodemailer.createTransport("SMTP", { service: 'Gmail', auth: { user: "test.nodemailer@gmail", pass: "Nodemailer123" } }); console.log('SMTP Configured'); // Message object var message = { // sender info from: 'Sender Name <sender@example>', // Comma separated list of recipients to: '"Receiver Name" <nodemailer@disposebox>', // Subject of the message subject: 'Nodemailer is unicode friendly ✔', // plaintext body text: 'Hello to myself!', // HTML body html:'<p><b>Hello</b> to myself <img src="cid:note@node"/></p>'+ '<p>Here\'s a nyan cat for you as an embedded attachment:<br/></p>' }; console.log('Sending Mail'); transport.sendMail(message, function(error){ if(error){ console.log('Error occured'); console.log(error.message); return; } console.log('Message sent successfully!'); // if you don't want to use this transport object anymore, uncomment following line //transport.close(); // close the connection pool });更多推荐
Nodemailer发送电子邮件而无需SMTP传输
发布评论