1

Iam new to php coding. I have tried to send an email from an html page.It is redirected to my 'email.php', but it doesn,t send email.My code is here..

<?php

//if "email" is filled out, send email

  //send email
  $name = $_REQUEST['your-name'] ;
   $email = $_REQUEST['your-email'] ;
   $company= $_REQUEST['company'] ;
    $website= $_REQUEST['website'] ;
  $message=$name."<br>".$company."<br>".$website."<br>".$email;
  $subject = 'Hai there' ;
  $message = $_REQUEST['message'] ;
  mail("sample@gmail.com", $subject,
  $message, "From:" . $email);
  if(mail()){
  echo 'successfull';
  }
  else{
   echo 'not successfull';
  }


?>

It always shows 'not successful'.

Albzi
  • 15,431
  • 6
  • 46
  • 63
Ansar
  • 364
  • 3
  • 16

2 Answers2

2

Replace

if(mail()){

with

if(mail("sample@gmail.com", $subject,  $message, "From:" . $email)){
Albzi
  • 15,431
  • 6
  • 46
  • 63
Shankar Narayana Damodaran
  • 68,075
  • 43
  • 96
  • 126
0

You will probably have to check your php.ini config, have a look to this comment:

https://stackoverflow.com/a/8804035/2910910

And this comment:

http://www.php.net/manual/en/ref.mail.php#77499

Good luck!

Community
  • 1
  • 1
dcapilla
  • 171
  • 6