Sending Emails in PHP Example
Tuesday, August 10th, 2010With the help of smartwebby.com, we are able to show you the basic example when sending an email in PHP.
Syntax: mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]] )
Ex:
Sample PHP Code:
<?php
//Check whether the submission is made
if(isset($hidSubmit)){//Declarate the necessary variables
$mail_to=$txtEmailto;
$mail_from=$txtEmailfrm;
$mail_sub=$txtSub;
$mail_mesg=$txtMsg;//Check for success/failure of delivery
if(mail($mail_to,$mail_sub,$mail_mesg,”From:$mail_from/r/nReply-to:$mail_from”))
echo “<span class=’red’>E-mail has been sent successfully from $mail_sub to $mail_to</span>”;
else
echo “<span class=’red’>Failed to send the E-mail from $mail_sub to $mail_to</span>”;
}
?>