This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

No emails sent via PHP Mail() function
#1
No emails sent via PHP Mail() function
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:

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.
Reply
Thanks given by:


Messages In This Thread
No emails sent via PHP Mail() function - by kwongger - 04-11-2016, 09:59 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Why can i not send emails from my site phabeon8 3 6 ,592 04-20-2021, 06:29 AM
Last Post: sparkrack
External mail client cannot connect to server iraqiboy90 2 6 ,304 02-28-2021, 11:34 AM
Last Post: iraqiboy90
Postfix mail.log to database stikekar 2 7 ,283 03-02-2019, 01:22 AM
Last Post: TGates

Forum Jump:


Users browsing this thread: 1 Guest(s)