How to capture bad email addresses in mass mail.

We have huge project with a great number of registered users. They receive notification via email, when actions occur. (new comment, gift, some other activity). Project targeting – Russia and former USSR In Russia some free email hosting providers like mail.ru delete user account after 2-3 years of inactivity.
So we have now 2-3000000 users with bad email address.
How to find them and remove from mailing list:

According to RFC 5321 (smtp rfc) in case of wrong email in rcpt to, server should return 550 no such user.

RCPT TO: [ SP  ] 

If the recipient is known not to be a deliverable address, the SMTP server
returns a 550 reply, typically with a string such as "no such user -
"and the mailbox name (other circumstances and reply codes are possible).

But, almost all servers accept email to queue, then reply with 550.
So we need capture and parse emails to reply address.
I just store them to separate folder and parse using:

find /home/mail/noreply/new/ -type f -exec grep 'invalid mailbox' {} \;
> /root/bad-email.txt ;
 cat /root/bad-email.txt | sort | uniq > /root/bad-email-uniq.txt

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>