【发布时间】:2014-06-01 17:04:26
【问题描述】:
我的结构:
site
-- node_modules
---- nodemailer
-- webclient
---- js
------- controller.js
site/node_modules/nodemailer
site/webclient/js/controller.js
site/webclient/js/controller.js:
var nodemailer = require('../../node_modules/nodemailer');
var transport = nodemailer.createTransport('SES', {
AWSAccessKeyID: 'xxx', // real one in code
AWSSecretKey: 'xxx', // real one in code
ServiceUrl: 'email-smtp.us-west-2.amazonaws.com'
});
var message = {
from: 'example@mail.com', // verified in Amazon AWS SES
to: 'example@mail.com', // verified in Amazon AWS SES
subject: 'testing',
text: 'hello',
html: '<p><b>hello</b></p>' +
'test'
};
transport.sendMail(message, function(error) {
if (error) {
console.log(error);
} else {
console.log('Message sent: ' + response.message);
}
});
此代码是控制器的一部分,其中的所有其他功能都可以完美运行。
- 我有什么遗漏吗?
- 也许我调用了不正确的 nodemailer 模块?
- 或者传输应该是 SMTP,而不是 SES?
我被困住了。
【问题讨论】:
-
您可以考虑描述实际问题。您是否收到错误消息等。
-
实际问题是它不发送电子邮件。没有错误信息。我应该在哪里看到它?控制台不返回任何内容。
-
您确定将正确的参数传递给
transport.sendMail()函数吗?你只传入一个函数,但通常你传入一个处理成功的函数和一个处理错误的单独函数。当然,我对 nodemailer 并不熟悉,因为它没有成功路径的回调,这似乎有点奇怪。 -
请在下方标记为正确答案
标签: javascript amazon-ses nodemailer