Reputation: 122
I just need that when form is submitted mail is send to recipient. My form submitted with Response code of 200k but mail is not Delivered. I have installed sendmail.
sendmail.php code:
if(isset($_POST['submit']))
{
$subject = $_POST['subject'];
$to = "[email protected]";
$from = $_POST['email'];
//data
$msg = "NAME: " .$_POST['name'] ."<br>\n";
$msg .= "EMAIL: " .$_POST['email'] ."<br>\n";
$msg .= "WEBSITE: " .$_POST['web'] ."<br>\n";
$msg .= "COMMENTS: " .$_POST['comments'] ."<br>\n";
//Headers
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=UTF-8\r\n";
$headers .= "From: <".$from. ">" ;
mail ($to, $subject,$msg, $headers);
echo "sent";
}
installed mail server in php.ini file:
[mail function]
; Setup for Linux systems
sendmail_path = /usr/sbin/sendmail -t
sendmail_from = [email protected]
Upvotes: 0
Views: 140
Reputation: 1981
mail ($to, $subject,$msg, $headers);
echo "sent";
instead of this ,first check if the mail is sent
$mail=mail ($to, $subject,$msg, $headers);
if($mail){
echo "sent";
}else{
echo "failed.";
}
By this actually u can know whether your mail function in working or not
if it is not working.the problem can be with SMTP settings in your localhost
enable errors in php if not enabled using
ini_set('display_errors',1);
Upvotes: 2
Reputation: 2238
Have you checked mail settings in you php.ini ?
If you don't have access to the PHP settings you can use PHP Mailer to deliver emails with your own parameters
Upvotes: 0