|
The feedback form in PHP can use the simple inbuilt mail function to send the mail. The sample declaration is as follows : mail($to,$subject,$body,$headers)
However, this forms are insecure and can be used by spammers. So it is highly recommended that you use phpmailer for your forms. phpmailer is an advanced php mail script which establishes smtp connection to relay the form mail. To use phpmailer in your web application you need three pre-requisites viz., class.phpmailer.php class.smtp.php language (folder) This files/folder is recommended to be placed in your domain's www folder. Further you need to include this path in your form to use phpmailer. Kindly refer the sample code (Linux Hosting) shown below: <%
ini_set("include_path", ".");
$mail->PluginDir = "/home/usename/www/";
require("class.phpmailer.php");
$sleeptmp = 0;
// While Loop to send emails
$mybody = "test";
$subject = "test";
$content = " ";
$tmpemail = "whoever@yourdomain.com";
$mail = new phpmailer();
$mail->IsSMTP();
$mail->Mailer = "smtp";
$mail->Host = "127.0.0.1";
$mail->WordWrap = 50;
$mail->IsHTML(true);
$mail->Subject = $subject;
$mail->Body = $mybody;
$mail->AltBody = $content;
$mail->From = "test@test.com";
$mail->FromName = "test sender";
$mail->AddAddress("$tmpemail");
if(!$mail->Send())
{
echo "Message was not sent <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
flush();
%>
|