ID:               15373
 Comment by:       ilmi_bunjaku 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 have e problem, I can not sent email with PHP
the server is wampserver, OS windows xp 
I have one error as you can see:

Warning: mail() [function.mail]: Failed to connect to mailserver at 
"localhost" port 25, verify your "SMTP" and "smtp_port" setting in 
php.ini or use ini_set() in D:\Webroot\PHP\dergo email.php on line 16


the cod which I write is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-
1" />
<title>Dergo email</title>

</head>

<body>
<?php
$to = "em...@yahoo.com";
$subject = "Test mail";
$message = "hello! .";
$from = "em...@hotmail.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail sent.";
?>
</body>
</html>

best regards,
ILA


Previous Comments:
------------------------------------------------------------------------

[2009-08-25 01:13:40] dallas_thompson2001 at yahoo dot com

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";


?>

------------------------------------------------------------------------

[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>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
                                
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
                        </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);
        }

------------------------------------------------------------------------

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

Reply via email to