mailPlease help. My PHP mailer is not working that I host on Go Daddy. Any idea why the email won't send?
<?php
session_start();
$contact=$_POST['contact'];
$phone=$_POST['telephone'];
$email=$_POST['email'];
$msg=$_POST['message'];
$to="webform@xxx.com";
$subject="Contact Form";
$from=$email;
$message .= '<table border="1px" width="50%" style="border:1px black solid;margin:0px auto">';
$message .= '<tr><th colspan="2" style="text-align:center">Contacts Information</th></tr>';
$message .= '<tr><td>Name :- </td><td>'.$contact.'</td></tr>';
$message .='<tr> <td>Phone No. :- </td><td>'.$phone.'</td></tr>';
$message .= "<tr><td>Email :- </td><td>" . $email . "</td></tr>";
$message .= "<tr><td>Message :- </td><td>" . $msg. "</td></tr>";
$message .= "</table>";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= 'From: ' . $from . "\r\n";
mail($to, $subject, $message, $headers);
header("Location: sent.html");
Their is a typo error in your code.
$contact=$_POST['contact'];
$phone=$_POST['telephone'];
$email=$_POST['email'];
$msg=$_POST['message'];
$to="webform@xxx.com";
$subject="Contact Form";
$from=$enm; //this should be $from=$email
CAUTION: ur not validating user input. Pls do validate them server side to avoid errors and attack attempts.
If u have any other error pls state it clearly.
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.