Currently im using sendgrid using nodejs library “('nodemailer')” TransporterOption:
config:
transporterOption: {
host: process.env.SMTP_HOST, // smtp.sendgrid.net
pool: true,
maxConnections: 20,
rateDelta: 1000,
rateLimit: 150,
auth: {
user: process.env.USER_NAME,
pass: process.env.PASSWORD
}
},
sending code :
const config = require('./config');
const nodeMailer = require('nodemailer');
const htmlToText = require('nodemailer-html-to-text').htmlToText;
const transporter = nodeMailer.createTransport(config.transporterOption);
transporter.use('compile', htmlToText());
try {
let mailOptions = {
headers: { 'X-SMTPAPI': `{"category":["${myid}"]}` },
from: `"myname" <${toemail}>`,
replyTo: `"myname" <${toemail}>`,
to: `"name" <${emailAdr}>`,
subject: mysubject,
text: mytextbody,
html: myhtmlbodymsg
}
} catch (e) {
console.log(e);
}
Working FINE with no issues.
migrating from username/password to API key when passing api_key in response getting this error "Mail command failed: 550 Unauthenticated senders not allowed”
option 1:
transporterOption: {
host: process.env.SMTP_HOST, // smtp.sendgrid.net
pool: true,
maxConnections: 20,
rateDelta: 1000,
rateLimit: 150,
auth: {
api_key: process.env.SENDGRID_API_KEY // fakeKEY.kashdkjhjkdhsakjdhksajhd
}
},
"err":{"message":"Missing credentials for "PLAIN"","name":"Error","stack":"Error: Missing credentials for "PLAIN"\n
Option 2 :
transporterOption: {
host: process.env.SMTP_HOST, // smtp.sendgrid.net
pool: true,
maxConnections: 20,
rateDelta: 1000,
rateLimit: 150,
auth: {
Username: process.env.USER_NAME, //’apikey’
Password: process.env.SENDGRID_API_KEY // fakekeyssssjhkjsahdkjsahdkjhsa
}
},
Error : “{"message":"Mail command failed: 550 Unauthenticated senders not allowed","name":"Error","stack":"Error: Mail command failed: 550 Unauthenticated senders not allowed\n”
Option 3 :
transporterOption: {
host: process.env.SMTP_HOST, // smtp.sendgrid.net
pool: true,
maxConnections: 20,
rateDelta: 1000,
rateLimit: 150,
auth: {
api_user: 'apikey',
api_key: process.env.SENDGRID_API_KEY // fakekeyssssjhkjsahdkjsahdkjhsa
}
},
Error : “{"message":"Mail command failed: 550 Unauthenticated senders not allowed","name":"Error","stack":"Error: Mail command failed: 550 Unauthenticated senders not allowed\n”