【问题标题】:Unable to send email to yahoo email using PHP无法使用 PHP 将电子邮件发送到雅虎电子邮件
【发布时间】:2013-09-19 12:07:50
【问题描述】:

我的脚本正常工作,因为它显示“消息已发送!”但没有收到指定电子邮件的电子邮件。顺便说一句,使用 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!';
?>

这是来自我的 php.inisendmail.ini 的信息:

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

sendmail.ini

smtp_server=smtp.mail.yahoo.com

; smtp port (normally 25)

smtp_port=25

auth_username=theaccount+yahoo.com      
auth_password=passwordhere

【问题讨论】:

    标签: php email xampp yahoo


    【解决方案1】:

    您尚未“注释掉”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 文件,分号; 用于cmets。所以你需要从这些行中删除它:

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

    试试看:)

    【讨论】:

    • Mmmhh cr@ap :/ 我从来不需要在本地发送邮件,所以我不知道该怎么做。我认为方法是尝试更深入地调试。使用 php 的原生 mail() 函数可能很难做到这一点,因为它不会输出任何错误,所以我建议您使用一些库,例如 PhpMailer。此外,它是进一步使用的绝佳工具!
    • 将尝试 PhpMailer。谢谢!!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-06
    • 2017-01-08
    • 1970-01-01
    • 2015-06-11
    • 2013-09-04
    相关资源
    最近更新 更多