i have a registration form:
<h2>PHP Form Validation Example</h2>
<form method="post" action="sendmail.php">
Name: <input type="text" name="name">
<br><br>
E-mail: <input type="text" name="email">
<br><br>
Website: <input type="text" name="website">
<br><br>
Comment: <textarea name="comment" rows="5" cols="40"></textarea>
<br><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
and i wrote php code where a mail can be send like this:
<?php
$name = $_POST['name'];
$to = $_POST['email'];
$msg = $_POST['comment'];
sendMail($to);
function sendMail($to){
$subject = "Thanks for registring.";
$message = "We are glad that you have posted your problems with us.";
//$header = "From:".$to;
$headers = array(
'From' => $email,
'To' => $to,
'Subject' => $subject
);
$smtp = Mail::factory('smtp', array(
'host' => 'ssl://smtp.live.com',
'port' => '587',
'auth' => true,
'username' => 'USERNAME',
'password' => 'PASSWORD'
));
$pmailing = $smtp->send($to, $headers, $body);
//$retval = mail ($to,$subject,$message,$header);
//$mmsg = 'Receiver: mymail@gmail.com';
if( $pmailing == true )
{
echo "Message sent successfully...";
//$mmsg = "Mail sent.";
}
else
{
echo "Message could not be sent...";
//$mmsg = "Mail not send.";
echo'<script> window.location="re_enter.html"; </script> ';
}
}
?>
it is showing "Mail" is not acceptable. So suggest me, i have edited my code with your code which you have shared. Do i require to add any library or any as such to execute this SMTP code.