-1

I'm trying to run PHPMailer for an internal contact form and I am getting the error ERROR: AUTH not accepted from server. Here is my current code..

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();
  }
};

2 Answers2

1

This error basically means that your attempt to authenticate was rejected by the remote server. Different PHPMailer settings (well SMTP settings) are required by different remote mail servers.

This could be caused by

  • Using the wrong port
  • Using the wrong host
  • Incorrect user/pass
  • Incorrect SMTPSecure

Example SMTP setup:

Community
  • 1
  • 1
Pez Cuckow
  • 14,048
  • 16
  • 80
  • 130
  • The host and port are correct and the user/password is correct - what about SMTPSecure? –  Apr 09 '14 at 11:36
  • RE SMTPSecure, it can be set to tls or ssl. Which copy of PHPMailer are you using? Looks like there are plenty of old versions/misinformation on the internet. I'm referencing https://github.com/PHPMailer/PHPMailer – Pez Cuckow Apr 09 '14 at 11:41
  • I'm using the PHPMailer that you linked. –  Apr 09 '14 at 11:48
  • Set SMTPDebug = 3 and paste the output that should dump connection information. – Pez Cuckow Apr 09 '14 at 12:07
0

If you are using this internally, you may not need to use SMTP authentication at all, depending on your server settings. Try this and see if it works:

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();
  }
};