Error: 421 Timeout waiting for data from client using express-mailer with attachments
Error: 421 Timeout waiting for data from client using express-mailer with attachments
我正在使用 express-mailer
(建立在 nodemailer
之上)从我的 nodejs
应用程序发送电子邮件。如果我发送一封普通的 html 电子邮件,效果很好,但如果我尝试附加文件,我会收到 Error: 421 Timeout waiting for data from client
.
请注意,该错误仅在我使用 Amazon SES 作为 smtp 服务器时出现。如果我使用其他电子邮件服务器,则会发送电子邮件。我已经尝试 google 这个问题,但没有找到答案。有人可以帮助我吗?
这是我的代码:
var mailer = require('express-mailer');
mailer.extend(app, {
from: 'No Reply <no-reply@no-reply.com>',
host: 'email-smtp.us-east-1.amazonaws.com',
secureConnection: false,
port: 587,
transportMethod: 'SMTP',
auth: {
user: 'user',
pass: 'password'
}
});
var mailConfig = {
to: 'me@email.com',
subject: 'email_subject',
data: {
name: 'name'
}
};
var sendOptions = {
template: 'emailTemplate',
attachments: [{
fileName: 'attachment.pdf', filePath: 'data/attachment.pdf'}
}]
};
app.mailer.send(sendOptions, mailConfig, function (err)
{
if (err)
console.log(err + '\n' + __filename + ' ' + __functionName + ' ' + __lineNumber);
});
没关系。我只是将 port
更改为 465
,将 secureConnection
更改为 true
。
我正在使用 express-mailer
(建立在 nodemailer
之上)从我的 nodejs
应用程序发送电子邮件。如果我发送一封普通的 html 电子邮件,效果很好,但如果我尝试附加文件,我会收到 Error: 421 Timeout waiting for data from client
.
请注意,该错误仅在我使用 Amazon SES 作为 smtp 服务器时出现。如果我使用其他电子邮件服务器,则会发送电子邮件。我已经尝试 google 这个问题,但没有找到答案。有人可以帮助我吗?
这是我的代码:
var mailer = require('express-mailer');
mailer.extend(app, {
from: 'No Reply <no-reply@no-reply.com>',
host: 'email-smtp.us-east-1.amazonaws.com',
secureConnection: false,
port: 587,
transportMethod: 'SMTP',
auth: {
user: 'user',
pass: 'password'
}
});
var mailConfig = {
to: 'me@email.com',
subject: 'email_subject',
data: {
name: 'name'
}
};
var sendOptions = {
template: 'emailTemplate',
attachments: [{
fileName: 'attachment.pdf', filePath: 'data/attachment.pdf'}
}]
};
app.mailer.send(sendOptions, mailConfig, function (err)
{
if (err)
console.log(err + '\n' + __filename + ' ' + __functionName + ' ' + __lineNumber);
});
没关系。我只是将 port
更改为 465
,将 secureConnection
更改为 true
。