再次抱歉这个问题。我想用PHP发送电子邮件,因为我使用了简单的mail()函数。使用sendmail.exe。改变php.ini就像
一样SMTP = localhost (tried both comment and uncomment this)
smtp_port = 25 tried(587)
sendmail_path = "D:\sendmail\sendmail.exe"
smtp_server=smtp.gmail.com
smtp_port=25
default_domain=localhost
auth_username=mygmaill@gmail.com
auth_password=*********
force_sender=mygmail@gmail.com
hostname=localhost
我的email.php代码:
<?php
//ini_set('localhost');
$to = "sommai@gmail.com";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: mygmail@gmail.com";
if(mail($to,$subject,$txt,$headers)){
echo "message sent";
} else {
echo "mail sent fail";
}
?>
它显示邮件以echo发送但从未收到任何邮件。
请指导我解决这个问题。