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!