Zeile 6 | Zeile 6 |
---|
* Website: http://www.mybboard.net * License: http://www.mybboard.net/about/license *
|
* Website: http://www.mybboard.net * License: http://www.mybboard.net/about/license *
|
* $Id: class_mailhandler.php 3855 2008-05-20 14:08:16Z Tikitiki $
| * $Id: class_mailhandler.php 5379 2011-02-21 11:06:42Z Tomm $
|
*/
/**
| */
/**
|
Zeile 34 | Zeile 34 |
---|
* @var string */ var $from;
|
* @var string */ var $from;
|
| /** * Who the email should return to. * * @var string */ var $return_email;
|
/** * The subject of mail.
|
/** * The subject of mail.
|
*
| *
|
* @var string */ var $subject;
|
* @var string */ var $subject;
|
/** * The message of the mail.
| /** * The unaltered subject of mail. * * @var string */ var $orig_subject;
/** * The message of the mail.
|
* * @var string */ var $message;
|
* * @var string */ var $message;
|
/**
| /**
|
* The headers of the mail.
|
* The headers of the mail.
|
* * @var string */
| * * @var string */
|
var $headers;
/**
| var $headers;
/**
|
Zeile 63 | Zeile 77 |
---|
* @default utf-8 */ var $charset = "utf-8";
|
* @default utf-8 */ var $charset = "utf-8";
|
/**
| /**
|
* The currently used delimiter new lines.
|
* The currently used delimiter new lines.
|
*
| *
|
* @var string. */ var $delimiter = "\r\n";
|
* @var string. */ var $delimiter = "\r\n";
|
|
|
/** * How it should parse the email (HTML or plain text?) * * @var array */ var $parse_format = 'text';
|
/** * How it should parse the email (HTML or plain text?) * * @var array */ var $parse_format = 'text';
|
|
|
/** * Builds the whole mail. * To be used by the different email classes later.
| /** * Builds the whole mail. * To be used by the different email classes later.
|
Zeile 90 | Zeile 104 |
---|
* @param string headers of email. * @param string format of the email (HTML, plain text, or both?). * @param string plain text version of the email.
|
* @param string headers of email. * @param string format of the email (HTML, plain text, or both?). * @param string plain text version of the email.
|
| * @param string the return email address.
|
*/
|
*/
|
function build_message($to, $subject, $message, $from="", $charset="", $headers="", $format="text", $message_text="")
| function build_message($to, $subject, $message, $from="", $charset="", $headers="", $format="text", $message_text="", $return_email="")
|
{ global $parser, $lang, $mybb;
|
{ global $parser, $lang, $mybb;
|
$this->headers = preg_replace("#(\r\n|\r|\n)#s", $this->delimiter, $this->headers); $this->message = preg_replace("#(\r\n|\r|\n)#s", $this->delimiter, $this->message);
$this->headers = $headers;
| $this->message = ''; $this->headers = $headers;
|
if($from) { $this->from = $from;
|
if($from) { $this->from = $from;
|
| } else { $this->from = ""; } if($return_email) { $this->return_email = $return_email; } else { $this->return_email = "";
|
}
$this->set_to($to);
| }
$this->set_to($to);
|
Zeile 114 | Zeile 140 |
---|
$this->parse_format = $format; $this->set_common_headers(); $this->set_message($message, $message_text);
|
$this->parse_format = $format; $this->set_common_headers(); $this->set_message($message, $message_text);
|
|
|
}
/**
| }
/**
|
Zeile 129 | Zeile 155 |
---|
if(empty($charset)) { $this->charset = $lang->settings['charset'];
|
if(empty($charset)) { $this->charset = $lang->settings['charset'];
|
}
| }
|
else { $this->charset = $charset;
|
else { $this->charset = $charset;
|
}
| }
|
}
/**
| }
/**
|
Zeile 160 | Zeile 186 |
---|
* @param string subject */ function set_subject($subject)
|
* @param string subject */ function set_subject($subject)
|
{ $this->subject = $this->cleanup($subject);
| { $this->orig_subject = $this->cleanup($subject); $this->subject = $this->utf8_encode($this->orig_subject);
|
}
/**
| }
/**
|
Zeile 191 | Zeile 218 |
---|
*/ function set_html_headers($message, $message_text="") {
|
*/ function set_html_headers($message, $message_text="") {
|
if(!$message_text)
| if(!$message_text && $this->parse_format == 'both')
|
{ $message_text = strip_tags($message); }
|
{ $message_text = strip_tags($message); }
|
$mime_boundary = "=_NextPart".md5(TIME_NOW);
$this->headers .= "Content-Type: multipart/alternative; boundary=\"{$mime_boundary}\"{$this->delimiter}"; $this->message = "This is a multi-part message in MIME format.{$this->delimiter}{$this->delimiter}";
$this->message .= "--{$mime_boundary}{$this->delimiter}"; $this->message .= "Content-Type: text/plain; charset=\"{$this->charset}\"{$this->delimiter}"; $this->message .= "Content-Transfer-Encoding: 8bit{$this->delimiter}{$this->delimiter}"; $this->message .= $message_text."{$this->delimiter}{$this->delimiter}"; $this->message .= "--{$mime_boundary}{$this->delimiter}{$this->delimiter}"; $this->message .= "Content-Type: text/html; charset=\"{$this->charset}\"{$this->delimiter}"; $this->message .= "Content-Transfer-Encoding: 8bit{$this->delimiter}{$this->delimiter}"; $this->message .= $message."{$this->delimiter}{$this->delimiter}"; $this->message .= "--{$mime_boundary}--{$this->delimiter}{$this->delimiter}";
| if($this->parse_format == 'both') { $mime_boundary = "=_NextPart".md5(TIME_NOW);
$this->headers .= "Content-Type: multipart/alternative; boundary=\"{$mime_boundary}\"{$this->delimiter}"; $this->message = "This is a multi-part message in MIME format.{$this->delimiter}{$this->delimiter}";
$this->message .= "--{$mime_boundary}{$this->delimiter}"; $this->message .= "Content-Type: text/plain; charset=\"{$this->charset}\"{$this->delimiter}"; $this->message .= "Content-Transfer-Encoding: 8bit{$this->delimiter}{$this->delimiter}"; $this->message .= $message_text."{$this->delimiter}{$this->delimiter}";
$this->message .= "--{$mime_boundary}{$this->delimiter}";
$this->message .= "Content-Type: text/html; charset=\"{$this->charset}\"{$this->delimiter}"; $this->message .= "Content-Transfer-Encoding: 8bit{$this->delimiter}{$this->delimiter}"; $this->message .= $message."{$this->delimiter}{$this->delimiter}";
$this->message .= "--{$mime_boundary}--{$this->delimiter}{$this->delimiter}"; } else { $this->headers .= "Content-Type: text/html; charset=\"{$this->charset}\"{$this->delimiter}"; $this->headers .= "Content-Transfer-Encoding: 8bit{$this->delimiter}{$this->delimiter}"; $this->message = $message."{$this->delimiter}{$this->delimiter}"; }
|
}
/**
| }
/**
|
Zeile 224 | Zeile 261 |
---|
// Build mail headers if(!trim($this->from)) {
|
// Build mail headers if(!trim($this->from)) {
|
$this->from = "\"{$mybb->settings['bbname']}\" <{$mybb->settings['adminemail']}>";
| if($mybb->settings['mail_handler'] == 'smtp') { $this->from = $mybb->settings['adminemail']; } else { $this->from = '"'.$this->utf8_encode($mybb->settings['bbname']).'"'; $this->from .= " <{$mybb->settings['adminemail']}>"; }
|
}
$this->headers .= "From: {$this->from}{$this->delimiter}";
|
}
$this->headers .= "From: {$this->from}{$this->delimiter}";
|
if($mybb->settings['returnemail'])
| if($this->return_email) { $this->headers .= "Return-Path: {$this->return_email}{$this->delimiter}"; $this->headers .= "Reply-To: {$this->return_email}{$this->delimiter}"; } elseif($mybb->settings['returnemail'])
|
{ $this->headers .= "Return-Path: {$mybb->settings['returnemail']}{$this->delimiter}"; $this->headers .= "Reply-To: {$mybb->settings['adminemail']}{$this->delimiter}";
| { $this->headers .= "Return-Path: {$mybb->settings['returnemail']}{$this->delimiter}"; $this->headers .= "Reply-To: {$mybb->settings['adminemail']}{$this->delimiter}";
|
Zeile 238 | Zeile 288 |
---|
{ $this->headers .= "Return-Path: {$mybb->settings['adminemail']}{$this->delimiter}"; $this->headers .= "Reply-To: {$mybb->settings['adminemail']}{$this->delimiter}";
|
{ $this->headers .= "Return-Path: {$mybb->settings['adminemail']}{$this->delimiter}"; $this->headers .= "Reply-To: {$mybb->settings['adminemail']}{$this->delimiter}";
|
}
| }
|
if(isset($_SERVER['SERVER_NAME'])) { $http_host = $_SERVER['SERVER_NAME'];
|
if(isset($_SERVER['SERVER_NAME'])) { $http_host = $_SERVER['SERVER_NAME'];
|
}
| }
|
else if(isset($_SERVER['HTTP_HOST'])) { $http_host = $_SERVER['HTTP_HOST'];
| else if(isset($_SERVER['HTTP_HOST'])) { $http_host = $_SERVER['HTTP_HOST'];
|
Zeile 251 | Zeile 301 |
---|
else { $http_host = "unknown.local";
|
else { $http_host = "unknown.local";
|
}
| }
|
$msg_id = md5(uniqid(TIME_NOW)) . "@" . $http_host;
| $msg_id = md5(uniqid(TIME_NOW)) . "@" . $http_host;
|
Zeile 260 | Zeile 310 |
---|
$this->headers .= "X-Priority: 3{$this->delimiter}"; $this->headers .= "X-MSMail-Priority: Normal{$this->delimiter}"; $this->headers .= "X-Mailer: MyBB{$this->delimiter}";
|
$this->headers .= "X-Priority: 3{$this->delimiter}"; $this->headers .= "X-MSMail-Priority: Normal{$this->delimiter}"; $this->headers .= "X-Mailer: MyBB{$this->delimiter}";
|
if(defined("IN_ADMINCP")) { $_SERVER['PHP_SELF'] = str_replace($mybb->config['admin_dir']."/", "admin-", $_SERVER['PHP_SELF']); } $this->headers .= "X-MyBB-Script: {$http_host}{$_SERVER['PHP_SELF']}{$this->delimeter}";
| |
$this->headers .= "MIME-Version: 1.0{$this->delimiter}"; }
| $this->headers .= "MIME-Version: 1.0{$this->delimiter}"; }
|
Zeile 279 | Zeile 324 |
---|
global $db; $mail_error = array(
|
global $db; $mail_error = array(
|
"subject" => $db->escape_string($this->subject),
| "subject" => $db->escape_string($this->orig_subject),
|
"message" => $db->escape_string($this->message), "toaddress" => $db->escape_string($this->to), "fromaddress" => $db->escape_string($this->from),
| "message" => $db->escape_string($this->message), "toaddress" => $db->escape_string($this->to), "fromaddress" => $db->escape_string($this->from),
|
Zeile 305 | Zeile 350 |
---|
$string = trim($string); return $string; }
|
$string = trim($string); return $string; }
|
| /** * Encode a string based on the character set enabled. Used to encode subjects * and recipients in email messages going out so that they show up correctly * in email clients. * * @param string The string to be encoded. * @return string The encoded string. */ function utf8_encode($string) { if(strtolower($this->charset) == 'utf-8' && preg_match('/[^\x20-\x7E]/', $string)) { $chunk_size = 47; // Derived from floor((75 - strlen("=?UTF-8?B??=")) * 0.75); $len = strlen($string); $output = ''; $pos = 0;
while($pos < $len) { $newpos = min($pos + $chunk_size, $len);
while(ord($string[$newpos]) >= 0x80 && ord($string[$newpos]) < 0xC0) { // Reduce len until it's safe to split UTF-8. $newpos--; }
$chunk = substr($string, $pos, $newpos - $pos); $pos = $newpos;
$output .= " =?UTF-8?B?".base64_encode($chunk)."?=\n"; } return trim($output); } return $string; }
|
} ?>
| } ?>
|