I am building a webpage with a contact form that sends an email to me via the Mail() php function.
I can send/receive emails fine via Roundcube, but none are sent via this method.
Here is my script:
contact page:
php page:
Any ideas? I'm not receiving any emails whether I specify the 'to' email as my personal email (hosted on protomail) or an email I have on round cube.
I can send/receive emails fine via Roundcube, but none are sent via this method.
Here is my script:
contact page:
Code:
<form action="mail_handler.php" method="post" class="col s12">
<div class="row">
<div class="input-field col s6">
<input id="name" type="text" class="validate">
<label for="name">Name</label>
</div>
</div>
<div class="row">
<div class="input-field col s6">
<input id="email" type="email" class="validate">
<label for="email">Email Address</label>
</div>
<div class="input-field col s6">
<input id="telephone" type="tel" class="validate">
<label for="telephone">Telephone Number</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<textarea id="message" class="materialize-textarea"></textarea>
<label for="message">Breif description of work to be done.</label>
</div>
</div>
<div class="row">
<div class="input-field col s6">
<select>
<option value="" disabled selected>Choose the best way to contact you</option>
<option value="email">Email</option>
<option value="telephone">Telephone</option>
</select>
<label>Best Contact Method</label>
</div>
<div class="input-field col s6">
<button class="btn waves-effect waves-light" type="submit" name="action">Submit
<i class="material-icons right">send</i>
</button>
</div>
</div>
</form>
php page:
Code:
<?php
if(isset($_POST['submit'])){
$to = "myemailishere"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
$name = $_POST['name'];
$telephone = $_POST['telephone'];
$contactmethod = $_POST['contactmethod'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = $name . " wrote the following:" . "\n\n" . $_POST['message'];
$message2 = "Here is a copy of your message " . $name . "\n\n" . $_POST['message'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$telephone,$contactmethod,$headers);
mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
echo "Mail Sent. Thank you " . $name . ", we will contact you shortly.";
// You can also use header('Location: thank_you.php'); to redirect to another page.
// You cannot use header and echo together. It's one or the other.
}
?>
Any ideas? I'm not receiving any emails whether I specify the 'to' email as my personal email (hosted on protomail) or an email I have on round cube.