📄 class.phpmailer.php
字号:
{
$path = $this->attachment[$i][0];
}
$filename = $this->attachment[$i][1];
$name = $this->attachment[$i][2];
$encoding = $this->attachment[$i][3];
$type = $this->attachment[$i][4];
$disposition = $this->attachment[$i][6];
$cid = $this->attachment[$i][7];
$mime[] = sprintf ('--%s%s', $this->boundary[1], $this->LE);
$mime[] = sprintf ('Content-Type: %s; name="%s"%s', $type, $name, $this->LE);
$mime[] = sprintf ('Content-Transfer-Encoding: %s%s', $encoding, $this->LE);
if (($disposition == 'inline'))
{
$mime[] = sprintf ('Content-ID: <%s>%s', $cid, $this->LE);
}
$mime[] = sprintf ('Content-Disposition: %s; filename="%s"%s', $disposition, $name, ($this->LE.$this->LE));
if ($bString)
{
$mime[] = $this->EncodeString ($string, $encoding);
if ($this->IsError ())
{
return '';
}
$mime[] = ($this->LE.$this->LE);
continue;
}
else
{
$mime[] = $this->EncodeFile ($path, $encoding);
if ($this->IsError ())
{
return '';
}
$mime[] = ($this->LE.$this->LE);
continue;
}
}
$mime[] = sprintf ('--%s--%s', $this->boundary[1], $this->LE);
return join ('', $mime);
}
function encodefile ($path, $encoding = 'base64')
{
if (!$fd = fopen ($path, 'rb'))
{
$this->SetError (($this->Lang ('file_open').$path));
return '';
}
$magic_quotes = get_magic_quotes_runtime ();
set_magic_quotes_runtime (0);
$file_buffer = fread ($fd, filesize ($path));
$file_buffer = $this->EncodeString ($file_buffer, $encoding);
fclose ($fd);
set_magic_quotes_runtime ($magic_quotes);
return $file_buffer;
}
function encodestring ($str, $encoding = 'base64')
{
$encoded = '';
switch (strtolower ($encoding))
{
case 'base64':
{
$encoded = chunk_split (base64_encode ($str), 76, $this->LE);
break;
}
case '7bit':
{
}
case '8bit':
{
$encoded = $this->FixEOL ($str);
if ((substr ($encoded, (0 - strlen ($this->LE))) != $this->LE))
{
($encoded .= $this->LE);
break;
}
break;
}
case 'binary':
{
$encoded = $str;
break;
}
case 'quoted-printable':
{
$encoded = $this->EncodeQP ($str);
break;
}
default:
{
$this->SetError (($this->Lang ('encoding').$encoding));
break;
}
}
return $encoded;
}
function encodeheader ($str, $position = 'text')
{
$x = 0;
switch (strtolower ($position))
{
case 'phrase':
{
if (!preg_match ('/[\\200-\\377]/', $str))
{
$encoded = addcslashes ($str, '');
if ((($str == $encoded) AND !preg_match ('/[^A-Za-z0-9!#$%&\'*+\\/=?^_`{|}~ -]/', $str)))
{
return $encoded;
}
else
{
return (((''.'"').$encoded).'"');
}
}
$x = preg_match_all ('/[^\\040\\041\\043-\\133\\135-\\176]/', $str, $matches);
break;
}
case 'comment':
{
$x = preg_match_all ('/[()"]/', $str, $matches);
}
case 'text':
{
}
default:
{
($x += preg_match_all ('/[\\000-\\010\\013\\014\\016-\\037\\177-\\377]/', $str, $matches));
break;
}
}
if (($x == 0))
{
return $str;
}
$maxlen = (68 - strlen ($this->CharSet));
if (((strlen ($str) / 3) < $x))
{
$encoding = 'B';
$encoded = base64_encode ($str);
($maxlen -= ($maxlen % 4));
$encoded = trim (chunk_split ($encoded, $maxlen, '
'));
}
else
{
$encoding = 'Q';
$encoded = $this->EncodeQ ($str, $position);
$encoded = $this->WrapText ($encoded, $maxlen, true);
$encoded = str_replace (('='.$this->LE), '
', trim ($encoded));
}
$encoded = preg_replace ('/^(.*)$/m', ((' =?'.$this->CharSet).(((''.'?').$encoding).'?\\1?=')), $encoded);
$encoded = trim (str_replace ('
', $this->LE, $encoded));
return $encoded;
}
function encodeqp ($str)
{
$encoded = $this->FixEOL ($str);
if ((substr ($encoded, (0 - strlen ($this->LE))) != $this->LE))
{
($encoded .= $this->LE);
}
$encoded = preg_replace ('/([\\000-\\010\\013\\014\\016-\\037\\075\\177-\\377])/e', '\'=\'.sprintf(\'%02X\', ord(\'\\1\'))', $encoded);
$encoded = preg_replace ((('/([ ])'.$this->LE).'/e'), (('\'=\'.sprintf(\'%02X\', ord(\'\\1\')).\''.$this->LE).'\''), $encoded);
$encoded = $this->WrapText ($encoded, 74, true);
return $encoded;
}
function encodeq ($str, $position = 'text')
{
$encoded = preg_replace ('[
]', '', $str);
switch (strtolower ($position))
{
case 'phrase':
{
$encoded = preg_replace ('/([^A-Za-z0-9!*+\\/ -])/e', '\'=\'.sprintf(\'%02X\', ord(\'\\1\'))', $encoded);
break;
}
case 'comment':
{
$encoded = preg_replace ('/([\\(\\)"])/e', '\'=\'.sprintf(\'%02X\', ord(\'\\1\'))', $encoded);
}
case 'text':
{
}
default:
{
$encoded = preg_replace ('/([\\000-\\011\\013\\014\\016-\\037\\075\\077\\137\\177-\\377])/e', '\'=\'.sprintf(\'%02X\', ord(\'\\1\'))', $encoded);
break;
}
}
$encoded = str_replace (' ', '_', $encoded);
return $encoded;
}
function addstringattachment ($string, $filename, $encoding = 'base64', $type = 'application/octet-stream')
{
$cur = count ($this->attachment);
$this->attachment[$cur][0] = $string;
$this->attachment[$cur][1] = $filename;
$this->attachment[$cur][2] = $filename;
$this->attachment[$cur][3] = $encoding;
$this->attachment[$cur][4] = $type;
$this->attachment[$cur][5] = true;
$this->attachment[$cur][6] = 'attachment';
$this->attachment[$cur][7] = 0;
}
function addembeddedimage ($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream')
{
if (!is_file ($path))
{
$this->SetError (($this->Lang ('file_access').$path));
return false;
}
$filename = basename ($path);
if (($name == ''))
{
$name = $filename;
}
$cur = count ($this->attachment);
$this->attachment[$cur][0] = $path;
$this->attachment[$cur][1] = $filename;
$this->attachment[$cur][2] = $name;
$this->attachment[$cur][3] = $encoding;
$this->attachment[$cur][4] = $type;
$this->attachment[$cur][5] = false;
$this->attachment[$cur][6] = 'inline';
$this->attachment[$cur][7] = $cid;
return true;
}
function inlineimageexists ()
{
$result = false;
for ($i = 0; ($i < count ($this->attachment)); ++$i)
{
if (($this->attachment[$i][6] == 'inline'))
{
$result = true;
break;
}
}
return $result;
}
function clearaddresses ()
{
$this->to = array ();
}
function clearccs ()
{
$this->cc = array ();
}
function clearbccs ()
{
$this->bcc = array ();
}
function clearreplytos ()
{
$this->ReplyTo = array ();
}
function clearallrecipients ()
{
$this->to = array ();
$this->cc = array ();
$this->bcc = array ();
}
function clearattachments ()
{
$this->attachment = array ();
}
function clearcustomheaders ()
{
$this->CustomHeader = array ();
}
function seterror ($msg)
{
++$this->error_count;
$this->ErrorInfo = $msg;
}
function rfcdate ()
{
$tz = date ('Z');
$tzs = (($tz < 0) ? '-' : '+');
$tz = abs ($tz);
$tz = ((($tz / 3600) * 100) + (($tz % 3600) / 60));
$result = sprintf ('%s %s%04d', date ('D, j M Y H:i:s'), $tzs, $tz);
return $result;
}
function servervar ($varName)
{
global $HTTP_SERVER_VARS;
global $HTTP_ENV_VARS;
if (!isset ($_SERVER))
{
$_SERVER = $HTTP_SERVER_VARS;
if (!isset ($_SERVER['REMOTE_ADDR']))
{
$_SERVER = $HTTP_ENV_VARS;
}
}
if (isset ($_SERVER[$varName]))
{
return $_SERVER[$varName];
}
else
{
return '';
}
}
function serverhostname ()
{
if (($this->Hostname != ''))
{
$result = $this->Hostname;
}
else
{
if (($this->ServerVar ('SERVER_NAME') != ''))
{
$result = $this->ServerVar ('SERVER_NAME');
}
else
{
$result = 'localhost.localdomain';
}
}
return $result;
}
function lang ($key)
{
if ((count ($this->language) < 1))
{
$this->SetLanguage ('zh');
}
if (isset ($this->language[$key]))
{
return $this->language[$key];
}
else
{
return ('Language string failed to load: '.$key);
}
}
function iserror ()
{
return (0 < $this->error_count);
}
function fixeol ($str)
{
$str = str_replace ('
', '
', $str);
$str = str_replace ('
', '
', $str);
$str = str_replace ('
', $this->LE, $str);
return $str;
}
function addcustomheader ($custom_header)
{
$this->CustomHeader[] = explode (':', $custom_header, 2);
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -