I am trying to send emails using nodemailer. Email is hosted on hostinger. Here is my configuration:
host: "smtp.hostinger",
port: 465,
secure: true,
auth: {
user: process.env.GRIEVANCE_EMAIL,
pass: process.env.GRIEVANCE_EMAIL_PASSWORD,
},
But every time I encounter this error:
Error occurred while sending the email: Invalid login: 535 5.7.8 Error: authentication failed:
user and pass is correct as i log into hostinger webmail with the same credentials. I tried setting secure: false
, adding tls: {rejectUnauthorized: false}
but nothing works. I have to deploy the project in 2 days, event ChatGPT can't help me.
I am trying to send emails using nodemailer. Email is hosted on hostinger. Here is my configuration:
host: "smtp.hostinger.",
port: 465,
secure: true,
auth: {
user: process.env.GRIEVANCE_EMAIL,
pass: process.env.GRIEVANCE_EMAIL_PASSWORD,
},
But every time I encounter this error:
Error occurred while sending the email: Invalid login: 535 5.7.8 Error: authentication failed:
user and pass is correct as i log into hostinger webmail with the same credentials. I tried setting secure: false
, adding tls: {rejectUnauthorized: false}
but nothing works. I have to deploy the project in 2 days, event ChatGPT can't help me.
- have you checked the settings of the host? For example I had a similar problem using G-Mail. If you use a G-Mail account you have to allow 3rd party apps to login with the credentials in the account settings. – db3000 Commented Jun 22, 2023 at 13:24
3 Answers
Reset to default 2Your configuration is only missing the correct host name. Hostinger uses titan rather than hosting webmails itself. Should look like the following:
host: "smtp.titan.email",
port: 465,
secure: true,
auth: {
user: process.env.GRIEVANCE_EMAIL,
pass: process.env.GRIEVANCE_EMAIL_PASSWORD,
},
The problem got solved using this configuration:
host: "smpt.hostinger.",
secure: true,
secureConnection: false,
tls: {
ciphers: "SSLv3",
},
requireTLS: true,
port: 465,
debug: true,
connectionTimeout: 10000,
auth: {
user: process.env.GRIEVANCE_EMAIL,
pass: process.env.GRIEVANCE_EMAIL_PASSWORD,
},
it should work, but make sure to pass the mail option from the same hostinger email: export const mailOptions: nodemailer.SendMailOptions = { from: process.env.GRIEVANCE_EMAIL, to: whatever, subject: 'test', text: 'test', html: 'test' };