Wednesday, February 26, 2020

PHP Sendmail() method delivers mail after 5 minutes - How to Fix?

Problem:

Use sendmail() method to send mail to the registered user. Email sends when user registered but it takes 5 minutes to send the mail every time.

Solution:

Try using normal php mail() function to check if its server issue

<?php
$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>

if mail get sent fast then server is working fine.

No comments:

Post a Comment