0

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 = "abc@gmail.com";
    $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 = me@myserver.com 
user3306026
  • 122
  • 3
  • 16

2 Answers2

2
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);
a4arpan
  • 1,828
  • 2
  • 24
  • 41
0

Have you checked mail settings in you php.ini ?

PHP Runtime Configuration

If you don't have access to the PHP settings you can use PHP Mailer to deliver emails with your own parameters

cardeol
  • 2,218
  • 17
  • 25