0
我使用feathersjs構建了一個API,並且需要發送附件的電子郵件。Nodemailer - 電子郵件發送但沒有收到
該電子郵件似乎是發送,但我什麼都沒收到。
在我mail.service.js
const nodemailer = require('nodemailer');
const transporter = nodemailer.createTransport({
host: 'smtp.office365.com',
port: 587,
secure: false, // secure:true for port 465, secure:false for port 587
auth: {
user: '[email protected]',
pass: 'MyPassWord'
}
});
// Check the connection to the service.
transporter.verify(function(error, success) {
if (error) {
console.log(error);
} else {
console.log('Server is ready to take our messages');
}
});
然後在我的鉤
hook => {
const file = hook.params.file;
const email = {
from: '[email protected]', // sender address
to: '[email protected]', // list of receivers
subject: 'Test Nodemailer', // Subject line
// text: req.body.text, // plaintext body
html: '<b>Hello world </b>', // html body
attachments: [
{
filename: file.originalname,
contents: new Buffer(file.buffer, 'base64'),
encoding: 'base64'
}
]
};
return hook.app.service('mail').create(email)
.then(function (result) {
console.log('Sent email', result);
}).catch(err => {
console.log(err);
});
}
後來我
服務器準備採取我們的信息
發電子郵件
對象{來自: 「[email protected]」,到: 「[email protected]」,主題: 「測試Nodemailer」,HTML: 「世界,你好」}
我不知道如何檢查問題的來源。