Send Email using Exchange Server

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
amir
Forum Contributor
Posts: 287
Joined: Sat Oct 07, 2006 4:28 pm

Send Email using Exchange Server

Post 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]
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

PHPMailer requires that you tell it your SMTP server to use.

Have you looked at Swift Mailer?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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...
amir
Forum Contributor
Posts: 287
Joined: Sat Oct 07, 2006 4:28 pm

Post 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.
Post Reply