Reputation: 11
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
Upvotes: 1
Views: 259
Reputation: 683
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!";
}
Upvotes: 1
Reputation: 786
I'm not familiar with sendmail, but I notice 1 thing:
"$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!
Upvotes: 2