📄 emailer.php
字号:
<?php
class emailer
{
var $from = "";
var $to = "";
var $subject = "";
var $message = "";
var $header = "";
var $footer = "";
var $template = "";
var $error = "";
var $parts = array( );
var $bcc = array( );
var $mail_headers = array( );
var $multipart = "";
var $boundry = "";
var $smtp_fp = FALSE;
var $smtp_msg = "";
var $smtp_port = "";
var $smtp_host = "localhost";
var $smtp_user = "";
var $smtp_pass = "";
var $smtp_code = "";
var $mail_method = "mail";
var $temp_dump = 0;
function emailer( )
{
global $ibforums;
$this->from = $ibforums->vars['email_out'];
$this->temp_dump = $ibforums->vars['fake_mail'];
if ( $ibforums->vars['mail_method'] == "smtp" )
{
$this->mail_method = "smtp";
$this->smtp_port = intval( $ibforums->vars['smtp_port'] ) != "" ? intval( $ibforums->vars['smtp_port'] ) : 25;
$this->smtp_host = $ibforums->vars['smtp_host'] != "" ? $ibforums->vars['smtp_host'] : "localhost";
$this->smtp_user = $ibforums->vars['smtp_user'];
$this->smtp_pass = $ibforums->vars['smtp_pass'];
}
$this->header = $ibforums->vars['email_header'];
$this->footer = $ibforums->vars['email_footer'];
$this->boundry = "----=_NextPart_000_0022_01C1BD6C.D0C0F9F0";
$ibforums->vars['board_name'] = $this->clean_message( $ibforums->vars['board_name'] );
}
function add_attachment( $data = "", $name = "", $ctype = "application/octet-stream" )
{
$this->parts[] = array(
"ctype" => $ctype,
"data" => $data,
"encode" => "base64",
"name" => $name
);
}
function build_headers( )
{
global $ibforums;
$this->mail_headers = "From: \"".$ibforums->vars['board_name']."\" <".$this->from.">\n";
if ( $this->mail_method != "smtp" )
{
if ( 1 < count( $this->bcc ) )
{
$this->mail_headers .= "Bcc: ".implode( ",", $this->bcc )."\n";
}
}
else
{
if ( $this->to )
{
$this->mail_headers .= "To: ".$this->to."\n";
}
$this->mail_headers .= "Subject: ".$this->subject."\n";
}
$this->mail_headers .= "Return-Path: ".$this->from."\n";
$this->mail_headers .= "X-Priority: 3\n";
$this->mail_headers .= "X-Mailer: IBForums PHP Mailer\n";
if ( 0 < count( $this->parts ) )
{
$this->mail_headers .= "MIME-Version: 1.0\n";
$this->mail_headers .= "Content-Type: multipart/mixed;\n\tboundary=\"".$this->boundry."\"\n\nThis is a MIME encoded message.\n\n--".$this->boundry;
$this->mail_headers .= "\nContent-Type: text/plain;\n\tcharset=\"iso-8859-1\"\nContent-Transfer-Encoding: quoted-printable\n\n".$this->message."\n\n--".$this->boundry;
$this->mail_headers .= $this->build_multipart( );
$this->message = "";
}
}
function encode_attachment( $part )
{
$msg = chunk_split( base64_encode( $part['data'] ) );
return "Content-Type: ".$part['ctype'].( $part['name'] ? ";\n\tname =\"".$part['name']."\"" : "" )."\nContent-Transfer-Encoding: ".$part['encode']."\nContent-Disposition: attachment;\n\tfilename=\"".$part['name']."\"\n\n".$msg."\n";
}
function build_multipart( )
{
$multipart = "";
$i = sizeof( $this->parts ) - 1;
for ( ; 0 <= $i; --$i )
{
$multipart .= "\n".$this->encode_attachment( $this->parts[$i] )."--".$this->boundry;
}
return $multipart."--\n";
}
function send_mail( )
{
global $ibforums;
$this->to = preg_replace( "/[ \t]+/", " ", $this->to );
$this->from = preg_replace( "/[ \t]+/", " ", $this->from );
$this->to = preg_replace( "/,,/", ",", $this->to );
$this->from = preg_replace( "/,,/", ",", $this->from );
$this->to = preg_replace( "#\\#\\[\\]'\"\\(\\):;/\$!
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -