Page 1 of 1

Send Email using Exchange Server

Posted: Thu Oct 26, 2006 8:58 am
by amir
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


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.

I want to send emails using mail server, but the code I have put together does not seem to work.  when I run my script, I get no errors, but no emails come through to my mailbox either...

mailserver  IP is 192.168.0.2

Code: Select all

<?php
require('classes/class.phpmailer.php');

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

ini_set('sendmail_from',$mail->Sender);

$mail = new PHPMailer();
$mail->AddAddress('sdelaney@companyname.com','mlennon@companyname.com');
$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 (192.168.0.2)</p>';
$mail->Send();
$mail->ClearAddresses();
$mail->SmtpClose();
?>
Any help would be greatly appreciated. TIA.


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu Oct 26, 2006 9:21 am
by Chris Corbyn
PHPMailer requires that you tell it your SMTP server to use.

Have you looked at Swift Mailer?

Posted: Thu Oct 26, 2006 9:23 am
by volka
amir wrote:mailserver IP is 192.168.0.2
Does the phpmailer object "know" that? I don't see it.
Maybe you want the check the return values of the methods and if they signal an error print some information?

edit: ah, too slow...

Posted: Thu Oct 26, 2006 11:04 am
by amir
Thanks All!
Its working now.
I am coding it as
$mail->AddAddress('sdelaney@companyname.com','mlennon@companyname.com');
and it was not working. Then I changed it as in two lines, i mean separatey and its working.