We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,548 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

PHP Mail function not working in Windows Server

I have trid the testing script as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</HEAD>
<BODY><?php
$headers = 'From:info@mydomain.com'. "\r\n" .
    'Reply-To: [email]info@mydomain.com[/email]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();
$ret=mail('user@customer.com', 'subject', 'this is the content',$headers,'-finfo@mydomain.com');
echo "<BR/>mail() returned: " . ($ret? "TRUE" : "FALSE") . "<BR/>";
?>
</BODY>
</HTML>

This script works fine at another Linux server. But in the windows server i am using, the result is:

mail() returned: TRUE

but sending no mail at all.

The server setting is like:

Directive	      Local Value	               Master Value
sendmail_from	[email]me@localhost.com[/email]	[email]me@localhost.com[/email]
sendmail_path	     no value	                       no value
SMTP	              213.200.51.11	         213.200.51.11
smtp_port	             25	                                25

I can't locate the problem cos I don't have access to server config...
Someone please tell me where the problem is..Thanks

7
Contributors
7
Replies
4 Years
Discussion Span
6 Months Ago
Last Updated
11
Views
Question
Answered
MeixiuLin
Newbie Poster
2 posts since Jun 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

I found the solution by myself:
put

<?php
ini_set("sendmail_from", "info@mydomain.com");?>

at the beginng of mail testing file.....

MeixiuLin
Newbie Poster
2 posts since Jun 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Question Self-Answered as of 5 Years Ago

For all of the people struggling with getting PHP mail() sending to some, but not all, recipients...look no farther. Your solution has been posted here.

It appears PHP-generated emails don't play nice on Windows mail servers. So, when your mail goes to anyone who uses a Windows mail server (Comcast, gmail, and maybe aol), the recipients won't get it. UNLESS YOU ADD THE LINE:

<?

phpini_set("sendmail_from", "info@mydomain.com");

?>

This is a miracle! I have been scouring the internet high and low, and this is the ONLY thing that has worked! Now I can move on to the rest of the project!

Thank you, MeixiuLin! Thank you, thank you.

songjockey
Newbie Poster
1 post since Aug 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Guys, i love you.

clouding.it
Newbie Poster
1 post since Jun 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Excellent Solution by MeixiuLin, its working , keep it up :)

mayankbpandya
Newbie Poster
1 post since Jul 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

hi sir, i m also facing php email setting problem it show that mail() returned: TRUE, but its not sending mail, pls help me

ganeshshirsat
Newbie Poster
1 post since Aug 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

I have a problem sending mails from my Windows Server. I am using IIS 7 and PHP 5.3.18
I would like to know if I need to configure my PHP.ini and how do I have to do it?
Thanks a lot for your help.

hexodo
Newbie Poster
1 post since Dec 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

This post is dead, dont bring it back. Besides, dont hijack peoples post.

fobos
Posting Whiz
345 posts since Feb 2009
Reputation Points: 29
Solved Threads: 67
Skill Endorsements: 3

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page generated in 0.0778 seconds using 2.66MB