2012-06-04 180 views
3

这看起来很简单,我的php脚本能够执行。但是我从来没有收到邮件。下面是相关代码:使用XAMPP,sendmail和gmail smtp服务器发送邮件

的php.ini

sendmail.ini

smtp_server=smtp.gmail.com 

smtp_port=587 
smtp_ssl=auto 
default_domain=mydomain.com 
error_logfile=error.log 
debug_logfile=debug.log 
[email protected] 
auth_password=passpass 

[email protected] 
hostname=smtp.gmail.com 

,请问有什么我在这里失踪?我的脚本正在向我发送电子邮件。那不会是个问题吧?

<?php 
$to = "[email protected]"; 
$subject = "Test mail"; 
$message = "Hello! This is a simple email message."; 
$from = "[email protected]"; 
$headers = "From:" . $from; 
mail($to,$subject,$message,$headers); 
echo "Mail Sent."; 
?> 
+0

您是否启动了汞? –

+0

我没打开水银。如果你使用外部smtp服务器,我使用gmail – hamobi

+0

你有没有合适的端口? SSL端口:465 – bumperbox

回答

-1

尝试此

sendmail.ini

[sendmail的]

smtp_server=smtp.gmail.com 
smtp_port=465 
smtp_ssl=ssl 
error_logfile=error.log 
debug_logfile=debug.log 
auth_username=[email]@gmail.com 
auth_password=[email password] 
pop3_server= 
pop3_username= 
pop3_password= 
force_sender=[email]@gmail.com 
force_recipient= 
hostname=smtp.gmail.com 

的php.ini

[邮件功能]

SMTP = smtp.gmail.com 
smtp_port = 465 
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t" 
mail.add_x_header=Off 
相关问题