mail() function is not working in cakephp 2

73 Views Asked by At

I am using mail() function in cakephp 2 to send the mail in the server. The mail is not delivered.

PHP - 5.6

Code:

$headers = 'MIME-Version: 1.0' . "\r\n";
 $headers.= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
$headers.= "From: " . $from . "\n"; 
$mail = mail($to, $subject, $message, $headers); 
 echo 'Mailer error: ' . $mail->ErrorInfo;

phpinfo screenshot below: enter image description here

There is no error message is showing. The mail sending status is true. but mail is not receiving.

1

There are 1 best solutions below

1
Rouissi Iheb On

if you are on your local machine , it won't work until you configure your local mail server. Most cpanels support php mail() function , but you need manual configuration for sendmail on your local machine / LAMP stack / vps server.