<html>
<head>
<title>Send a Mail</title>
</head>
<body>
<center>
<table border="1" bgcolor="green">
<tr>
<td>
<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">
</center>
</td>
</tr>
</body>
</html>
<?php
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
sendmai_from admin@localhost.com[/img]