简体   繁体   中英

PHP Contact Form not triggering email

The following php contact form is not working for me. Could you please help me to fix the error. After submitting the form, there is no email triggered. I am not sure, what is wrong. The following php contact form is not working for me. Could you please help me to fix the error.

 <?php ob_start(); if(isset($_POST['your-name'])){ $to = "info@freshpotsolutions.com"; $from = $_POST['your-name'].'<'.$_POST["email"].'>'; $subject = "Enquiry Form"; $message= '<html> <body bgcolor="#EBEBEB" style="font-family:Roboto,Arial,Helvetica,sans-serif;"> <table cellpadding="3" cellspacing="2"> <tr> <td colspan="3" align="left"><h3>Booker Information</h3></td> </tr> <tr> <td colspan="3"> &nbsp;</td> </tr> <tr> <td width="160" > Name</td><td width="15">:</td><td>'.$_POST["your-name"].'</td> </tr> <tr> <td>Email</td><td>:</td><td>'.$_POST["your-email"].'</td> </tr> <tr> <td>Website</td><td>:</td><td>'.$_POST["tel-681"].'</td> </tr> <tr> <td>Message</td><td>:</td><td>'.$_POST["your-message"].'</td> </tr> </table> </body> </html>'; // $headers = "MIME-Version:1.0 \\r\\n"; $headers .= "Content-type:text/html; charset=iso-8859-1\\r\\n"; $headers .= "From: $from\\r\\n"; if(mail($to, $subject, $message, $headers)){ //session_destroy(); header('Location:enquiry.html?message=success'); } } 
 <form action="messageForm.php" class="wpcf7-form" method="post" novalidate> <p><span class="wpcf7-form-control-wrap your-name"><input class= "wpcf7-form-control wpcf7-text wpcf7-validates-as-required floatlabel" name="your-name" placeholder="Name" size="40" type="text"></span> </p> <p><span class="wpcf7-form-control-wrap your-email"><input class= "wpcf7-form-control wpcf7-text wpcf7-email wpcf7-validates-as-required wpcf7-validates-as-email floatlabel" name="your-email" placeholder="Email" size="40" type="email"></span> </p> <p><span class="wpcf7-form-control-wrap tel-681"><input class= "wpcf7-form-control wpcf7-text wpcf7-tel wpcf7-validates-as-tel floatlabel" name="tel-681" placeholder="Phone" size="40" type="tel"></span> </p> <p><span class="wpcf7-form-control-wrap your-message"> <textarea class="wpcf7-form-control wpcf7-textarea floatlabel" cols= "40" name="your-message" placeholder="Message" rows="10"> </textarea></span> </p> <p data-scrollreveal="enter bottom over 1s after 1s and move 50px"> <input class="wpcf7-form-control wpcf7-submit get-in-touch-submit-btn" type="submit" value="Send"> </p> <div class="wpcf7-response-output wpcf7-display-none"> </div> </form> 

change this line

$from = $_POST['your-name'].'<'.$_POST["email"].'>';

to

$from = $_POST['your-name'].'<'.$_POST["your-email"].'>';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM