I have created PHP app and deployed using heroku. In the app, I have contact form to send mails to my gmail account. To implement this, I have written the following PHP code
<?php
$to = "to@gmail.com";
$subject = "This is subject";
$message = "This is simple text message.";
$header = "From:from@yantranet.com \r\n";
$retval = mail ($to,$subject,$message,$header);
if( $retval == true ){
echo "Message sent successfully...";
}else{
echo "Message could not be sent...";
}
?>
My php script is executing. But it is not sending mail instead it is showing up Message could not be sent
. Can any one help to implement contact form using PHP?