Solved

Getting Exchange 2007 to work with PHPMailer SMTP authentication only works with my account

Posted on 2008-10-07
4
3,247 Views
Last Modified: 2013-12-13
I'm trying to get PHPMailer to work with a Wiki so that it can send out email to users when necessary, eg. when they request password resets. I first created a simple test that attempts to use PHPMailer by itself, and I got that working - but only with my normal domain user account and my domain admin user account. I thought I'd look at that problem later, and so I then started work on integrating usage of PHPMailer into our Wiki, and have successfully completed integration of PHPMailer into MediaWiki's UserMailer.php code that sends mail when the password reset button on the login page is used. Now I have the same problem as before; the mail server would not accept the mail unless I gave it my username and password (which is for an account with a lot of admin privileges) or my domain admin account credentials (which obviously has ALL admin privileges). I want to get it to work with a lower-privileged account that I created specifically for this purpose, but I have been unable to. I have tried getting a couple of other people to enter the credentials for their standard user accounts, and I get the same result: the mail server won't accept it.

The way I have gone about doing this is by creating a class SecureMailer (source attached), which extends PHPMailer, just to set some default values. I then create an instance of SecureMailer, set the body, subject and recipient(s), and away it goes.

Included is a code snippet for my SecureMailer.php file. I'm about to attach another code snippet in a separate post for a testmail.php file, which I used to test the setup. It works flawlessly when the SecureMailer.php file has my username and password, but I want it to use one with fewer privileges (for obvious reasons), if possible one that's not even a member of the Domain Users group.

This is all happening in a Windows Server 2003 domain, and the mail host is the domain controller, which is running Windows Server 2003 R2 x64 and Exchange 2007 Standard.

So, how do I fix this? I'm no expert on this kind of thing, but what I reckon is that the user accounts don't have the required privileges to establish an SSL/TLS-encrypted connection to the Exchange Server.
<?php
 

include_once("class.phpmailer.php");
 

class SecureMailer extends PHPMailer {

	

	var $Mailer 		= "smtp";

	var $Host 		= "[ip]";

	var $SMTPAuth 		= true;

	var $Username 		= "[username]";

	var $Password 		= "[password]";

	

	/* mail settings */

	var $ContentType 	= 'text/html';

	var $WordWrap 		= 80;

	var $SMTPDebug 		= false;

	var $Encoding 		= '7bit';

    

	/* mail details */

	var $From 		= "[addr]@[domain].[tld]";

	var $FromName 		= "[name]";

	

}
 

?>

Open in new window

0
Comment
Question by:spectra-qest
  • 3
4 Comments
 

Author Comment

by:spectra-qest
ID: 22666293
As promised, the code for my testmail.php...

<?php
 

require("SecureMailer.php");
 

$mail = new SecureMailer;

 

$mail->AddAddress("aRealAddress@mail.com, "aName");

$mail->Subject = "Message Subject";

$mail->Body    = "Message Body";

 

if(!$mail->Send())

{

   echo "<br>Error sending message!<br>";

   exit;

}
 

echo "Success!!";
 

?>

Open in new window

0
 
LVL 15

Accepted Solution

by:
It breaks therefore I am earned 500 total points
ID: 22841768
Hi, Have you thought of running Sendmail on your local box and mailing locally? or you could create a connector that allows open relay from the IP address of your wiki server.

http://msexchangeteam.com/archive/2006/12/28/432013.aspx
0
 

Author Comment

by:spectra-qest
ID: 22919227
Thanks. Sorry for the wait. I'm trying it now.
0
 

Author Comment

by:spectra-qest
ID: 22927943
Thanks for that article. It pointed me in the right direction. I had to work on the Wiki files some more, but I got it eventually.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
To show how to create a transport rule in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Rules tab.:  To cr…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now