How to find out if php mail failed

I am sending letters from php mail (): and I want to receive an error message if the sending failed destinatio.

$to = 'itsdfdsf@7sisters.in';
    $email_from = "info@7sisters.in";

    $full_name = 'XXXX';
    $from_mail = $full_name.'<'.$email_from.'>';



    $subject = "testing sender name";
    $message = "";
    $message .= '
            <p><strong>This is only a test mail. Please do not reply.</strong><br />
    ';
    $from = $from_mail;

    //$headers = "" .
    //         "Reply-To:" . $from . "\r\n" .
    //         "X-Mailer: PHP/" . phpversion();

    $headers = "From:" . $from_mail . "\r\n" .
               "Reply-To:" . $from_mail . "\r\n" .
               "X-Mailer: PHP/" . phpversion();


    $headers .= 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";        

    if(!mail($to,$subject,$message,$headers))
    {
        echo 'failed !!';
    }

But although the mail $todoes not exist, it does not showfailed !!

+5
source share
7 answers

I think you want to verify the authentic email address, not just a valid formatted email. So I suggest you take a look at this blog

+3
source

. (, ..), . , "" , - ..

+5

mail

TRUE, , FALSE .

, , , , .

, true, , , , , ...

$to , , , , mail(), , , .

- UPDATE

@SeRPRo, , , - - , , , , SMTP-, (: ). , ( ) , , .

+3

$to mail , !!

, SMTP-, , ​​ . PHP , .

+1

CC , .

0

"-f", $_ mail().

mail($to, $subject, $message, $headers, "-f address.where.i.want.the.bounces@xy.com");

... http://www.php.net/manual/en/function.mail.php -inviroments (, , , "From:" heade... ..)

, , ( - , ) Domainfactory http://www.df.eu

0

Use phpmailer to send email and set $ mail-> AddCustomHeader ('Return-path: bounce@mail.com '); This will send a bounce message to bounce@mail.com if the recipient's mail identifier does not exist, or the recipient does not receive the email in any other way.

0
source

All Articles