ID: 15373 Comment by: dallas_thompson2001 at yahoo dot com Reported By: alonso at admintek dot net Status: No Feedback Bug Type: Mail related Operating System: win2000 PHP Version: 4.2.1 Assigned To: mfischer New Comment:
i am having a problem like this and am so lost, i cant send mail from the server but it wont let mail be sent from the website and they tell me it is a problem with the PHP can some look and tell me what i have dont wrong and how to make it work. <?php //-------------------------------------------------------------------- User Area $ToEmail = "mail.thirdstreetdesignstudio.com"; $ToName = "Dallas Thompson"; $ToSubject = "Thanks for your email. One of our consultants will respond to your request shortly. "; //-------------------------------------------------------------------- //-------------------------------------------------------------------- Prohibited Area No Changes $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: '.$_POST['_namex'].' <'.$_POST['_emailx'].'>' . "\r\n"; $Message = "Sender Name:".$_POST['_namex']."<br/><br/>Sender Email:".$_POST['_emailx']."<br/><br/>Sender Phone:".$_POST['_phonex']."<br/><br/>Message:".$_POST['_commx']; if($_REQUEST['_emailx']!=""){ mail($ToName." <".$ToEmail.">",$ToSubject, $Message, $headers); } echo "_root.Status=success"; ?> Previous Comments: ------------------------------------------------------------------------ [2009-07-07 06:28:32] lakshmi at nace dot co dot in OS Windows XP home Edition, Redhat Linux 5 Server Apache 2.2.11 PHP 5.2.9-2 <?php $Name = "sam"; //senders name $email = "a...@example.com"; //senders e-mail adress $recipient = "a...@example.com"; //recipient $mail_body = "The text for the mail..."; //mail body $subject = "Subject for reviever"; //subject $header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields if(mail($recipient, $subject, $mail_body, $header)) //mail command :) echo "mail sent"; else echo "mail not sent"; ?> I get this: Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set(). I tried by changing the php.ini and it does not work. I hope you can help me Request: This is the third time I am posting this query to PHP Bugs, But Still I haven't get any Proper Solutions. Thanks a lot ------------------------------------------------------------------------ [2009-06-18 16:33:00] omgmain at gmail dot com Hi, I am also having the same problem with this. I am using Mac OS X, and it doesn't seem to be sending. Script: <?php if(!mail($_POST['email'],"blabla","$text_body")){ echo("Unable to send verification email."); }else{ echo("Sent verification email."); } ?> Mail seems to always return true. ------------------------------------------------------------------------ [2009-03-27 11:37:05] real_ganesh at yahoo dot co dot in Am php to send E-mail,but will be Error. Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in -----code---- Contact.html ----------- <html> <head> <meta http-equiv="Content-Type" content="text/html;>charset=iso-8859-1" /> <title>Cultuzz Digital Media GmbH - Contact</title> </head> <center> <body bgcolor="FF9900"> <div class="componentheading"><h1>Contact Us</h1></div> <table width="50%" cellpadding="0" cellspacing="0" border="0" class="contentpane"> <!-- <form action="../Contactus/Contact1.php" method="post"> --> <form action="../Contactus/Mailto.php" method="post"> <table> <!-- <body background="FF9900"> --> <tr> <td align="right" class="w"><b>Enter your To Address:</b></font></h3></td> <td><input type="text" name="toAddr" size="25"></td> </tr> <tr> <td align="right" class="w"><b>E-mail your From Address:</b></font></td> <td><input type="text" name="fromAddr" size="25"></td> </tr> <tr> <td align="right" class="w"><b>Enter your Password:</b></font></td> <td><input type="password" name="toPass" size="25"></td> </tr> <tr> <td align="right" class="w"><b>Enter your Subject:</b></font></td> <td> <input type = "text" name="subject" size="25"> </td> </tr> <tr> <td align="right" class="w"><b>Enter your Content:</b></font></td> <td> <textarea name="content" size="20" cols="25" rows="7"></textarea> </td> </tr> <tr> <td> <center> <input type="submit" name="submit" value="Submit"> </center> </td>                                       </tr> </body> </table> </form> </body> </center> </html> <!-- <textarea name="content" size="20" cols="25" rows="7" value="<?php echo $_POST['content']; ?>"></textarea> --> --------------------- mailto.php ---------------------- <!-- Mail to multiple recipients --> <?php /*$headers = "From:sen...@java2s.com\r\n"; $recipients = "t...@java.com,a...@java2s.com"; mail($recipients, "This is the subject","This is the mail body", $headers); */ /* $SMTP = 10.200.10.7 $smtp_port = 25*/ $toAddr = "toAddr"; $fromAddr = "fromAddr"; $toPass = "toPass"; $subject = "subject"; $content = "content"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: sk.gane...@yahoo.co.in\r\n' . 'Reply-To: real_gan...@yahoo.co.in\r\n'; //u can add //$headers .= 'CC : t...@test.com\r\n'; //$headers .= 'BCC : t...@test.com\r\n'; mail($toAddr, $fromAddr, $toPass, $subject,$content); echo "This is To---------------->: $toAddr <br/>"; echo "This is From----------->: $fromAddr <br/></n>"; echo "This is Password----------->: $toPass <br/>"; echo "This is Subject----------->: $subject <br/></n>"; echo "This is Content----------->: $content <br/></n>"; echo "This is Headers----------->: $headers <br/></n>"; ?> ------------------------------------------------------------------------ [2009-03-19 00:47:46] rmsadik dot ece at gmail dot com i have problem sending email using mail(). it was working couple of weeks before but now on its not working ...i dont know whats the problem and here is the code if ($db_result) { echo "Successful"; $to = $email; $from = "msa...@gmail.com"; $subject = "Password Request From"; $message = "PLEASE DO NOT REPLY TO THIS EMAIL\n\n"; $message .= "unless others can read your email.\n\n\n"; $message .= "Password: ".$password; $headers = "From: ".$from; // Set the name of the server for mail processing. This should be handled at the server level but the following // statement allows dynamic setting of the SMPT server for testing purposes. ini_set("SMTP","mail.sunet.com.au"); // Attempt to send the mail message. //$db_result = mail($to,$subject,$message,$headers); mail($to,$subject,$message,$headers); } ------------------------------------------------------------------------ [2008-11-25 17:17:49] jeff at jouster dot org I have this same problem. I have Windows Server 2003 SP2 IIS 6. PHP6-dev (also same problem with 5.4) Port 25 is open and I can telnet to the server from my home machine completely outside the network and manually send an email. So I know that SMTP is not the problem and relaying is not a problem. Here's my script: <?php $success = mail("m...@address.tld", "subject", "body", "From: My Name <m...@address.tld>"); echo ($success); if ($success) { echo (" success!"); } else { echo (" problem..."); } ?> When I run this test script I see: 1 success! However I never get an email. I have php.ini set to log errors (have also tried display errors) and there is never any errors logged or displayed. php.ini SMTP section: [mail function] ; For Win32 only. SMTP = localhost smtp_port = 25 ; For Win32 only. sendmail_from = m...@address.tld phpinfo() shows all of this information properly (only after I moved the .ini file into the PHP install directory. I have PHPRC environment variable set to PHP install directory and have added same directory to my PATH env var. Mail was successfully being sent until another issue caused me to uninstall and reinstall the SMTP Service portion of IIS. I see no solutions or cause to this problem in this thread. Any new news? Original issue was posted 6 years ago... I can't believe this is still cropping up for people. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/15373 -- Edit this bug report at http://bugs.php.net/?id=15373&edit=1