Today I built a simple email class to send out emails.
/**
* Description of Email Class
*
* @author Joseph Tveter
*/
class Email
{
public function __construct()
{}
public function Email($to, $subject, $message, $from = 'admin@yoursite.com', $cc = '', $bcc = '', $MIME = 'MIME-Version: 1.0', $Content = 'Content-type: text/html; charset=iso-8859-1', $Reply = "")
{
$headers = $MIME . "\r\n";
$headers .= $Content . "\r\n";
$headers .= 'From: '. $from . "\r\n";
if($cc != "")
{
$headers .= 'Cc: '. $cc . "\r\n";
}
if($bcc != "")
{
$headers .= 'Bcc: '. $bcc . "\r\n";
}
if($Reply != "")
{
$headers .= 'Reply-To: '. $Reply . "\r\n";
}
if (mail($to, $subject, $message, $headers) == false)
{
//send email on fail
$s = "Email Failed to ".$to;
$m = $s.":"."\r\n".$message;
$h = $MIME . "\r\n";
$h .= $Content . "\r\n";
$h .= 'From:'. '$from' . "\r\n";
mail('you@yoursite.com', $s, $m, $h);
}
}
}
No comments:
Post a Comment