Home » Php » email – Problem sending mail in php with http_response_code other than 200

email – Problem sending mail in php with http_response_code other than 200

Posted by: admin February 25, 2020 Leave a comment

Questions:

I have a problem with sending mail in PHP when I add the line “http_response_code (503)“. The email is sent in 3 copies while if I remove the line, I have no problem, the email is sent only once. I have the same problem with PHPMailer.
Here is my code:

$message = 'test fg';
$to      = '[email protected]';
$subject = ' TEST - ' .md5(rand());            
$headers = array(
    'From' => '[email protected]',
    'Reply-to' => '[email protected]',
    'Content-type' => 'text; charset=UTF-8'
);

mail($to, $subject, $message, $headers);

http_response_code(503);

Thank you in advance for your help.

How to&Answers: