Error 535 while setting up nodemailer with GoDaddy - node.js

I'm wondering if anyone has figured out how to use GoDaddy hosted email with nodemailer. I have an email submission box from my contact form, and it triggers the following script:
function sendEmail ( to, subject, body ) {
var transporter = nodemailer.createTransport({
service: 'Godaddy',
host: "relay-hosting.secureserver.net",
port: 465,
secureConnection: true,
auth: {
user: 'email#godaddydomain.com',
pass: 'password'
}
});
var mailOptions = {
from: 'email#godaddydomain.com',
to: to,
subject: subject,
text: body
};
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});
}
I've tried a few different options, and made sure my ports are all open, but I'm having a hard time with the authentication. I keep getting errors like this:
{ Error: Invalid login: 535 Authentication Failed for email#godaddydomain.com. User does not have any relays assigned.
at SMTPConnection._formatError (/var/www/node/node_modules/nodemailer/lib/smtp-connection/index.js:577:19)
at SMTPConnection._actionAUTHComplete (/var/www/node/node_modules/nodemailer/lib/smtp-connection/index.js:1306:34)
at SMTPConnection._responseActions.push.str (/var/www/node/node_modules/nodemailer/lib/smtp-connection/index.js:349:26)
at SMTPConnection._processResponse (/var/www/node/node_modules/nodemailer/lib/smtp-connection/index.js:733:20)
at SMTPConnection._onData (/var/www/node/node_modules/nodemailer/lib/smtp-connection/index.js:529:14)
at Socket._socket.on.chunk (/var/www/node/node_modules/nodemailer/lib/smtp-connection/index.js:481:47)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at TCP.onread (net.js:547:20)
code: 'EAUTH',
response: '535 Authentication Failed for email#godaddydomain.com. User does not have any relays assigned.',
responseCode: 535,
command: 'AUTH PLAIN' }
Any thoughts or suggestions would be really appreciated.

It seems like this error is related to the hostname. Try this one:
var transporter2 = nodemailer.createTransport({
service: 'Godaddy',
host: "smtpout.secureserver.net",
secureConnection: true,
port: 465
})

I was facing the same error. I changed configuration to the following:
var transporter = nodemailer.createTransport({
host: "smtpout.secureserver.net",
secure: true,
secureConnection: false, // TLS requires secureConnection to be false
tls: {
ciphers: "SSLv3",
},
requireTLS: true,
port: 465,
debug: true,
auth: {
user: "xxxx#yyyy.com",
pass: "pass",
},
});
It worked like a charm for me.

In case anyone's still looking for this (as I have been the last few days!), I found all the server information GoDaddy was suggesting was completely wrong. Found the answer in cPanel - if you go to the main bit, and click on 'Email Accounts', on your account it should have an option on the right saying 'Connect Devices'. Click on that and it'll give you the correct server and port information for what you need, which for me ended up being this:
var transporter = nodemailer.createTransport({
host: "sxb1plzcpnl487525.prod.sxb1.secureserver.net",
secure: true,
secureConnection: true,
port: 465,
auth: {user: "yourcpanelusername#yourdomain.com", pass: "yourcpanelpassword"},
tls: {rejectUnauthorized: false}
});
Took me forever to find that specific weird server it needed. Hope this helps. Apologies for formatting, it's my first post here but I wanted to help as I've spent days on this now.

Related

Node.js nodemailer error - wrong version number/invalid greeting

I have a big problem with setting up the nodemailer on my node.js server. Tried everthing I found on the internet but nothing works. The only thing that was easy to setup was the gmail service. but unfortunately I cannot use that one.
With secure set to true, i get an ssl error with the reason wrong version code.
[Error: 22468:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:332:
] {
library: 'SSL routines',
function: 'ssl3_get_record',
reason: 'wrong version number',
code: 'ESOCKET',
command: 'CONN'
}
But when I try to set secure to false, then I get an invalid greeting error.
Error: Invalid greeting. response=* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA ACL ACL2=UNION STARTTLS] Courier-IMAP ready. Copyright 1998-2016 Double Precision, Inc. See COPYING for distribution information.: * OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA ACL ACL2=UNION STARTTLS] Courier-IMAP ready. Copyright 1998-2016 Double Precision, Inc. See COPYING for distribution information.
at SMTPConnection._actionGreeting (C:\Users\Motiondata\Documents\repos\rmn_app\server\rmn_server\node_modules\nodemailer\lib\smtp-connection\index.js:1189:27)
at SMTPConnection._processResponse (C:\Users\Motiondata\Documents\repos\rmn_app\server\rmn_server\node_modules\nodemailer\lib\smtp-connection\index.js:932:20)
at SMTPConnection._onData (C:\Users\Motiondata\Documents\repos\rmn_app\server\rmn_server\node_modules\nodemailer\lib\smtp-connection\index.js:739:14)
at Socket.SMTPConnection._onSocketData (C:\Users\Motiondata\Documents\repos\rmn_app\server\rmn_server\node_modules\nodemailer\lib\smtp-connection\index.js:189:44)
at Socket.emit (events.js:315:20)
at addChunk (_stream_readable.js:309:12)
at readableAddChunk (_stream_readable.js:284:9)
at Socket.Readable.push (_stream_readable.js:223:10)
at TCP.onStreamRead (internal/stream_base_commons.js:188:23) {
code: 'EPROTOCOL',
response: '* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA ACL ACL2=UNION STARTTLS] Courier-IMAP ready. Copyright 1998-2016 Double Precision, Inc. See COPYING for distribution information.',
command: 'CONN'
}
My code is the following:
const transporter = nodemailer.createTransport({
host: process.env.MAIL_HOST, // mx.example.com
port: process.env.MAIL_PORT, // 143
secure: true,
auth: {
user: process.env.MAIL_ADDRESS,
pass: process.env.MAIL_PWD
}
})
I checked the credentials a thousand time, they are definetly not the problem.
Hope anyone can help me.
Thanks in advance.
Refering to this issue mentioned here: https://github.com/andris9/Nodemailer/issues/165
See if this helps, adding the tls.ciphers option to use SSLv3:
const transport = nodemailer.createTransport({
host: process.env.MAIL_HOST, // mx.example.com
port: process.env.MAIL_PORT, // 143
secureConnection: false, // TLS requires secureConnection to be false
auth: {
user: process.env.MAIL_ADDRESS,
pass: process.env.MAIL_PWD
},
tls: {
ciphers:'SSLv3'
}
});
For Outlook365, this should work:
service: "Outlook365",
auth: {
user: '[YOUR_O365_EMAIL]',
pass: '[YOUR_O365_PASSWORD]'
},
Refer here: https://stackoverflow.com/a/37725123/9360885
If you're using HotMail, then remove host and port, and just add service: "hotmail".
use
secure: false, // true for 465, false for other ports
Example from nodemailer docs:
let transporter = nodemailer.createTransport({
host: 'smtp.ethereal.email',
port: 587,
secure: false, // true for 465, false for other ports
auth: {
user: account.user, // generated ethereal user
pass: account.pass // generated ethereal password
}
});
source: nodemailer examples
I used port 465 with Gmail and that worked. Got the "wrong version number" error with 587. Example below is for a GCP service account in a Cloud Function.
const transporter = nodemailer.createTransport({
host: "smtp.gmail.com",
port: 465,
secure: true,
auth: {
type: "OAuth2",
user: process.env.GMAIL_ADDRESS,
serviceClient: process.env.CLIENT_ID,
privateKey: process.env.PRIVATE_KEY.replace(/\\n/g, "\n"),
},
});
I also ran in this problem. But I managed to fix it.
It's quite simple to solve.
Solution:
port: process.env.MAIL_PORT * 1
This will change your process.env.MAIL_PORT type from a string to integer.
Why there was an error?
NodeMail require a port with a type of integer, but you were passing a string. So that caused an error.
If you are still receiving the issue, fix by inputting this into your browser manually while logged in.
https://accounts.google.com/DisplayUnlockCaptcha
change smtp port 587 to 465
smtp:{
name:"noreply#gmail.com",
host:process.env.SMTP_HOST,
secure: true,//true
port: 465,//465
auth: {
user: process.env.SMTP_USER,
pass: process.env.SMTP_PASSWORD,
}, // here it goes
},

Nodemailer works on local but not on production

I put my application online and tried my contact form but the nodemailer is not working due to a smtp connection timeout.
Here is my transport
let transporter = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: 465,
secure: true,
auth: {
user: process.env.MAIL_USERNAME, //
pass: process.env.MAIL_PASSWORD // Google app password
},
tls: {
rejectUnauthorized: process.env.APP_ENV == 'local' ? false : true // which is true but also tried false
}
});
and my sendmail function
let info = await transporter.sendMail({
from: `"${data.firstname} ${data.lastname}" <${data.email}>`,
to: process.env.MAIL_TO_DESTINATION, // list of receivers
subject: data.subject,
html: `<p><strong>Fullname:</strong> ${data.firstname} ${data.lastname}</p>
<p><strong>Email:</strong> ${data.email}</p>
<p><strong>Subject:</strong> ${data.subject}</p>
<p><strong>Message:</strong> ${data.message}</p>`
});
Error
(node:3743) UnhandledPromiseRejectionWarning: Error: Connection timeout
at SMTPConnection._formatError (/home/clients/974a427295deac388e59a945b2c70917/portfolio-mytdragon/node_modules/nodemailer/lib/smtp-connection/index.js:784:19)
at SMTPConnection._onError (/home/clients/974a427295deac388e59a945b2c70917/portfolio-mytdragon/node_modules/nodemailer/lib/smtp-connection/index.js:770:20)
at Timeout._connectionTimeout.setTimeout (/home/clients/974a427295deac388e59a945b2c70917/portfolio-mytdragon/node_modules/nodemailer/lib/smtp-connection/index.js:235:22)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)
I don't know what is wrong since it works locally. Anyone know why?
Thanks.
I found out how to solve it. The problem wasn't from my script but from the host. I had to open manually the 465 tcp exit port.

Nodemailer send mail using gmail account showing response code 534-5.7.14

// create reusable transporter object using the default SMTP transport
transporter = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: 465,
secure: true,
auth: {
user: 'yourEmail',
pass: 'yourPassword'
}
});
{ [Error: Invalid login] code: 'EAUTH', response: '534-5.7.14
Please log in via your web browser and\n534-5.7.14 then try
again.\n534-5.7.14 Learn more at n534 5.7.14
https://support.google.com/mail/answer/78754 77sm13524842wml.20 - g
smtp', responseCode: 534 }
You may need to "Allow Less Secure Apps" in your Gmail account (it's all the way at the bottom). You also may need to "Allow access to your Google account".
var transporter = nodemailer.createTransport(smtpTransport({
host: config.email_config.SMTP_HOST,
port: config.email_config.SMTP_PORT,
tls: {
rejectUnauthorized: false
},
auth: {
user: config.email_config.SMTP_AUTH_USER,
pass: config.email_config.SMTP_AUTH_PASS
}
}));
use like thiss....

Timeout error on using nodemailer with cpanel custom email

I have created a custom email in my cpanel dashboard, so I can be sending emails with my domain name. I was using google before with nodemailer it works out well, but now trying to do it with my domain host all i get is connection timeout, i don't really know where the problem is from, but my mail host is up and running.
this question may have similar duplicates but i have gone through them but no help..
my records for the host, I don't know if the TTL and record type is causing it
TTL: 14400
record-type : CNAME
var smtpTransport = nodemailer.createTransport({
host: 'mail.mydomain.com',
port: 465,
secure: true,
auth: {
user: 'me#mydomain.com',
pass: process.env.Password
}
});
var mailOptions = {
to: somebody#gmail.com,
from: 'me#mydomain.com',
subject: 'welcome',
html: '<p>Hello this is a notification </p>',
};
smtpTransport.sendMail(mailOptions, function(err, sent){
if(err){
console.log(err)
} else {
console.log('message sent')
}
});
{ Error: Connection timeout
at SMTPConnection._formatError (/home/ubuntu/workspace/bitcoin.1/main/node_modules/nodemailer/lib/smtp-connection/index.js:591:19)
at SMTPConnection._onError (/home/ubuntu/workspace/bitcoin.1/main/node_modules/nodemailer/lib/smtp-connection/index.js:564:20)
at Timeout._connectionTimeout.setTimeout (/home/ubuntu/workspace/bitcoin.1/main/node_modules/nodemailer/lib/smtp-connection/index.js:256:18)
at ontimeout (timers.js:386:11)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5) code: 'ETIMEDOUT', command: 'CONN' }
Any help is highly appreciated :)

nodemailer and zoho email issue '530 Must issue a STARTTLS command first.'

I am using the latest version of nodemailer version 4.1.0. I tried using the sample code available here
https://nodemailer.com/smtp/
Here is my code
let transporter = nodemailer.createTransport({
host: 'smtp.zoho.com',
port:587,
secure: false,
auth: {
user: this.user,
pass: this.password
}
});
var mailOptions: nodemailer.SendMailOptions = {
from: ****#***.com,
to: test#abc.com,
subject: 'Hello ✔',
text: 'Hello world ✔',
html: '<b>Hello world ✔</b>'
};
transporter
.sendMail(mailOptions)
.then(
(info) => {
// console.log(info);
resolve({status: info.messageId})
}
)
.catch(err => {
// console.log(err);
reject({status: err.toString()})
})
I get the following error. I have set the secure flag as false, and have also used ignodeTLS. The previous version of nodemailer 0.7.1 did not have any issues. Am I missing out on any specific configuration?
{ Error: Invalid login: 530 Must issue a STARTTLS command first.
at SMTPConnection._formatError
(C:\Project\NotificationService\node_modules\nodemailer\lib\smtp-connection\index.js:577:19)
at SMTPConnection._actionAUTHComplete (C:\Project\NotificationService\node_modules\nodemailer\lib\smtp-connection\index.js:1306:34)
at SMTPConnection._responseActions.push.str (C:\Project\NotificationService\node_modules\nodemailer\lib\smtp-connection\index.js:349:26)
at SMTPConnection._processResponse (C:\Project\NotificationService\node_modules\nodemailer\lib\smtp-connection\index.js:733:20)
at SMTPConnection._onData (C:\Project\NotificationService\node_modules\nodemailer\lib\smtp-connection\index.js:529:14)
at Socket._socket.on.chunk (C:\Project\NotificationService\node_modules\nodemailer\lib\smtp-connection\index.js:481:47)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at TCP.onread (net.js:548:20)
code: 'EAUTH',
response: '530 Must issue a STARTTLS command first.',
responseCode: 530,
command: 'AUTH PLAIN' }
you can also use this without these tls parameter default value is false.
you got the error because of you don't pass service:'zoho' in nodemailer
let transporter = nodemailer.createTransport({
service:'Zoho',
host: this.service,
port:587,
secure: false,
auth: {
user: this.user,
pass: this.password
}
});
After going through the typings( "#types/nodemailer") file I added the following flags
1) service :'Zoho'
2) requireTLS :false
it is working now :)
let transporter = nodemailer.createTransport({
service:'Zoho',
host: this.service,
port:587,
secure: false,
ignoreTLS:true,
requireTLS:false,
auth: {
user: this.user,
pass: this.password
}
});
In the year 2022, I got this on the official documentation https://nodemailer.com/smtp/well-known/
let transporter = nodemailer.createTransport({
service: 'SendPulse', // no need to set host or port etc.
auth: {
user: 'account.email#example.com',
pass: 'smtp-password'
}
});
transporter.sendMail(...)
So, for Zoho just simply:
let transporter = nodemailer.createTransport({
service: 'Zoho', // no need to set host or port etc.
auth: {
user: 'account.email#example.com',
pass: 'smtp-password'
}
});
transporter.sendMail(...)
Just test it and works. I believe it doesn't need to put any setting if we use "Well-known services"
Hope this helps someone drop by in this thread :).

Resources