2016-09-17 86 views
1

发送电子邮件我试图从本地主机使用PHP发送电子邮件,但未能 这样如何配置XAMPP以从本地主机的PHP

<?php 
$to= "[email protected]"; 
$subject = "this is test"; 
$messages= "this is message test, congrats, your success" 

if(mail($to, $subject, $messages)) { 
echo "success guys"; 
} 
else{ 
echo "failed guys"; 
}; 

?> 

代码是如何解决这些问题?我正在使用Linux。以及如何配置我的XAMPP在本地主机上发送电子邮件?

+2

看看[这个答案在这里。](http://stackoverflow.com/questions/15965376/how-to-configure-xampp-to-send-mail-from-localhost) –

回答

2

您可以配置C:\ xampp \ php \ php.ini和c:\ xampp \ sendmail \ sendmail.ini让gmail发送邮件。

在C:\ xampp \ php \ php.ini中找到extension = php_openssl.dll,并从该行的开头删除分号以使SSL适用于localhost的gmail。

在php.ini文件

找到[邮件功能],改变

SMTP=smtp.gmail.com 
smtp_port=587 
sendmail_from = [email protected] 
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t" 

现在打开C:\xampp\sendmail\sendmail.ini。用以下代码替换sendmail.ini中的所有现有代码

[sendmail] 

smtp_server=smtp.gmail.com 
smtp_port=587 
error_logfile=error.log 
debug_logfile=debug.log 
[email protected] 
auth_password=your-gmail-password 
[email protected] 

现在你已经完成了!输入你的Gmail帐户

+0

我'使用Linux,发送电子邮件的文件夹? –