This question already has an answer here:
这个问题在这里已有答案:
- PHP mail function doesn't complete sending of e-mail 24 answers
- PHP邮件功能没有完成发送电子邮件24个答案
This seems like something fairly straightforward and my php script is able to execute. However I am never receiving the mail. Here is the relevant code:
这似乎相当简单,我的PHP脚本能够执行。但是我从未收到邮件。这是相关的代码:
php.ini
php.ini中
[mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP = localhost
; http://php.net/smtp-port
;smtp_port = 25
sendmail_path = "C:\xampplite\sendmail\sendmail.exe -t -i"
sendmail.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
auth_username=username50@gmail.com
auth_password=passpass
force_sender=myemail@gmail.com
hostname=smtp.gmail.com
Is there anything here I'm missing? My script is sending email to myself. That wouldn't be a problem right?
这里有什么我想念的吗?我的脚本正在给自己发送电子邮件。那不是问题吧?
<?php
$to = "blah@gmail.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
1 个解决方案
#1
-1
Try this
尝试这个
sendmail.ini
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
php.ini中
[mail function]
[邮件功能]
SMTP = smtp.gmail.com
smtp_port = 465
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
mail.add_x_header=Off
#1
-1
Try this
尝试这个
sendmail.ini
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
php.ini中
[mail function]
[邮件功能]
SMTP = smtp.gmail.com
smtp_port = 465
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
mail.add_x_header=Off