Search code examples
phpphpmailer

How to create PHPMailer mx blacklist


I send email via php script + phpmailer

I want to make blacklist mx records check in phpmailer. For example,

If email info@mail.com has in mx record domain company.com or company1.com - my script shouldn't send email to this info@mail.com

I need only mx check before sending email, not domain check in info@mail.com

Is it real?


Solution

  • i dont know the details of phpmailer, but a generic algorithm is:

    $host = "gmail.com";
    $black = array("mail.anexample.com","mail.otherexample.com");
    ////////
    $mxarr = array();
    getmxrr($host, $mxarr);
    $intersect = array_intersect($mxarr, $black);
    if(!count($intersect)>0) {
        echo "ok";
        //sendmail(......);
    }