I'm using nodemailer to send email validations with no success, I get no errors when sending the e-mail, it actually says the e-mail was sent but I recieve nothing.
I tried sending e-mails using this e-mail (with gmail integration) and it works fine.
This is my config
import Mailer from "nodemailer";
async function sendEmail(emailData) {
const SMTP = process.env.EMAIL_SMTP;
const SENDER = Mailer.createTransport({
host: SMTP,
port: 465,
secure: true,
auth: {
user: process.env.EMAIL_SENDER,
pass: process.env.EMAIL_SENDER_PASSWORD
},
tls: {
ignoreTLS: true
}
});
const RECEIVER = {
from: process.env.EMAIL_SENDER,
to: emailData.to,
subject: emailData.subject,
text: emailData.text,
};
SENDER.sendMail(RECEIVER, function (error) {
if (error) {
console.log(error);
} else {
console.log("E-mail sent"); // E-mail sent is fired at console
}
});
await SENDER.verify(function (err, success) {
console.log({ err, success }); // {err: null, success: true}
})
}
I'm trying to send this using local env, does this work locally or the SMTP should match my domain?
Related
I am trying to send emails to using nodemailer from my site but it gives me this error
Error: Invalid login: 535-5.7.8 Username and Password not accepted.
and I made sure the password and credentials is accurate. This is my code for setting up nodemailer
function message(merchantEmail, msgTxt){
var transporter = nodemailer.createTransport({
host: "smtp.gmail.com",
secure: true,
port: 465,
auth: {
user: 'kesterdaniel401#gmail.com',
pass: process.env.PASSWORD
},
tls: {
rejectUnauthorized: false
}
});
var mailOptions = {
from: 'kesterdaniel401#gmail.com',
to: merchantEmail,
subject: 'Sending Email using Node.js',
text: msgTxt
};
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});
}
module.exports = message
This is where I called the function
message(productOwner.Email, `You have received an order from ${Buyer.Name} for the product ${product. ProductName}. Please contact the customer as soon as possible. Customer Number is ${Buyer.PhoneNumber}.`)
I gonna to create SMTP Server to send, receiving E-mails, using nodemailer
I have a custom domain from namecheap to do this
tried use this code but i don't receive any email on my Gmail account
const nodemailer = require('nodemailer');
const { SMTPServer } = require("smtp-server")
const server = new SMTPServer({
onData(stream, session, callback) {
console.log('test')
},
disabledCommands: ['AUTH'],
secure: false
});
server.listen(25)
const transporter = nodemailer.createTransport({
host: '192.168.1.2',
port: 25,
secure: false,
auth: {
user: '',
pass: ''
},
tls: {
rejectUnauthorized: false
}
});
transporter.sendMail({ from: "support#myDomain.com", to: "myGmail#gmail.com", text: "text", subject: "subject" })
.then(info => {
console.log(info)
}).catch(err => {
console.log(err)
})
log error:
test
Error: Message failed: 421 Timeout - closing connection
There any method to create smtp server using node js for send, receiving E-mails?
Nodemailer is sending emails as a thread if the email has the same subject as a previously sent email. But I want to send the emails as separate emails, even if they have the same subject as each other.
I have an application that sends notification emails to users. The emails all have the same subject: notification. This is causing the emails to show as a thread, at least in Gmail:
How can I make each notification email send separately?
const nodemailer = require('nodemailer');
const logger = require('./logger');
class Email {
constructor(email, to, pass) {
this.user = email;
this.to = to;
this.pass = pass;
}
get mailOptions() {
return {
from: this.user,
to: this.to,
subject: 'notification',
html: 'You received a new purchase in your shop.',
};
}
get transporter() {
const transporter = nodemailer.createTransport({
// for zoho emails
host: 'smtp.zoho.com',
port: 587,
secure: false,
auth: {
user: this.user,
pass: this.pass,
},
});
return transporter;
}
send(cb) {
this.transporter.sendMail(
this.mailOptions,
cb ||
((error, info) => {
if (error) console.log(error);
if (info) logger.log('silly', `message sent: ${info.messageId}`);
this.transporter.close();
})
);
}
sendSync() {
return new Promise((res, rej) =>
this.transporter.sendMail(this.mailOptions, (error, info) => {
if (error) rej(error);
else res(info);
this.transporter.close();
})
);
}
}
const email = new Email(
'somesendingemail#gmail.com',
'somereceivingemail#gmail.com',
'SendINgEmAIlPassWoRD'
);
email.send();
I am using nodemailer to send email using nodejs. Here is my code
export function createOrder(req, res) {
var transporter = nodemailer.createTransport({
service: 'gmail',
secure: false,
port: 25,
auth: {
user: 'fahadsubzwari924#gmail.com',
pass: 'Jumpshare1'
},
tls: {
rejectUnauthorized: false
}
});
var mailOptions = {
from: 'Fahad <fahadsubzwari924#gmail.com>',
to: 'shan4usmani#hotmail.com',
subject: 'Order Status ',
text: 'Your order has finished'
}
transporter.sendMail(mailOptions, function (err, res) {
if (res) {
console.log(res);
res.json({
message: res,
status: 200
})
} else {
console.log(err, 'Error');
}
})
}
When i am trying to send email then email is sending successfully but request is going on pending for a long time which is shown in network section of chrome.
How can i get rid of this request pending issue?
I am trying to implement Nodemailer for sending one or bulk emails but facing trouble to handle when there is a failure in sending email for eg. Email Address not found. I need a list of these bounced emails and other such failures and insert them into the DB,after trying to send the email twice.
Below is my code:
const nodemailer = require("nodemailer");
var smtpConfig = nodemailer.createTransport(
{
host: hostname,
port: port,
secure: false,
auth: {
user: username,
pass: password
},
logger: false,
debug: false
},
{
headers: [],
priority: "normal"
}
);
function sendMailnew() {
const mailOptions = {
from: "email.com,
to: "sjdhf#jhdf.com",
subject: "my testing emails new",
html: "my testing email",
dsn: {
id: "123",
return: "HEADERS",
notify: ["failure", "delay"],
recipient: "abc#gmail.com"
}
};
smtpConfig.sendMail(mailOptions, function(error, response) {
if (error) {
console.log(error);
} else {
console.log("mail sent");
}
});
}
sendMailnew();
I am using gmail SMTP. Please Help.Thanks!Let me know if any more details are needed.