PHP email
Posted: Tue Jun 12, 2007 2:03 am
I creating a simple feedback form using PHP and HTML.
This executes the mail function with four parameters. It mails to the recipient with a subject, body, and from. If it does not execute, it will print "Message failed!".
What is the code if the user does not execute and will print "Message failed"?
Any helps would be great!
This executes the mail function with four parameters. It mails to the recipient with a subject, body, and from. If it does not execute, it will print "Message failed!".
Code: Select all
<?php
$name = $_POST['name'];
$message = $_POST['comments'];
$from = $_POST['email'];
$mail_sent = $_POST['submit'];
$to = 'paul.crawford@austasiagroup.com';
$subject = 'Kiri Park Enquiry';
$body = "The following enquiry was submitted via the Kiri Park website on ".date('l, d M Y H:i:s') . "\n\nName: ". $name ."\n\nEmail: ". $from ."\n\nComments: ". $message;
$mail_sent = mail( $to, $subject, $body, "From: $from" );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
if ($mail_sent)
{
echo "<div class=\"bodytext\">Thank you, ". $name .". Your mail was sent successfully.</div>";
} else {
echo "<div class=\"bodytext\">Mail failed<!/div>";
}
?>Any helps would be great!