Solved

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

Posted on 2010-11-17
9
4,161 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 

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 Johncock earned 500 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 Johncock
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 Johncock
ID: 34163137
Thank you - appreciate that. :)
0

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

Read this checklist to learn more about the 15 things you should never include in an email signature.
This article will help to fix the below errors for MS Exchange Server 2013 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager

688 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