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

x
?
Solved

PHP Email not working Windows 2008 R2

Posted on 2015-02-19
12
Medium Priority
?
125 Views
Last Modified: 2015-02-21
I am running a Windows 2008 R2 Server for a customer. They have asked me to install PHP Email on the server and I thought I had done that. However they say it's not working. Details are:

PHP 5.4.24 is installed on the server
PHP 5.4.24 (cli) (built: Jan  8 2014 20:26:10)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

SMTP Server is set up and installed using the IIS6 Management Console

PHP is working on the server. Customer is happy that his website calls to PHP are being handled OK. The php.ini variables  tell us that SMTP and smtp_port have the values "localhost" and "25" respectively.

The code he's using:
<?php
error_reporting(E_ALL);
echo 'From ini - SMTP = ' . ini_get('SMTP');
echo ' From ini - port = ' . ini_get('smtp_port');

$to      = 'rks4153@yahoo.co.uk';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

$mres = mail($to, $subject, $message, $headers);

// Was accepted?
if ( $mres == '') {
   echo "<p>Result was empty";
   }
else if ( $mres ){
   echo "<p>Result was $mres</p>";
    }
else {
   echo "<p>Message was not accepted</p>";
    };
?>

mail() Is supposed to return true or false (1 or 0). On his live site on an older 2003 server it works fine but on the newer 2008 server we are having this issue.

I have ini_set() set to OFF on the server and not sure whether I need to re-enable it for this process as generally we have errors OFF globally because there are other websites running on the same 2008 server.

Any help would be gratefully accepted.

Cheers
Chris
0
Comment
Question by:kenwardc
[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
  • 6
  • 6
12 Comments
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 2000 total points
ID: 40619435
Are you sure the SMTP server is running?  Can you telnet to it and get any response.  Is anything or anyone able to send thru the SMTP server?  Have them try with CDO in ASP.
0
 

Author Comment

by:kenwardc
ID: 40620202
Hi Dave

Nice to have you answer questions for me again. Appreciate the response. I'll add the telnet client to the unit and try telnetting to the localhost. I don't ever allow the web servers to receive Email from anywhere other than localhost. Once I've done the test I'll report back.

All the best
Chris
0
 

Author Comment

by:kenwardc
ID: 40620270
Hi Dave

Have checked - the SMTP service was stopped. I added the telnet client feature to the server and managed to telnet to the website. I've now dropped customer an Email asking him to attempt the php mail() thing again and will update you as soon as I hear from him.

Thanks again.
Chris
0
Understanding Web Applications

Without even knowing it, most of us are using web applications on a daily basis. Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We often confuse these web applications tools for websites.  So, what is the difference?

 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 40620298
Good, that explains part of it.
0
 

Author Comment

by:kenwardc
ID: 40620671
Hi Dave

Just had a reply from customer. Not working. Where do I look now please sir?

Cheers
Chris
0
 
LVL 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 2000 total points
ID: 40620737
Re-check the SMTP service, see if it is responding to telnet.  There is a setting that says what IP addresses it can accept email from.  This is normally a no-brainer.
0
 

Author Comment

by:kenwardc
ID: 40620760
Hi Dave

Yes - the SMTP service is running this morning. I had changed the properties on the Generall tab to reflect the IP address of the server and, when I tried to telnet to localhost from the command prompt, it just hung. I changed the IP address to "All unassigned" and I now get the HELO from the server. WIll get customer to try again.

IP addresses that are allowed to send through the SMTP server are only the IP of the server and 127.0.0.1

Cheers
Chris
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 40620768
Those IP addresses should be adequate for the task.  Do you know how to write a CDO ASP page to send email?  Just another way to test the SMTP server.
0
 

Author Comment

by:kenwardc
ID: 40620919
Nossir - I have no idea! ;)
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 40621760
Here is a very simple CDO ASP test program.  Put in your own email addresses.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>ASP Email Test</title>
</head>
<body>
<h2>ASP Email Test Using CDO</h2>
<p>Tested and working on 2012-03-23</p>
<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.To="you@yourplace.com"
myMail.From="me@myplace.com"
myMail.TextBody="This is a message."
myMail.Send
set myMail=nothing
%>

</body>
</html>

Open in new window

0
 

Author Comment

by:kenwardc
ID: 40623152
Thanks Dave. Your checks above were what was needed.
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 40623271
You're welcome, glad to help.
0

Featured Post

Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses

604 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