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


?>

It always shows 'not successful'.

2 Answers 2

2

Replace

if(mail()){

with

if(mail("[email protected]", $subject,  $message, "From:" . $email)){
Sign up to request clarification or add additional context in comments.

3 Comments

@Ansar, The you are doing your mail() wrong. See the basic example here on PHP Manual. in2.php.net/manual/en/…
I have checked it but it couldn't send emails
Try adding error_reporting(E_ALL); ini_set('display_errors', 1); on top of your PHP script and see what is the issue.
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!

1 Comment

i have tried it in the real server.Then how can i fix this poblem.?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.