1,105,312 Community Members

PHP Mail function not working in Windows Server

Member Avatar
MeixiuLin
Newbie Poster
2 posts since Jun 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
MeixiuLin
Newbie Poster
2 posts since Jun 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
1
 

I found the solution by myself:
put

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

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

Question Self-Answered as of 5 Years Ago
Member Avatar
songjockey
Newbie Poster
1 post since Aug 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
1
 

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.

Member Avatar
clouding.it
Newbie Poster
1 post since Jun 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Guys, i love you.

Member Avatar
mayankbpandya
Newbie Poster
1 post since Jul 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
ganeshshirsat
Newbie Poster
1 post since Aug 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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

Member Avatar
hexodo
Newbie Poster
1 post since Dec 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
fobos
Posting Whiz
351 posts since Feb 2009
Reputation Points: 19 [?]
Q&As Helped to Solve: 68 [?]
Skill Endorsements: 3 [?]
 
0
 

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

Member Avatar
anjrim
Newbie Poster
2 posts since Jul 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

i need a send email code for windows server.Help me as soon as possible.
Thnx

Member Avatar
anjrim
Newbie Poster
2 posts since Jul 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Above suggestion is not working with my code and windows server.plz give me actual solution.

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article