2012-06-04 235 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 
相關問題