Solved

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

Posted on 2010-11-17
9
3,947 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
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
 

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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 25

Accepted Solution

by:
Tony1044 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 25

Expert Comment

by:Tony1044
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 25

Expert Comment

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

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Find out what you should include to make the best professional email signature for your organization.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

896 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

16 Experts available now in Live!

Get 1:1 Help Now