[英]PHP mail() function returns 1 but no mail is sent despite configuring XAMPP
In a PHP application during the sign up step, I'm sending an email with a verfication link to the user.在注册步骤期间的 PHP 应用程序中,我向用户发送带有验证链接的 email。 I'm using XAMPP in localhost to serve the page, and my database is in another device but in the same network.我在 localhost 中使用 XAMPP 来提供页面,我的数据库在另一个设备中但在同一个网络中。 When I fill the form and hit the sign up button, I get a success message, the database is updated but no email is received to my address.当我填写表格并点击注册按钮时,我收到一条成功消息,数据库已更新,但我的地址没有收到 email。 I've searched for answers and found out that I had to configure php.ini
and sendmail.ini
properly in order for it work and I did that as well but still no mail is send.我搜索了答案,发现我必须正确配置php.ini
和sendmail.ini
才能正常工作,我也这样做了,但仍然没有发送邮件。 Can anyone explain why is this happening?谁能解释为什么会这样? Below are the configurations of both php.ini
and sendmail.ini
as there is no problem with my signup.php since the database is updating.以下是php.ini
和sendmail.ini
的配置,因为我的 signup.php 没有问题,因为数据库正在更新。
sendmail.ini发送邮件.ini
[sendmail]
smtp_server= smtp.mail.yahoo.com
smtp_port=465
smtp_ssl=ssl
;default_domain=mydomain.com
error_logfile=error.log
;debug_logfile=debug.log
auth_username=mymail@yahoo.com
auth_password=mypassword
pop3_server=
pop3_username=
pop3_password=
force_sender=mymail@yahoo.com
force_recipient=
hostname=
php.ini php.ini
[mail function]
SMTP= smtp.mail.yahoo.com
smtp_port=465
sendmail_from = mymail@yahoo.com
sendmail_path = "\"C:\Users\GMKRG\Desktop\xampp\sendmail\sendmail.exe" -t"
;mail.force_extra_parameters =
mail.add_x_header=Off
mail.log = "\"C:\Users\GMKRG\Desktop\xampp\sendmail\error.txt"
;mail.log = syslog
I've also configured my yahoo account to accept mails from less secure apps but still no mail received.我还将我的雅虎帐户配置为接受来自不太安全的应用程序的邮件,但仍然没有收到邮件。 Thanks in advance.提前致谢。
EDIT: Below is the php mail function in case it helps more.编辑:下面是 php 邮件 function 以防它有更多帮助。
$email = mysqli_real_escape_string($connection, $mailString);
$emailBody = "Please click on the link below to activate your account:\n\n";
$emailBody .= "localhost/website/activate.php?email=" . urlencode($email) . "&key=$activationKey";
if(mail($email, 'Confirm your registration', $emailBody, 'From:'.'myaddress@yahoo.com')){
echo "<div class='alert alert-success'>Thank you for registering. A
confirmation email has been sent to $email. Please click on the
activation link inside it to activate your account.</div>";
}
It seems that yahoo smtp sever is not working properly with xampp.雅虎 smtp 服务器似乎无法与 xampp 一起正常工作。 Once I switched to gmail everything worked.一旦我切换到 gmail 一切正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.