无法使用PHP向yahoo电子邮件发送电子邮件

无法使用PHP向yahoo电子邮件发送电子邮件,php,email,xampp,yahoo,Php,Email,Xampp,Yahoo,我的脚本在显示“消息已发送”时起作用但未收到指向指定电子邮件的电子邮件。使用XAMPP顺便说一句。感谢您的帮助。多谢各位 <?php $to = 'theaccount@yahoo.com'; $subject = 'Sample Subject'; $message = 'Hi. This is a sample message.'; $headers = 'From: webmaster@august.ai.com' . "\r\n" . 'Reply-To: no-reply

我的脚本在显示“消息已发送”时起作用但未收到指向指定电子邮件的电子邮件。使用XAMPP顺便说一句。感谢您的帮助。多谢各位

<?php
$to = 'theaccount@yahoo.com';
$subject = 'Sample Subject';
$message = 'Hi. This is a sample message.';
$headers = 'From: webmaster@august.ai.com' . "\r\n" .
    'Reply-To: no-reply@august.ai.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

echo (mail($to, $subject, $message, $headers)) ? 'Message sent!' : 'Message not sent!';
?>
sendmail.ini

[mail function]
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
; SMTP = theaccount@yahoo.com
; smtp_port = 25
smtp_server=smtp.mail.yahoo.com

; smtp port (normally 25)

smtp_port=25

auth_username=theaccount+yahoo.com      
auth_password=passwordhere
您尚未“注释掉”php.ini的SMTP配置行:

[mail function]
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
; SMTP = theaccount@yahoo.com
; smtp_port = 25
对于
php.ini
文件,分号
用于注释。因此,您需要将其从这些行中删除:

[mail function]
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
SMTP = theaccount@yahoo.com
smtp_port = 25

试试看:)

Mmmhhcr@ap:/我从来都不需要在本地发送邮件,所以我不知道该怎么办。我认为方法是尝试进行更深入的调试。使用php本机的
mail()
函数可能很难做到这一点,因为它不会输出任何错误,因此我建议您使用一些lib,例如。此外,它是一个伟大的工具,供进一步使用!我会试试PhpMailer。谢谢