我想从我的开发服务器上的节点应用程序中发送电子邮件以进行测试(运行macOS 10.11.6)。我可以从命令行发送电子邮件,如下所示:
$ date | mail -s testing my@email.address
我正在尝试使用emailjs
,这似乎是相当标准的,但是我收到了ECONNREFUSED错误。我无法找出为什么连接不成功,有关其他调试信息的任何提示?
const email = require('emailjs')
const smtp = email.server.connect({
user: process.env.SMTP_USER,
password: process.env.SMTP_PASSWORD,
host: process.env.SMTP_HOST,
ssl: !!process.env.SMTP_ENABLE_SSL
})
smtp.send({
from: 'noreply@localhost',
to: recipient,
subject: 'Test subject',
text: 'Hello world'
}, err => err ? console.error('Error when sending mail', err) : done()
)
日志输出如下所示:
Error when sending mail { Error: connection encountered an error
at module.exports (/code/server/node_modules/emailjs/smtp/error.js:3:13)
at TLSSocket.error (/code/server/node_modules/emailjs/smtp/response.js:26:29)
at emitOne (events.js:101:20)
at TLSSocket.emit (events.js:188:7)
at emitErrorNT (net.js:1281:8)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
code: 5,
previous:
{ Error: connect ECONNREFUSED 127.0.0.1:465
at Object.exports._errnoException (util.js:1026:11)
at exports._exceptionWithHostPort (util.js:1049:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 465 },
smtp: undefined }
这是postfix
的配置问题吗?我使用标准配置,mail
足够聪明,可以解决这个问题。如何找到默认凭据?提前谢谢!