Unable to send SMTP mails using office365 settings
Solution 1:
Outlook doesn't provide to send using different from address other than your username to log in.
You need both email address same.
You can add one or more sender in your admin panel after that you can send easily from different addresses.
Solution 2:
This error means the user whose credentials you specified in the SMTP connection cannot submit messages on behalf of the user specified in the From
and/or Sender
MIME headers or the FROM
SMTP command.
Solution 3:
I face the similar issue and i resolved it right now, you are most likely facing this issue because your "user" email in the auth option and the "from" email at the mail option are different
make the user and from email same and it will work for you
const transporter = nodemailer.createTransport({
service: 'outlook',
port: 587,
auth: {
user: '[email protected]',
pass: '******'
},
tls: {
rejectUnauthorized: false
}
});
// setup email data with unicode symbols
let mailOptions = {
from: "[email protected]", // sender address
to: '[email protected]', // list of receivers
subject: 'Node Contact Request', // Subject line
text: 'Hello world?', // plain text body
html: output // html body
};
// send mail with defined transport object
transporter.sendMail(mailOptions, (error, info) => {
console.log(info);
if (error) {
return console.log(error);
}
console.log('Message sent: %s', info.messageId);
console.log('Preview URL: %s', nodemailer.getTestMessageUrl(info));
});
If your email is not verified you will likely to get more errors
Solution 4:
After trying for 4 days, mails started to triggered with port:25, so instead of trying with 587 or 465. Try with other port numbers.
host: "smtp.office***.*", port:25, secureConnection: false, requireTLS: true, tls: { ciphers: 'SSLv3' }, auth: { user: *, pass: *** }