This is the first time I am using the mail function. I tried to send a mail using this and the code tells me it's "successfully sent", but I didn't receive any mail. I'm confused reading lots of articles on this. Please help me.
<?php
if(isset($_POST['author'])&& isset($_POST['subject'])&& isset($_POST['text'])) {
//Email
$email_to = "[email protected]";
$email_subject = "Query From HYPERMARKETS";
$name = $_POST['author']; // required
$sub = $_POST['subject']; // required
$comments = $_POST['text']; // required
echo "POST:".$name.$sub.$comments;
$error_message = "";
$string_exp = "^[a-z .'-]+$";
if(!strcmp($string_exp,$name)) {
$error_message .= 'The Name you entered does not appear to be valid.<br />';
}
if(strlen($comments) < 5) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
echo ("<center><table border=1 cellspacing=5 cellpadding=5><tr><th>$error_message</th></tr></table></center>");
}
$email_message = "Form details below.
";
$email_message .= "Name: ".$name."
";
$email_message .= "Subject: ".$sub."
";
$email_message .= "Comments: ".$comments."
";
// create email headers
$headers = "From: [email protected]
Reply-To: [email protected]
" ;
if(@mail($email_to, $email_subject, $email_message, $headers))
echo "<center><table border=1 cellspacing=5 cellpadding=5><tr><th>MESSAGE SENT SUCCESSFULLY</th></tr></table></center>";
else
echo "<center><table border=1 cellspacing=5 cellpadding=5><tr><th>MESSAGE NOT SENT</th></tr></table></center>";
}
else
echo ("<center><table border=1 cellspacing=5 cellpadding=5><tr><th>FILL ALL THE FIELDS..!!</th></tr></table></center>");
?>
Hey I have configured my php.ini file as
[mail function]
sendmail_from = postmaster@localhost
SMTP = localhost
smtp_port = 25
sendmail_path = ""C:xamppsendmailsendmail.exe" -t"
sendmail_path = "C:xamppmailtodiskmailtodisk.exe"
It still doesnt work.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…