php mail function using windows and zend

Discussion on PHP Scripting
no avatar
Posts: 1
Joined: Sun Nov 27, 2011 8:32 pm

php mail function using windows and zend

by kala » Sun Nov 27, 2011 8:43 pm

<title>Send a Mail</title>
<table border="1" bgcolor="green">
<form name="form" method="post" action="mailsend.php">

To: <input type="text" name="to"> <br>

From: <input type="text" name="from"> <br>

Subject: <input type="text" name="subject"> <br>

Message:<br> <textarea name="message" rows=4 cols=25> </textarea> <br>

<input type="submit" value="send">


ini_set("display_errors", "1");error_reporting(E_ALL);

//PHP allows you to send e-mails directly from a script.

$to = $_POST['to'];
$message =stripslashes( $_POST['message']);

//stripslashes() function to remove embedded backslashes in the message string that are
//used as escape characters for embedded apostrophes, quotation marks and such.

$subject = $_POST['subject'];
$from = $_POST['from'];

echo $to;
echo '<br>';
echo $message;
echo '<br>';
echo $subject;
echo '<br>';
echo $from;
echo '<br>';

if ( isset( $to ,$message ,$subject ,$from) ) {

$headers = "From: $from \r\n";

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

if ($ret_value == true ) {
echo 'Success Mail sent!';
else {
echo 'Failed to send Mail !';

else { echo 'Please fill the values ..'; }

//Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.
//It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination.


Above is complete script my error is
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 C:\Program Files (x86)\Zend\Apache2\htdocs\workspace\sendMail\mailsend.php on line 30
Failed to send Mail !

SMTP localhost
smtp_port - 25

no avatar
Posts: 11
Joined: Thu Dec 27, 2012 12:37 pm
Location: VIET NAM


by daniel88 » Wed Jan 30, 2013 10:21 am

well the error is that the mail() isn’t used, if i use a if statement it just goes to the else part.

no avatar
Posts: 1
Joined: Fri Jul 05, 2013 4:46 pm

Re: php mail function using windows and zend

by mr.vinaysheoran » Fri Jul 05, 2013 4:49 pm

It is showing error : Failed to send Mail !
plz help me, i m using IIS7 and PHP Version 5.2.17

Return to PHP Script