i' m using node-mailer for registration mail notification.
but there are some issuses sending mail for invalid email type or wrong email adresses.
how can i catch this state?
When sending emails, the callback gets 2 arguments and the first one is an Error object if sending failed.
@andris9 , first one is invalid email address [email protected] and send result
and second one is valid email address [email protected] and result
both are the same result. so i can not filter sending failure mail address.
error(first argument) is null both
========================================================================
null { accepted: [ '[email protected]' ],
rejected: [],
response: '250 2.0.0 OK 1428585848 je11sm14359925pbd.65 - gsmtp',
envelope: { from: '[email protected]', to: [ '[email protected]' ] },
messageId: '[email protected]' }
========================================================================
null { accepted: [ '[email protected]' ],
rejected: [],
response: '250 2.0.0 OK 1428585888 a2sm690264pdg.70 - gsmtp',
envelope:
{ from: '[email protected]',
to: [ '[email protected]' ] },
messageId: '[email protected]' }
Everything is correct in this case. There is no errors because the relay does not know yet that the e-mail address is not valid. Thats what the "bounce" messages are for 鈥撀爄f the last SMTP server in the sending chain can't deliver the message then the message is bounced back to the original sender. Nodemailer passes the message to the relay and thats all Nodemailer can do, from this point onwards it is not Nodemailers responsibility to handle the message. Thats how SMTP works.
@andris9 good answer thanks! :)
but there should a way to do that ?
how can we get bounce back email using nodemailer ?
or how can we get status code if the smtp server failed to deliver the mail ??
Most helpful comment
Everything is correct in this case. There is no errors because the relay does not know yet that the e-mail address is not valid. Thats what the "bounce" messages are for 鈥撀爄f the last SMTP server in the sending chain can't deliver the message then the message is bounced back to the original sender. Nodemailer passes the message to the relay and thats all Nodemailer can do, from this point onwards it is not Nodemailers responsibility to handle the message. Thats how SMTP works.