Php 未从本地主机接收电子邮件
我正在尝试从本地主机向我的gmail发送邮件。我正在使用Windows7。My mail()函数在提交时未显示任何错误。相反,在提交时,一个窗口突然出现并消失,即使我不能正确地看到该窗口 mail.phpPhp 未从本地主机接收电子邮件,php,email,Php,Email,我正在尝试从本地主机向我的gmail发送邮件。我正在使用Windows7。My mail()函数在提交时未显示任何错误。相反,在提交时,一个窗口突然出现并消失,即使我不能正确地看到该窗口 mail.php $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; if(mail($to, $subject, $body,$headers)) {
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
if(mail($to, $subject, $body,$headers))
{
echo 'Mail has send';
}
else
{
echo "Email Not Found";
}
php.ini
1130 [mail function]
1131 ; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
1132 SMTP = smtp.gmail.com
1133 smtp_port = 587
1134 sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
sendmail.ini
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=mygmail.com
auth_password=myPass
force_sender=mygmailgmail.com
初始化mail.php中的所有变量 下面是一个例子:
$to = 'sender_email_id_here@gmail.com';
$subject = 'Testing';
$message = 'Email Testing';
$headers = 'From: your_emil_id_here@gmail.com' . "\r\n" .
'MIME-Version: 1.0' . "\r\n" .
'Content-type: text/html; charset=utf-8';
因为谷歌保证了你的电子邮件的安全,而从谷歌的角度来看,你的php应用程序或网站是不安全的。可能是谷歌没有提供你的php代码来访问你的电子邮件。您可能需要检查一下。这是下面的谷歌声明,您可以看到
**
- 不太安全的应用程序访问
嘿!我已经在我的文件中声明了变量,没有声明我怎么能在我的函数中传递空变量!已经打开了!