Solved

php.ini Microsoft Exchange authenticate SMTP when using php mail() function

Posted on 2010-11-17
9
3,889 Views
Last Modified: 2012-05-10
let me give you the set up.

We have an internal machine that has WAMP server 2.0 installed with php, mysql etc. On here I have created a php order system that we can keep track of orders currently awaiting. When we order something it sends an email to the supplier.

The problem is that when I process the order and try and send an email I get an error back saying
Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to relay in file.php on line 22

in the php ini file it is set up to find the exchange server
SMTP = 172.16.0.1
smtp_port = 25


And this works perfectly when sending an email to a user who is on our exchange server. The problem happens when trying to send an email to an external address. One that is not part of our domain.

I think it might be to do with authentication but am not sure how to configure this. So if anyone can help that would be great.
0
Comment
Question by:alumwell
9 Comments
 
LVL 48

Expert Comment

by:hernst42
Comment Utility
with the native PHP-mail function you can authenticate. You need a PHP-Mailer class like http://phpmailer.sf.net or http://swiftmailer.sf.net which are capable of doing a stmp auth
0
 

Author Comment

by:alumwell
Comment Utility
I was hoping for something that i can alter/add to the php.ini or the actual php file to make this work. If i use EasySMTP on the internal server it works but really need a better solution
0
 
LVL 7

Expert Comment

by:Vimal DM
Comment Utility
Hai,

Try to use "PHPMailer" which will solve all your problems,

1) Can avoid spams
2) Mail will can sent to all the different email id's
3) Bulk mail
4) Bulk attachment
0
 

Author Comment

by:alumwell
Comment Utility
Ok I have tried using the PHPmailer and have tave the following error when sending

Mailer Error: SMTP Error: Could not connect to SMTP host.

This is the php code I am using
require("class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP();                                      // set mailer to use SMTP
$mail->Host = "exchange.domain.uk";  // specify main and backup server
$mail->SMTPAuth = true;     // turn on SMTP authentication
$mail->Username = "administrator";  // SMTP username
$mail->Password = "adminpass"; // SMTP password

$mail->From = "me@domain.uk";
$mail->FromName = "John Smith";
$mail->AddAddress("customer@domain.co.uk", "The customer");

$mail->WordWrap = 120;                                 // set word wrap to 50 characters
$mail->IsHTML(true);                                  // set email format to HTML

$mail->Subject = "Test Message";
$mail->Body    = "This is the HTML message body <b>in bold!</b>";
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";

if(!$mail->Send())
{
   echo "Message could not be sent. <p>";
   echo "Mailer Error: " . $mail->ErrorInfo;
   exit;
}

echo "Message has been sent";
?>

Open in new window



Any ideas?


0
Are your corporate email signatures appalling?

Is it scary how unprofessional your email signatures look? Do users create their own terrible designs and give themselves stupid job titles? You can make this a lot easier for yourself by choosing an email signature management solution from Exclaimer today.

 
LVL 25

Accepted Solution

by:
Tony1044 earned 500 total points
Comment Utility
Are you using Exchange 2007 / 2010?

If so, allow the send connector to relay.

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

What I prefer to do, is add an additional IP address to the Exchange server and bind a dedicated send connector to it that is used by scripts to relay.

Any issues then mean that connector won't interfere with ordinary mail flow.
0
 

Author Comment

by:alumwell
Comment Utility
needed to create a receive connector on exchange for the internal server and this did the tick. Don't need to validate authentication this way using php.
0
 
LVL 25

Expert Comment

by:Tony1044
Comment Utility
I stated that a connector was the best option prior to the close request. I feel I that I provided the correct solution even if the OP didn't see it.
0
 

Author Comment

by:alumwell
Comment Utility
Yes I didnt see that, have given you the points. Thanks :)
0
 
LVL 25

Expert Comment

by:Tony1044
Comment Utility
Thank you - appreciate that. :)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Marketers need statistics and metrics like everybody else needs oxygen. In this article we explain how to enable marketing campaign statistics for Microsoft Exchange mail.
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
In this video we show how to create a mailbox database 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 Servers >> Data…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

772 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

11 Experts available now in Live!

Get 1:1 Help Now