When ever I try and send a email to a certain exchange server, I get the response : “SMTP Error: Could not connect to SMTP host”.
The server I am attempting to use is a Mail Exchange server thus the password I was given is in the form of domain\username.
I do not know what I am doing wrong. Any ideas I can try out?
PS. We are able to connect with the server making use of the default php mail functions.
Here is the code I am using to test the email with:
<?php
define("CR_AUTHENTICATE", false);
include_once("setup.php");
ini_set('display_errors', 1); # enable PHP error reporting
error_reporting(E_ALL);
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "web.mydomain.co.za"; // SMTP server
$mail->SMTPAuth = true;
$mail->Username = "mydomain.\\webmaster";
$mail->Password = "*********";
$mail->SetLanguage("en", DIR_3RDPARTY."/phpmailer/language/");
$mail->From = "webmaster@mydomain..co.za";
$mail->FromName = "mydomain.";
$mail->AddAddress("jaco@mydomain..co.za");
$mail->Subject = "SMTP Test";
$mail->Body = "Hello World";
if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo "Sent";
}
?>
I have tested this on my local development enviroment running php 5.2.11 and the email is sent out without any trouble.
I then tested it on the live server running php 5.2.15, but it gives me the same error.
I checked the php info files and the following mail related settings:
LOCAL
sendmail_from no value no value
sendmail_path no value no value
SMTP smtp.ourdomain.co.za smtp.ourdomain.co.za
smtp_port 25 25
LIVE
sendmail_from no value no value
sendmail_path /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i
SMTP localhost localhost
smtp_port 25 25