【问题标题】:PHPMailer - AUTH not acceptedPHPMailer - AUTH 不被接受
【发布时间】:2014-04-09 19:48:51
【问题描述】:

我正在尝试为内部联系表单运行 PHPMailer,但收到错误 ERROR: AUTH not accepted from server。这是我当前的代码..

require_once('/includes/class.phpmailer.php');
include("/includes/class.smtp.php");

if (isset($_POST['submit'])) {

$mail = new PHPMailer(true); 
$mail->IsSMTP(); 
$name = htmlspecialchars($_POST['name']);
$email = htmlspecialchars($_POST['email']);
$message = htmlspecialchars($_POST['message']);

try {
  $mail->Host       = "192.168.6.6"; 
  $mail->SMTPDebug  = 2;                     
  $mail->SMTPAuth   = True;
  $mail->Username = 'xxxxx';
  $mail->Password = '***';                  
  $mail->Port       = 25;                    
  $mail->AddAddress('xxx@xxx.com', 'xxxxx');
  $mail->SetFrom($email);
  $mail->Subject = 'New message from Contact Form';
  $mail->Body = $message;
    $mail->Send();
  } catch (phpmailerException $e) {
    echo $e->errorMessage();
  } catch (Exception $e) {
    echo $e->getMessage();
  }
};

【问题讨论】:

  • 我怀疑这个192.168.6.6

标签: php email phpmailer


【解决方案1】:

此错误基本上意味着您的身份验证尝试被远程服务器拒绝。不同的远程邮件服务器需要不同的 PHPMailer 设置(以及 SMTP 设置)。

这可能是由于

  • 使用了错误的端口
  • 使用了错误的主机
  • 用户/密码不正确
  • SMTPSecure 不正确

SMTP 设置示例:

【讨论】:

  • 主机和端口正确,用户/密码正确 - SMTPSecure 怎么样?
  • RE SMTPSecure,可以设置为 tls 或 ssl。您使用的是哪个 PHPMailer 副本?看起来互联网上有很多旧版本/错误信息。我引用github.com/PHPMailer/PHPMailer
  • 我正在使用您链接的 PHPMailer。
  • 设置 SMTPDebug = 3 并粘贴应该转储连接信息的输出。
【解决方案2】:

如果您在内部使用此功能,则可能根本不需要使用 SMTP 身份验证,具体取决于您的服务器设置。试试这个,看看它是否有效:

require_once('/includes/class.phpmailer.php');
include("/includes/class.smtp.php");

if (isset($_POST['submit'])) {

$mail = new PHPMailer(true); 
$mail->IsSMTP(); 
$name = htmlspecialchars($_POST['name']);
$email = htmlspecialchars($_POST['email']);
$message = htmlspecialchars($_POST['message']);

try {
  $mail->Host       = "192.168.6.6"; 
  $mail->SMTPDebug  = 0;                     
  $mail->SMTPAuth   = False;                 
  $mail->Port       = 25;                    
  $mail->AddAddress('xxx@xxx.com', 'xxxxx');
  $mail->SetFrom($email);
  $mail->Subject = 'New message from Contact Form';
  $mail->Body = $message;
    $mail->Send();
  } catch (phpmailerException $e) {
    echo $e->errorMessage();
  } catch (Exception $e) {
    echo $e->getMessage();
  }
};

【讨论】:

    猜你喜欢
    • 2016-10-22
    • 2022-01-01
    • 2013-03-30
    • 1970-01-01
    • 2019-12-15
    • 1970-01-01
    • 2013-02-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多