0

I am facing e-mail sending problem.
e-mail does not send through my e-mail function.

My code is given below:

ini_set("sendmail_from",$_POST['email']);
$to      = 'email@gmail.com';
$subject = $_POST['subject'];
$from    = $_POST['email'];
$message = $_POST['message'];
$message = wordwrap($message, 70);
mail($to,$subject,$message,$from);
Hamad
  • 5,096
  • 13
  • 37
  • 65
Gautam Pal
  • 29
  • 5

2 Answers2

0

You have to setup your SMTP mail server and mention those details in php.ini before executing your script. For further info, please check http://www.phpeasystep.com/phptu/23.html

Thanga
  • 7,811
  • 3
  • 19
  • 38
0

In your code you have to set proper header, you have used $from for header section of mail.

change its value as

$from= 'From: '.$_POST['email']. "\r\n" .
       'Reply-To: '.$_POST['email'] . "\r\n" .
       'X-Mailer: PHP/' . phpversion();

or you can use below solution.

Use PHPMailer API for sending mail. all are inbuilt there. download complete code form below link PHPMailer API

goodluck

Nitesh Pawar
  • 435
  • 2
  • 11