3
我使用nodemailer以發送電子郵件
var nodemailer = require('nodemailer'),
config = require('./mailer.conf');
var smtpTransport;
console.log('Creating Transport');
//smtp transport configuration
var smtpTransport = nodemailer.createTransport({
host: config.host,
port: config.port,
auth: {
user: config.email,
pass: config.password
}
});
//Message
var message = {
from: "[email protected]",
replyTo: "[email protected]",
to: "[email protected]",
subject: "hello"
};
console.log('Sending Mail');
// Send mail
smtpTransport.sendMail(message, function(error, info) {
if (error) {
console.log(error);
} else {
console.log('Message sent successfully!');
console.log('Server responded with "%s"', info.response);
}
console.log('Closing Transport');
smtpTransport.close();
});
我也有使用SMTP服務器本地SMTP服務器:
var SMTPServer = require('smtp-server').SMTPServer;
var server = new SMTPServer({
onData: function(stream, session, callback) {
console.log('received');
}
});
server.listen(465);
console.log('listening');
我不當我將電子郵件發送到本地主機smtp服務器(請注意:客戶端代碼中的「me @ localhost」)時,不會看到「收到」。
我錯過了什麼使它工作?
你有沒有想過這個想法? –
@NicholasKreidberg還沒有,但它在我的待辦事項列表中。 –