【问题标题】:my phpMailer not working我的 phpMailer 不工作
【发布时间】:2016-08-27 12:17:25
【问题描述】:

嗨,当我执行 mailtest.php 时,我的 phpmailer 会产生以下结果

无法发送邮件。邮件程序错误:SMTP 连接()失败。 https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

我在这个论坛上遇到了很多关于 phpmailer 的问题,但没有一个对我有用。

我的邮件测试.php

     <?php
       require ("/phpmailer/PHPMailerAutoload.php");
       require ("/phpmailer/class.phpmailer.php");

       $mail = new PHPMailer;

       //$mail->SMTPDebug = 3;                               // Enable verbose debug output

       $mail->isSMTP();                                      // Set mailer to use SMTP
       $mail->Host = 'smtp.gmail.com';  // Specify main and backup SMTP servers
       $mail->SMTPAuth = true;                               // Enable SMTP authentication
       $mail->Username = 'thethih@gmail.com';                 // SMTP username
       $mail->Password = 'password.';                           // SMTP password
       $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
       $mail->Port = 587;                                    // TCP port to connect to

       $mail->setFrom('from@example.com', 'Mailer');
       $mail->addAddress('thethih@gmail.com', 'Joe User');     // Add a recipient
       $mail->addAddress('thethih@yahoo.com');               // Name is optional
       $mail->addReplyTo('info@example.com', 'Information');
       $mail->addCC('cc@example.com');
       $mail->addBCC('bcc@example.com');


       $mail->isHTML(true);                                  // Set email format to HTML

       $mail->Subject = 'Here is the subject';
       $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
       $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

       if(!$mail->send()) {
         echo 'Message could not be sent.';
        echo 'Mailer Error: ' . $mail->ErrorInfo;
        } else {
        echo 'Message has been sent';
        }

     ?>

任何帮助将不胜感激..它位于本地主机中。

【问题讨论】:

  • 隐藏您的凭据!!
  • 密码。不是实际密码..谢谢
  • @JoseManuelAbarcaRodríguez 还没有工作
  • 你也应该取消注释 //$mail-&gt;SMTPDebug = 3; 那是你的内置调试器。
  • 我们可以假设您阅读了 phpMailer 为您生成的链接?还是我们应该复制该部分供您在这里阅读并浪费我们和您的时间???

标签: php phpmailer


【解决方案1】:

在 GitHub 上,PHPMailer 说“与 PHP 5.0 及更高版本兼容”,但事实可能并非如此。

尝试将您的 PHP 版本更改为 5.5,看看是否能解决问题。您可以通过转到控制面板并单击 PHP 配置来更改您的 PHP 版本。

【讨论】:

    猜你喜欢
    • 2014-03-14
    • 1970-01-01
    • 1970-01-01
    • 2012-05-21
    • 2014-08-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多