We help IT Professionals succeed at work.

Send Email using Exchange Server

ellandrd asked
Medium Priority
Last Modified: 2010-05-18
at work we have a mail server, windows 2000 exchange Server to be specific.  We have PHP 5.1.4 installed and running on IIS.

im wanting to send emails using mail server, but the code ive put together dont seem to work.  when i run my script, i get no errors, but no emails come through to my mailbox either...

mailserver  IP is


$mail->Sender = 'administrator@companyname.com';


$mail = new PHPMailer();
$mail->From = 'administrator@companyname.com';
$mail->FromName = 'Pegasus Intranet Gate Keeper';
$mail->Subject = 'Just Testing the SMPT Settings for the Intranet';
$mail->ContentType = 'text/html';
$mail->CharSet = 'iso-8859-1';
$mail->Priority = 1;
$mail->Body = '<p>Hello, This email has been send using the Pegasus Exchange Server (</p>';
Watch Question

Top Expert 2007
The usage of addAddress is not 100% correct. It looks like you wnat to send the mails to two recipients with
it should be

But the mails should have come to the first email-adress

also put an
echo $mail->ErrorInfo
to see ih phpmailer has encountred an error

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Mark GilbertSenior Performance Engineer
As you are using the PHPMailer classes (http://phpmailer.sourceforge.net/), I would recommend that in the class files, look for the authentication section.  I believe it should be contained in the file class.phpmailer.php.  Do a search for var $Host and you should find all the settings that need changed.  For example, point $Host to your exchange server, and put in the username and password necessary to connect to the server.  You may have to setup an account on the exchange server for the purposes of php authentication.

Hope this helps.
Top Expert 2007
ups forgot to add that you need

$mail->Host = '';

to delive the mail via that smtp-server


>>it should be

Oh! OK, i was shown this way by another expert in the PHP TA...  they where obviously wrong them... damn and ive been shown other people this all along!

OK i'll fix this.

>>also put an
>>echo $mail->ErrorInfo
>>to see ih phpmailer has encountred an error

Ya sorry, ive added these since:

      echo 'Message send!';
      echo 'Message not send!';

and all i get is: Message not send! so i'll add what you suggest again...

>>$mail->Host = '';
>>to delive the mail via that smtp-server

ah - this would be good to have... if i want to send an email... ;-)


Thank you for that advise - i wasnt sure if to go searching for options in that class file as i didnt want to muck the class up by editing it...but i'll take a look now

ive also checked my PHP.INI file on the exchange server and the setting are correct in terms of SMTP server address and port...

thanks guys, i'll reply in a few mins



Im not getting:

Language string failed to load: instantiate
Message not send!



Ive went into that class and set the username/password of the admin account and set host to and set the from address to administrator@companyname.com...

still no difference...

Mark GilbertSenior Performance Engineer
Hmm, you might find this page useful with the above error:


Additionally, here's another link to check:



none of these seem to fix my issue.


Ive changed my username to my account login username and now i get this:

Warning: fsockopen() [function.fsockopen]: unable to connect to (An established connection was aborted by the software in your host machine. ) in c:\Inetpub\wwwroot\prelease\classes\class.smtp.php on line 105
Language string failed to load: connect_host


ive already looked in the class.smtp.php and i cant make heads or tails of that code or where it might be going wrong..

any other options??


cheers guys i got it working another way by using a remote SMTP server.

thanks for helping!

Mark GilbertSenior Performance Engineer

Hi Ellandrd, glad to hear you have the problem resolved.  Thanks for the points and the grade and have a great day.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.