简体   繁体   中英

phpmailer with exchange and no SSL or TLS

I've been working on this problem for the past 2 days and everything that i tried is still not working. I'm trying to authenticate to an exchange server with php so i can send to outside domains.

If i disable authentication, i can send internally without any issues.

Here's the error

SMTP -> FROM SERVER:220 N-CAS1-13.company.domain Microsoft ESMTP MAIL Service ready at Sat, 20 Feb 2016 16:16:05 -0500
SMTP -> FROM SERVER: 250-N-CAS1-13.company.domain Hello [10.10.10.31] 250-SIZE 37748736 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-STARTTLS 250-X-        ANONYMOUSTLS 250-AUTH NTLM 250-X-EXPS GSSAPI NTLM 250-8BITMIME 250-BINARYMIME 250-CHUNKING 250 XRDST
SMTP -> ERROR: AUTH not accepted from server: 504 5.7.4 Unrecognized authentication type
SMTP -> FROM SERVER:250 2.0.0 Resetting
SMTP Error: Could not authenticate. 

Here's the phpmailer code

require "phpmailer/class.phpmailer.php"; //include phpmailer class
//require "PHPMailer-5.2.14/PHPMailer-5.2.14/PHPMailerAutoload.php";



$mail = new PHPMailer();  


$mail->IsSMTP();              
$mail->SMTPAuth = true;  
$mail->SMTPDebug = 2;       
$mail->SMTPSecure = false;       
$mail->Host = "10.10.10.38";
$mail->Port = 25;  


$mail->Username   = "username"; 
$mail->Password   = "cGhpbGltaWVzMjM2OTY5"; 

 $mail->From = "name@companydomain.com";
 $mail->FromName = "name";
 $mail->SetFrom("name@companydomain.com", "name");


$mail->Subject = $_POST['company'].": (Time Sensitive)";  
$mail->AddEmbeddedImage('trans2.png', 'logo', 'trans2.png ');


$mail->AddAttachment("docs/install.xlsx");
$mail->MsgHTML($message1.$message2.$message3);



// Send To  
$mail->AddAddress($_POST['emailid'], ""); // Where to send it - Recipient
$mail->AddCC("person@companydomain.com");
$result = $mail->Send();        // Send!  
$message = $result ? 'Successfully Sent!' : 'Sending Failed!';      
unset($mail);

}

I tried different version of phpmailer, i tried encoding the password with base64, i tried just the username, i tried the email as the username...Still nothing

The exchange server is on port 25 and it does not require SSL or TLS.

SMTP -> FROM SERVER: ... 250-AUTH NTLM

The server is only expecting NTLM authentication, not LOGIN, PLAIN or DIGEST-MD5 which could be used with only username and password. You would also need the NTLM realm and your workstation.

Unfortunately there is not much documentation about it but you might have a look at http://www.phpclasses.org/browse/file/31.html and look for NTLM to get the idea how to do this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM