1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| class T_Email extends T_Object
{
private $headers;
private $boundary;
private $subject;
private $message;
public function __construct( $subject , $message )
{
parent::__construct( );
$this->subject = "=?" . T_Kernel::EMAIL_CHARSET . "?B?" . base64_encode($subject) . "?=";
$this->boundary = md5(uniqid(mt_rand()));
$this->headers = "MIME-Version: 1.0\r\n"
. "Content-Type: multipart/alternative; boundary=\"" . $this->boundary . "\"\r\n";
$this->message = "MIME-Version: 1.0\r\n"
. "Content-Type: multipart/alternative; boundary=\"" . $this->boundary . "\"\r\n\r\n"
. "This is a multi-part message in MIME format.\r\n\r\n"
. "--" . $this->boundary . "\r\n"
. "Content-Type: text/plain; charset=\"" . T_Kernel::EMAIL_CHARSET . "\"\r\n"
. "Content-Transfer-Encoding: quoted-printable\r\n\r\n"
. strip_tags($message) . "\r\n\r\n"
. "--" . $this->boundary . "\r\n"
. "Content-Type: text/html; charset=\"" . T_Kernel::EMAIL_CHARSET . "\"\r\n"
. "Content-Transfer-Encoding: quoted-printable\n\n"
. $message . "\r\n\r\n"
. "--" . $this->boundary . "--\r\n";
}
public function send( $to , $from = null , $replyTo = null )
{
if ( ! is_null( $from ) )
{
$this->headers .= "From: " . $from . "\r\n";
}
if ( ! is_null( $replyTo ) )
{
$this->headers .= "Reply-To: " . $replyTo . "\r\n";
}
return mail( $to , $this->subject , $this->message , $this->headers );
}
} |