Search code examples
node.jsemaildnssendmailtelnet

Testing a domain for a catchAll email in node js


I am trying to programatically test if a domain has a catch all email address hosted on it. I would like to know if a particular domain - ie. facebook.com - would receive an email sent to blahblah@facebook.com.

I am currently using node DNS to see if the domain first has Mx records, then I send a ping to the email, unfortunately this is very slow and I was wondering if there is a faster way of detecting this.

validateDomain: function(domain, array, i, callback) {
    var testEmail = '1qaz2wsx3edc4rfv5tgb@' + domain;
    checkEmail(testEmail, function(validation, addresses, err) {
        if (validation) {
            callback( err, false, array, i);
        } else {
            array.push(domain);
            callback( null, true, array, i);
        }
    });
}

This is how I am currently set up to validate a catchall by using a very unlikely email. The function checkEmail uses Mx records to see if the domain has email and sends a ping. This is the function I would like to replace to detect the catch all.

Thanks,


Solution

  • Catch-all email trappers aren't implemented in DNS to the best of my knowledge, they're configured at the email server level. So there's no shortcut for testing this other than checking for the validity of an email address.

    Note that you don't have to actually send an email to test. Within, say, an SMTP session the RCPT TO command returns: 200 or 250 on success, 251 or 551 on forward, 252 cannot verify but will accept, 450 or 550 mailbox unavailable, 552 exceeded storage, 553 mailbox name not allowed. Upon determining whether/not the wildcard exists you'd send a QUIT.