Sample Code : Sending mail via PHP
You can use PHPMailer to send mails via PHP. To use this open source object you need to download two php class files which can be found here and upload them into your project include folder first.
Here's a complex example of sending an HTML email with SMTP authentication and attachments
$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->Host = "mail.yourdomain.com"; // SMTP server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "you@yourdomain.com"; // SMTP username
$mail->Password = "youremailpassword"; // SMTP password
$mail->From = "you@yourdomain.com";
$mail->FromName = "Your Name";
$mail->AddAddress("somebody@somedomain.com","Somebody name");
$mail->AddReplyTo("You@yourdomain.com","Your Name");
$mail->WordWrap = 50; // set word wrap
$mail->AddAttachment("Path to Attachment "); // attachment
$mail->IsHTML(true); // send as HTML
$mail->Subject = "Here is the subject";
$mail->Body = "This is the HTML body";
$mail->AltBody = "This is the text-only body";
if(!$mail->Send())
{
echo "Message was not sent";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>