开发者

why is php mail script not sending mail

开发者 https://www.devze.com 2023-01-13 13:28 出处:网络
<?php $headers = \'MIME-Version: 1.0\' . \"\\r\\n\"; $headers .= \'Content-type: text/html; charset=iso-8859-1\' . \"\\r\\n\";
<?php 
$headers = 'MIME-Version: 1.0' . "\r\n"; 
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail("example@gmail.com", "hello", "nothing",开发者_StackOverflow中文版$headers);
echo "mail sent";
?>

but it does not actually send the mail please help me out with this


The mail function is just an interface to the local mail server. The mail functionality in PHP relies on the machine PHP is running on to be correctly configured and able to dispatch e-mail. Check the mail system configuration on the machine.


check the following -

  1. check if your smtp server is running (you could either check through command line tools or try ftp'ing to port 25).
  2. If your smtp server is running. Then try to send a mail manually (without script). Use the command-line mail command (I am assuming you have unix here).

Also, when you run your script, what happens? It could be possible that your mail is in a Queue. From your terminal type 'mailq'. This shows the current emails in Queue & why they are there. Also there is a corresponding log to this. You could also check that out for info.

My guess is if all the above are running, you are good to go.


please check following ** Please verify your servers sender domain policy**

Emails sent through your servers (mail servers and shared web servers) should use a from address that is hosted here at your server. Emails that are sent with a from address hosted somewhere else (like Hotmail or Google) may be blocked.

ie use

$header = "From:example@/*yourhostname.domain name*/ \r\n";
0

精彩评论

暂无评论...
验证码 换一张
取 消