emailjs
emailjs copied to clipboard
SMTPClient stuck on same error message
Hello,
I have a fairly standard use case of sending emails using some form data I collect on a website that I code. Everything worked fine and expected until I chose a non existing mail address as recipient. Then I got this error:
SMTPError: bad response on command 'RCPT': 5.1.0 host MYMAILPROVIDER.TLD [ITS-IP-ADDRESS] said: <[email protected]>: Sender address rejected: User unknown (H-BADRCPT). So far also not unexpected behaviour, as the mail [email protected] does not actually exist and I am not wondering that my mail provider will throw and error.
Now, this error does no go away anymore and seems to be stuck in the SMTPClient and prevents further mails to be sent. Whenever I enter a mail by the same mail provider (something with @MYMAILPROVIDER.TLD) into to or cc, I will be presented the old error message.
My setup: node. 16.3.0 emailjs: 4.0.0
import { SMTPClient } from 'emailjs';
const client = new SMTPClient({
user: 'user',
password: 'pass',
host: 'smtp.address.tld',
ssl: true,
});
Full repeating error
SMTPError: bad response on command 'RCPT': 5.1.0 host MYMAILPROVIDER.TLD [ITS-IP-ADDRESS] said: <[email protected]>: Sender address rejected: User unknown (H-BADRCPT)
at Function.create (file:///C:/Users/path/to/my/project/node_modules/emailjs/email.js:1073:21)
at response (file:///C:/Users/path/to/my/project/node_modules/emailjs/email.js:1422:48)
at caller (file:///C:/Users/path/to/my/project/node_modules/emailjs/email.js:1188:9)
at TLSSocket.<anonymous> (file:///C:/Users/path/to/my/project/node_modules/emailjs/email.js:1377:21)
at Object.onceWrapper (node:events:514:26)
at TLSSocket.emit (node:events:394:28)
at notify (file:///C:/Users/path/to/my/project/node_modules/emailjs/email.js:1101:24)
at TLSSocket.watch (file:///C:/Users/path/to/my/project/node_modules/emailjs/email.js:1115:17)
at TLSSocket.emit (node:events:394:28)
at addChunk (node:internal/streams/readable:312:12) {
code: 2,
smtp: '550 5.1.0 host MYMAILPROVIDER.TLD [ITS-IP-ADDRESS] said: <[email protected]>: Sender address rejected: User unknown (H-BADRCPT)\n',
previous: null
}
Example mail that does not work
// send the message and get a callback with an error or details of the message that was sent
client.send(
{
text: 'Message is cool',
from: 'somemail <[email protected]>',
to: 'test <[email protected]>',
cc: 'test2 <[email protected]>',
subject: 'New Request from ' + req.body.name,
attachment: [
{ data: '<html>' + mailText + '</html>', alternative: true },
],
},
(error, message) => {
console.log(error || message);
}
);
When I use other addresses in to or cc, I am able to send mail successfully. But not when I use the old one.
Is there some way to prevent this behaviour? Thanks a lot!
After restarting my computer, this error seems to have left the (mail or error) queue and finally does not prevent any mails to be sent to that mail addresses of that mail provider.
However, I am still interested to solving that problem, as I process form data with a field of a mail address. Users could send wrong mail addresses, which would lead to the same thing happening again, the SMTPClient being stuck on that error message.
Also, I thought that this issue could maybe be related to 315, as they seem to have a similar issue, although different environment.
Validate addresses by looking up the MX of the domain, connect and send a RCPT TO: and check the response.
Response is Recipient ok or User unknown