I'm trying to send an email with the message being partly from a variable and partly preset. The email arrives fine when it's either just set as text or just a variable but as soon as I try and use both it never arrives. I've confirmed that all the variables are correct by echoing them at the end but it just never actually arrives in my mailbox.
The code is probably not the best way of doing things since I've not done much coding for a few years but if anyone can tell me why this is happening it would be appreciated:
<?php
$action=$_REQUEST['action'];
if ($action=="") /* display the contact form */
{
?>
<form action="" method="POST" enctype="multipart/form-data" id="emailform">
<input type="hidden" name="action" value="submit">
<label for="contact_name">Name <span>*</span></label>
<input name="name" type="text" value="" size="30"/><br>
<label for="email">Email <span>*</span></label>
<input name="email" type="text" value="" size="30"/><br>
<label for="contact_name">Why can't you pay? <span>*</span></label>
<input name="nopay" type="text" value="" size="30"/><br>
<input class="submit-button" type="submit" value="Send Email" id="submit" name="submit">
</form>
<?php
}
else /* send the submitted data */
{
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$message='Why cant you pay '. $_REQUEST['nopay'];
if (($name=="")||($email=="")||($message==""))
{
echo "All fields are required, please fill <a href=\"\">the form</a> again.";
}
else{
$from="From: $name<$email>\r\nReturn-path: $email";
$subject="Sacred Arts Camp Enquiry";
mail("myemail@gmail.com", $subject, $message, $from);
echo "<p>Thanks for your email!<br/>Someone will pick it up shortly and be in touch to help you out.</p>";
}
}
?>
Thanks for your email!
";` all the time? – Rasclatt Jan 02 '17 at 17:03Someone will pick it up shortly and be in touch to help you out.