Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2010-11-17
9
Medium Priority
?
4,464 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 48

Expert Comment

by:hernst42
ID: 34153774
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
ID: 34154766
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
ID: 34156367
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:alumwell
ID: 34162932
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
 
LVL 26

Accepted Solution

by:
Tony J earned 2000 total points
ID: 34163044
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
ID: 34163076
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 26

Expert Comment

by:Tony J
ID: 34163090
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
ID: 34163111
Yes I didnt see that, have given you the points. Thanks :)
0
 
LVL 26

Expert Comment

by:Tony J
ID: 34163137
Thank you - appreciate that. :)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I don't pretend to be an expert at this, but I have found a few things that are useful. I hope that sharing them here will help others, so they will not have to face some rather hard choices. Since I felt this to be a topic of enough importance and…
On September 18, Experts Exchange launched the first installment of the Help Bell, a new feature for Premium Members, Team Accounts, and Qualified Experts. The Help Bell will serve as an additional tool to help teams increase question visibility.
The viewer will learn how to count occurrences of each item in an array.
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 …
Suggested Courses

598 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