Solved

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

Posted on 2010-11-17
9
4,032 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

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 25

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 25

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 25

Expert Comment

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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Find out what you should include to make the best professional email signature for your organization.
In this video we show how to create an email address policy 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…
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 …

789 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