How to check whether mail sent successfully or not in PHP?

Use the following code to check the sent status of php mail function.

<?php
$to = "xyz@somedomain.com";
$subject = "This is subject";

$message = "This is HTML message.";
$message .= "This is headline.";

$header = "From:abc@somedomain.com \r\n";
$header .= "Cc:afgh@somedomain.com \r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html\r\n";

$retval = mail ($to,$subject,$message,$header);

if( $retval == true ) {
    echo "Message sent successfully...";
}else {
    echo "Message could not be sent...";
}
?>

Comments

Popular posts from this blog

About 12 Alwars

Post thumbnails from external URLs don’t appear in Blogger. How to resolve?