Ansar
Ansar

Reputation: 364

PHP not sending email

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("[email protected]", $subject,
  $message, "From:" . $email);
  if(mail()){
  echo 'successfull';
  }
  else{
   echo 'not successfull';
  }


?>

It always shows 'not successful'.

Upvotes: 1

Views: 117

Answers (2)

dcapilla
dcapilla

Reputation: 191

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!

Upvotes: 0

Replace

if(mail()){

with

if(mail("[email protected]", $subject,  $message, "From:" . $email)){

Upvotes: 2

Related Questions