1

Im trying to get my php mailer embedded on my html page, I get no syntax errors in Dreamweaver but sendmail (http://glob.com.au/sendmail/) keeps giving me this error message "Syntax error in arguments " Im hoping you can help me nail the issue

My PHP mailer:

//Email information
$admin_email = "------------ Secret";
$email = $_REQUEST['email'];
$subject = $_REQUEST['subject'];
$comment = $_REQUEST['comment'];

//send email
mail($admin_email, "$subject", $comment, "From:" . $email);

//Email response
echo "Thank you for contacting us!";
}

//if "email" variable is not filled out, display the form
else  {
?>

Here is the relevant page code

<?php
//if "email" variable is filled out, send email
  if (isset($_REQUEST['email']))  {

  //Email information
  $admin_email = "[email protected]";
  $email = $_REQUEST['email'];
  $subject = $_REQUEST['subject'];
  $comment = $_REQUEST['comment'];

  //send email
  mail($admin_email, "$subject", $comment, "From:" . $email);

  //Email response
  echo "Thank you for contacting us!";
  }

  //if "email" variable is not filled out, display the form
  else  {
?>
<html>
<head>
</head>
<body>
  <div id ="Email">         
    <form method="post"><br />
      <h3><b>send us a message</b></h3>
      <span>Any further questions or concerns? Send us an email!</span><br>
         Email: <input name="email" type="text" /><br />
         Subject: <input name="subject" type="text" /><br />
         Message:<br />
          <textarea name="comment" rows="15" cols="40"></textarea><br />
      <input type="submit" value="Submit" />
    </form>
  </div>
<?php
  }
?>

Any help you can give me would be much appreciated I am new to php but still trying to learn

Basically I just want to make a mail form built onto an html page

5
  • is that a PHP error, or an error from whatever smtp client php is trying to invoke to actually do the sending? Commented Nov 14, 2014 at 18:40
  • 2
    Try removing the quotes: "$subject" => $subject Commented Nov 14, 2014 at 18:41
  • Read up on php.net/manual/en/function.mail.php - That's what the manual was put together for ;) Just like the 'ol VCR's. Never could quite figure out how to set the time without one. Commented Nov 14, 2014 at 18:44
  • 1
    You do realize that you're only checking if (isset($_REQUEST['email'])) - If someone doesn't fill out the subject field, mail may very well be rejected or sent to Spam. Commented Nov 14, 2014 at 18:52
  • There's nothing wrong with your code, not while I tested it. Check your mail logs, and add error reporting to the top of your file(s) right after your opening <?php tag error_reporting(E_ALL); ini_set('display_errors', 1); see if it yields anything. Commented Nov 14, 2014 at 18:59

2 Answers 2

2

I'm not familiar with sendmail, but I notice 1 thing:

  1. "$subject" needs to be just $subject . You are capturing that variable for a reason. So turning it into a string of "$subject" makes no sense to me.

Hope this helps!

Sign up to request clarification or add additional context in comments.

3 Comments

There is no need for the action attribute, since the mailing script is in the same page. With no action attribute, the form submits to the current page.
Ah! Ok. Good point. Sorry. My php foo is rusty. Will edit that one out.
"$string" and $string evaluate to the same thing because of PHP string handling interpolation.
1

Try this code:

   //if "email" variable is filled out, send email
    if (isset($_REQUEST['email']))  {
     //Email information
     $admin_email = "[email protected]";
     $email = $_REQUEST['email'];
     $subject = $_REQUEST['subject'];
     $comment = $_REQUEST['comment'];
     $headers = "From: $email" . "\r\n";

     mail($admin_email, $subject, $comment, $headers);
     //Email response
     echo "Thank you for contacting us!";
    }

Comments

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.