How to test if PHP mail() has successfully delivered mail

phpmailer
php mail sent successfully but not received
how to check php mail is working
php mail from name
php mail error reporting
php mail function not working
php mail not working
php mail not delivered

How can I test if mail() has successfully delivered mail?

Well mail() simply returns a boolean value depending on whether the mail was successfully accepted for delivery. From the php.net site:

Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.

It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination.

So you can test to see if it's been "sent", however checking if it's been delivered is another story.

How to test if PHP mail() has successfully delivered mail, How do you check mail is delivered or not in PHP? Test php mail () on your Web Server. 1. Create a php test file using a text editor and save it e.g. as test.php: 2. Change the $sender and $recipient in the code. 3. Upload the php file to your webserver. 4. Open the uploaded php file in your browser to execute the php script.

As per Ben reply you can check successfully email delivery as below

$result = mail('abc@test.com', 'Test Subject', $message);
if(!$result) {   
     echo "Error";   
} else {
    echo "Success";
}

For better result you can use PHPMailer. Click on below link for detailed documentation of PHPMailer.

http://phpmailer.worxware.com/index.php?pg=tutorial

if(!$mail->Send()) {
  echo 'Message was not sent.';
  echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
  echo 'Message has been sent.';
}

How to check if mail() PHP function is enabled in your server , How do I know if my email is sent or not? You can still run test though. Just create a testmail.php with following lines of codes: <?php mail ('[email protected]', "Test Postfix", "Test mail from postfix"); ?> and run it on your server with php -f testmail.php command. If you can’t see any email form PHP, then that means its PHP’s fault. Check value of sendmail_path in php.ini config. If its wrong, fix it and run above test again.

from the docs:

"Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.

It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination. "

Delivery and Read Receipt Confirmations in Outlook, not support SMTP authentication and doesn't allow sending messages via external servers. You can test what the mail () PHP function returns by copying this code and saving it in a new empty text file as “testmail.php“. Edit $to and $from emails. Be careful, do not delete anything outside double quotes or you will break the code. Upload testmail.php into your root FTP folder and visit it using your browser.

From http://php.net/mail

Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.

PHP - Sending Emails using PHP, When visiting testmail. php you should wait some seconds and you will see a message: “Message successfully sent” or “Message delivery failed“. If you see “Message successfully sent“, check destination address and look if the email arrives to your inbox or spam folder. You're using isMail() (which is the default anyway), so your message will be sent via your local mail server. When it reports success, it means it delivered it successfully to your local mail server, not any further. To find out what happened after that, look in your mail server log file, usually /var/log/mail.log. – Synchro Dec 3 '15 at 17:14

Try this:

if(@mail($emailRecipient, $subject, $message, $headers))
{
  echo "Mail Sent Successfully";
}else{
  echo "Mail Not Sent";
}

Sending Emails in PHP, You should search for this in the list sendmail_path that has the default value /usr​/sbin/sendmail -t -i. You can also try to manual set it to this value by changing  http://php.net/manual/en/function.mail.php. mail () returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise. It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination.

PHP check if mail() function is enabled on your server, If you have made changes (eg enabled SMTP in the PHP settings) or moved hosts, in php.ini or use ini_set() in C:\mywebsite.com\data\iq\test-email.php on line 9 "Returns TRUE if the mail was successfully accepted for delivery, FALSE​  First of all, you need to create a file for the PHP mail script and place it in the public_html directory so that it can be easily accessed through the domain name. To access the hPanel, click on the File Manager -> Go to File Manager. Create a new file by clicking on Add New. Let’s name the file testmail.php and then hit Create.

Simple PHP Mail test • Conetix, Therefore, users must make sure specified headers are safe and contains Returns TRUE if the mail was successfully accepted for delivery, FALSE When using the PHP mail() function with IIS 6 on Windows Server 2003, check your  Hi guys, I'm a bit of a novice when it comes to php. I have recently built a "Contact Us" form and I am having difficulties getting the results sent to the desired email address. According to the

mail - Manual, Creating a Test File for PHP Mail; Understanding PHP Mail Components Using PHP mail() function invokes a Sendmail program, usually configured Once you have PHPMailer ready, you can use it to send PHP mails using Hostinger SMTP. If the email is successfully sent, this message will appear. When using the PHP mail () function with IIS 6 on Windows Server 2003, check your "Relay" settings on the SMTP Virtual Server in IIS. If you grant access to 127.0.0.1 and set then set your php.ini SMTP to the same IP address (along with setting the same port 25), you should have success in sending mail.

Comments
  • there is no choice in inbulid php function to know whether receiver received mail or not, even we can not detect is it valid mail id or not
  • mail() returns true doesn't mean the email is delivered successfully. u may get back a "mail delivery failure" message from the server which receives the email (eg. no such user name) after a few minutes
  • I think that's what I said?!
  • Ben can you please text something about actual mail delivery check?
  • why it is not sending the email
  • Welcome to Stack Overflow! While this code snippet may be the solution, including an explanation really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion.
  • That's not the answer, not even the right question.