73 public $From =
'root@localhost';
648 if ($this->Mailer ==
'smtp') {
666 private function mailPassthru(
$to,
$subject, $body, $header, $params)
669 if (ini_get(
'mbstring.func_overload') & 1) {
674 if (ini_get(
'safe_mode') || !($this->UseSendmailOptions)) {
677 $result = @mail(
$to,
$subject, $body, $header, $params);
691 if ($this->SMTPDebug <= 0) {
695 if (!in_array($this->Debugoutput, array(
'error_log',
'html',
'echo')) and is_callable($this->Debugoutput)) {
696 call_user_func($this->Debugoutput, $str, $this->SMTPDebug);
699 switch ($this->Debugoutput) {
707 preg_replace(
'/[\r\n]+/',
'', $str),
716 $str = preg_replace(
'/(\r\n|\r|\n)/ms',
"\n", $str);
717 echo gmdate(
'Y-m-d H:i:s') .
"\t" . str_replace(
733 $this->ContentType =
'text/html';
735 $this->ContentType =
'text/plain';
745 $this->Mailer =
'smtp';
754 $this->Mailer =
'mail';
763 $ini_sendmail_path = ini_get(
'sendmail_path');
765 if (!stristr($ini_sendmail_path,
'sendmail')) {
766 $this->Sendmail =
'/usr/sbin/sendmail';
768 $this->Sendmail = $ini_sendmail_path;
770 $this->Mailer =
'sendmail';
779 $ini_sendmail_path = ini_get(
'sendmail_path');
781 if (!stristr($ini_sendmail_path,
'qmail')) {
782 $this->Sendmail =
'/var/qmail/bin/qmail-inject';
784 $this->Sendmail = $ini_sendmail_path;
786 $this->Mailer =
'qmail';
807 public function addCC($address, $name =
'')
819 public function addBCC($address, $name =
'')
849 $address = trim($address);
850 $name = trim(preg_replace(
'/[\r\n]+/',
'', $name));
851 if (($pos = strrpos($address,
'@')) ===
false) {
853 $error_message = $this->
lang(
'invalid_address') . $address;
855 $this->
edebug($error_message);
856 if ($this->exceptions) {
861 $params = array($kind, $address, $name);
864 if ($kind !=
'Reply-To') {
865 if (!array_key_exists($address, $this->RecipientsQueue)) {
866 $this->RecipientsQueue[$address] = $params;
870 if (!array_key_exists($address, $this->ReplyToQueue)) {
871 $this->ReplyToQueue[$address] = $params;
878 return call_user_func_array(array($this,
'addAnAddress'), $params);
893 if (!in_array($kind, array(
'to',
'cc',
'bcc',
'Reply-To'))) {
894 $error_message = $this->
lang(
'Invalid recipient kind: ') . $kind;
896 $this->
edebug($error_message);
897 if ($this->exceptions) {
903 $error_message = $this->
lang(
'invalid_address') . $address;
905 $this->
edebug($error_message);
906 if ($this->exceptions) {
911 if ($kind !=
'Reply-To') {
912 if (!array_key_exists(strtolower($address), $this->all_recipients)) {
913 array_push($this->$kind, array($address, $name));
914 $this->all_recipients[strtolower($address)] =
true;
918 if (!array_key_exists(strtolower($address), $this->ReplyTo)) {
919 $this->ReplyTo[strtolower($address)] = array($address, $name);
938 $addresses = array();
939 if ($useimap and function_exists(
'imap_rfc822_parse_adrlist')) {
941 $list = imap_rfc822_parse_adrlist($addrstr,
'');
942 foreach (
$list as $address) {
943 if ($address->host !=
'.SYNTAX-ERROR.') {
944 if ($this->
validateAddress($address->mailbox .
'@' . $address->host)) {
945 $addresses[] = array(
946 'name' => (property_exists($address,
'personal') ? $address->personal :
''),
947 'address' => $address->mailbox .
'@' . $address->host
954 $list = explode(
',', $addrstr);
955 foreach (
$list as $address) {
956 $address = trim($address);
958 if (strpos($address,
'<') ===
false) {
961 $addresses[] = array(
963 'address' => $address
967 list($name, $email) = explode(
'<', $address);
968 $email = trim(str_replace(
'>',
'', $email));
970 $addresses[] = array(
971 'name' => trim(str_replace(array(
'"',
"'"),
'', $name)),
989 public function setFrom($address, $name =
'', $auto =
true)
991 $address = trim($address);
992 $name = trim(preg_replace(
'/[\r\n]+/',
'', $name));
994 if (($pos = strrpos($address,
'@')) ===
false or
997 $error_message = $this->
lang(
'invalid_address') . $address;
999 $this->
edebug($error_message);
1000 if ($this->exceptions) {
1005 $this->From = $address;
1006 $this->FromName = $name;
1008 if (empty($this->Sender)) {
1009 $this->Sender = $address;
1044 if (strpos($address,
"\n") !==
false or strpos($address,
"\r") !==
false) {
1047 if (!$patternselect or $patternselect ==
'auto') {
1050 if (defined(
'PCRE_VERSION')) {
1052 if (version_compare(PCRE_VERSION,
'8.0.3') >= 0) {
1053 $patternselect =
'pcre8';
1055 $patternselect =
'pcre';
1057 } elseif (function_exists(
'extension_loaded') and extension_loaded(
'pcre')) {
1059 $patternselect =
'pcre';
1062 if (version_compare(PHP_VERSION,
'5.2.0') >= 0) {
1063 $patternselect =
'php';
1065 $patternselect =
'noregex';
1069 switch ($patternselect) {
1077 return (
boolean)preg_match(
1078 '/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)' .
1079 '((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)' .
1080 '(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)' .
1081 '([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*' .
1082 '(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)' .
1083 '(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}' .
1084 '|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:' .
1085 '|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}' .
1086 '|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD',
1091 return (
boolean)preg_match(
1092 '/^(?!(?>"?(?>\\\[ -~]|[^"])"?){255,})(?!(?>"?(?>\\\[ -~]|[^"])"?){65,}@)(?>' .
1093 '[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*")' .
1094 '(?>\.(?>[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*"))*' .
1095 '@(?>(?![a-z0-9-]{64,})(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)(?>\.(?![a-z0-9-]{64,})' .
1096 '(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)){0,126}|\[(?:(?>IPv6:(?>(?>[a-f0-9]{1,4})(?>:' .
1097 '[a-f0-9]{1,4}){7}|(?!(?:.*[a-f0-9][:\]]){8,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?' .
1098 '::(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?))|(?>(?>IPv6:(?>[a-f0-9]{1,4}(?>:' .
1099 '[a-f0-9]{1,4}){5}:|(?!(?:.*[a-f0-9]:){6,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4})?' .
1100 '::(?>(?:[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4}):)?))?(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}' .
1101 '|[1-9]?[0-9])(?>\.(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}))\])$/isD',
1109 return (
boolean)preg_match(
1110 '/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}' .
1111 '[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/sD',
1117 return (strlen($address) >= 3
1118 and strpos($address,
'@') >= 1
1119 and strpos($address,
'@') != strlen($address) - 1);
1122 return (
boolean)filter_var($address, FILTER_VALIDATE_EMAIL);
1134 return function_exists(
'idn_to_ascii') and function_exists(
'mb_convert_encoding');
1152 !empty($this->CharSet) and
1153 ($pos = strrpos($address,
'@')) !==
false) {
1154 $domain = substr($address, ++$pos);
1156 if ($this->
has8bitChars($domain) and @mb_check_encoding($domain, $this->CharSet)) {
1157 $domain = mb_convert_encoding($domain,
'UTF-8', $this->CharSet);
1158 if (($punycode = defined(
'INTL_IDNA_VARIANT_UTS46') ?
1159 idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46) :
1160 idn_to_ascii($domain)) !==
false) {
1161 return substr($address, 0, $pos) . $punycode;
1182 $this->mailHeader =
'';
1183 $this->
setError($exc->getMessage());
1184 if ($this->exceptions) {
1199 $this->error_count = 0;
1200 $this->mailHeader =
'';
1203 foreach (array_merge($this->RecipientsQueue, $this->ReplyToQueue) as $params) {
1205 call_user_func_array(array($this,
'addAnAddress'), $params);
1207 if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
1212 foreach (array(
'From',
'Sender',
'ConfirmReadingTo') as $address_kind) {
1213 $this->$address_kind = trim($this->$address_kind);
1214 if (empty($this->$address_kind)) {
1219 $error_message = $this->
lang(
'invalid_address') . $this->$address_kind;
1221 $this->
edebug($error_message);
1222 if ($this->exceptions) {
1230 if (!empty($this->AltBody)) {
1231 $this->ContentType =
'multipart/alternative';
1236 if (!$this->AllowEmpty and empty($this->Body)) {
1241 $this->MIMEHeader =
'';
1246 $this->MIMEHeader .= $tempheaders;
1250 if ($this->Mailer ==
'mail') {
1251 if (count($this->to) > 0) {
1252 $this->mailHeader .= $this->
addrAppend(
'To', $this->to);
1254 $this->mailHeader .= $this->
headerLine(
'To',
'undisclosed-recipients:;');
1263 if (!empty($this->DKIM_domain)
1264 && !empty($this->DKIM_private)
1265 && !empty($this->DKIM_selector)
1266 && file_exists($this->DKIM_private)) {
1268 $this->MIMEHeader . $this->mailHeader,
1272 $this->MIMEHeader = rtrim($this->MIMEHeader,
"\r\n ") . self::CRLF .
1273 str_replace(
"\r\n",
"\n", $header_dkim) . self::CRLF;
1277 $this->
setError($exc->getMessage());
1278 if ($this->exceptions) {
1295 switch ($this->Mailer) {
1298 return $this->
sendmailSend($this->MIMEHeader, $this->MIMEBody);
1300 return $this->
smtpSend($this->MIMEHeader, $this->MIMEBody);
1302 return $this->
mailSend($this->MIMEHeader, $this->MIMEBody);
1304 $sendMethod = $this->Mailer.
'Send';
1305 if (method_exists($this, $sendMethod)) {
1306 return $this->$sendMethod($this->MIMEHeader, $this->MIMEBody);
1309 return $this->
mailSend($this->MIMEHeader, $this->MIMEBody);
1312 $this->
setError($exc->getMessage());
1313 $this->
edebug($exc->getMessage());
1314 if ($this->exceptions) {
1333 if (!empty($this->Sender) and self::isShellSafe($this->Sender)) {
1334 if ($this->Mailer ==
'qmail') {
1335 $sendmailFmt =
'%s -f%s';
1337 $sendmailFmt =
'%s -oi -f%s -t';
1340 if ($this->Mailer ==
'qmail') {
1341 $sendmailFmt =
'%s';
1343 $sendmailFmt =
'%s -oi -t';
1348 $sendmail = sprintf($sendmailFmt, escapeshellcmd($this->Sendmail), $this->Sender);
1350 if ($this->SingleTo) {
1351 foreach ($this->SingleToArray as $toAddr) {
1352 if (!@$mail = popen($sendmail,
'w')) {
1355 fputs($mail,
'To: ' . $toAddr .
"\n");
1356 fputs($mail, $header);
1357 fputs($mail, $body);
1358 $result = pclose($mail);
1373 if (!@$mail = popen($sendmail,
'w')) {
1376 fputs($mail, $header);
1377 fputs($mail, $body);
1378 $result = pclose($mail);
1407 if (escapeshellcmd($string) !== $string or !in_array(escapeshellarg($string), array(
"'$string'",
"\"$string\""))) {
1411 $length = strlen($string);
1413 for ($i = 0; $i < $length; $i++) {
1419 if (!ctype_alnum(
$c) && strpos(
'@_-.',
$c) ===
false) {
1439 foreach ($this->to as $toaddr) {
1442 $to = implode(
', ', $toArr);
1445 if (!empty($this->Sender) and $this->
validateAddress($this->Sender)) {
1447 if (self::isShellSafe($this->Sender)) {
1448 $params = sprintf(
'-f%s', $this->Sender);
1451 if (!empty($this->Sender) and !ini_get(
'safe_mode') and $this->
validateAddress($this->Sender)) {
1452 $old_from = ini_get(
'sendmail_from');
1453 ini_set(
'sendmail_from', $this->Sender);
1456 if ($this->SingleTo && count($toArr) > 1) {
1457 foreach ($toArr as $toAddr) {
1458 $result = $this->mailPassthru($toAddr, $this->Subject, $body, $header, $params);
1459 $this->
doCallback($result, array($toAddr), $this->cc, $this->bcc, $this->Subject, $body, $this->From);
1462 $result = $this->mailPassthru(
$to, $this->Subject, $body, $header, $params);
1463 $this->
doCallback($result, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From);
1465 if (isset($old_from)) {
1466 ini_set(
'sendmail_from', $old_from);
1481 if (!is_object($this->smtp)) {
1482 $this->smtp =
new SMTP;
1501 $bad_rcpt = array();
1505 if (!empty($this->Sender) and $this->
validateAddress($this->Sender)) {
1510 if (!$this->smtp->mail($smtp_from)) {
1511 $this->
setError($this->
lang(
'from_failed') . $smtp_from .
' : ' . implode(
',', $this->smtp->getError()));
1516 foreach (array($this->to, $this->cc, $this->bcc) as $togroup) {
1517 foreach ($togroup as
$to) {
1518 if (!$this->smtp->recipient($to[0])) {
1519 $error = $this->smtp->getError();
1520 $bad_rcpt[] = array(
'to' => $to[0],
'error' => $error[
'detail']);
1525 $this->
doCallback($isSent, array($to[0]), array(), array(), $this->Subject, $body, $this->From);
1530 if ((count($this->all_recipients) > count($bad_rcpt)) and !$this->smtp->data($header . $body)) {
1533 if ($this->SMTPKeepAlive) {
1534 $this->smtp->reset();
1536 $this->smtp->quit();
1537 $this->smtp->close();
1540 if (count($bad_rcpt) > 0) {
1542 foreach ($bad_rcpt as $bad) {
1543 $errstr .= $bad[
'to'] .
': ' . $bad[
'error'];
1546 $this->
lang(
'recipients_failed') . $errstr,
1564 if (is_null($this->smtp)) {
1569 if ($this->smtp->connected()) {
1573 $this->smtp->setTimeout($this->Timeout);
1574 $this->smtp->setDebugLevel($this->SMTPDebug);
1575 $this->smtp->setDebugOutput($this->Debugoutput);
1576 $this->smtp->setVerp($this->do_verp);
1577 $hosts = explode(
';', $this->Host);
1578 $lastexception = null;
1580 foreach ($hosts as $hostentry) {
1581 $hostinfo = array();
1582 if (!preg_match(
'/^((ssl|tls):\/\/)*([a-zA-Z0-9\.-]*):?([0-9]*)$/', trim($hostentry), $hostinfo)) {
1593 $tls = ($this->SMTPSecure ==
'tls');
1594 if (
'ssl' == $hostinfo[2] or (
'' == $hostinfo[2] and
'ssl' == $this->SMTPSecure)) {
1598 } elseif ($hostinfo[2] ==
'tls') {
1604 $sslext = defined(
'OPENSSL_ALGO_SHA1');
1605 if (
'tls' === $secure or
'ssl' === $secure) {
1611 $host = $hostinfo[3];
1613 $tport = (integer)$hostinfo[4];
1614 if ($tport > 0 and $tport < 65536) {
1617 if ($this->smtp->connect(
$prefix . $host, $port, $this->Timeout, $options)) {
1624 $this->smtp->hello($hello);
1630 if ($this->SMTPAutoTLS and $sslext and $secure !=
'ssl' and $this->smtp->getServerExt(
'STARTTLS')) {
1634 if (!$this->smtp->startTLS()) {
1638 $this->smtp->hello($hello);
1640 if ($this->SMTPAuth) {
1641 if (!$this->smtp->authenticate(
1654 $lastexception = $exc;
1655 $this->
edebug($exc->getMessage());
1657 $this->smtp->quit();
1662 $this->smtp->close();
1664 if ($this->exceptions and !is_null($lastexception)) {
1665 throw $lastexception;
1676 if ($this->smtp !== null) {
1677 if ($this->smtp->connected()) {
1678 $this->smtp->quit();
1679 $this->smtp->close();
1697 'authenticate' =>
'SMTP Error: Could not authenticate.',
1698 'connect_host' =>
'SMTP Error: Could not connect to SMTP host.',
1699 'data_not_accepted' =>
'SMTP Error: data not accepted.',
1700 'empty_message' =>
'Message body empty',
1701 'encoding' =>
'Unknown encoding: ',
1702 'execute' =>
'Could not execute: ',
1703 'file_access' =>
'Could not access file: ',
1704 'file_open' =>
'File Error: Could not open file: ',
1705 'from_failed' =>
'The following From address failed: ',
1706 'instantiate' =>
'Could not instantiate mail function.',
1707 'invalid_address' =>
'Invalid address: ',
1708 'mailer_not_supported' =>
' mailer is not supported.',
1709 'provide_address' =>
'You must provide at least one recipient email address.',
1710 'recipients_failed' =>
'SMTP Error: The following recipients failed: ',
1711 'signing' =>
'Signing Error: ',
1712 'smtp_connect_failed' =>
'SMTP connect() failed.',
1713 'smtp_error' =>
'SMTP server error: ',
1714 'variable_set' =>
'Cannot set or reset variable: ',
1715 'extension_missing' =>
'Extension missing: '
1717 if (empty($lang_path)) {
1719 $lang_path = dirname(__FILE__). DIRECTORY_SEPARATOR .
'language'. DIRECTORY_SEPARATOR;
1722 $lang_file = $lang_path .
'phpmailer.lang-' . $langcode .
'.php';
1724 if ($langcode !=
'en') {
1726 if (!is_readable($lang_file)) {
1731 $foundlang = include $lang_file;
1735 return (
boolean)$foundlang;
1759 $addresses = array();
1760 foreach ($addr as $address) {
1775 if (empty($addr[1])) {
1798 $soft_break = sprintf(
' =%s', $this->LE);
1804 $is_utf8 = (strtolower($this->CharSet) ==
'utf-8');
1805 $lelen = strlen($this->LE);
1806 $crlflen = strlen(self::CRLF);
1810 if (substr(
$message, -$lelen) == $this->LE) {
1815 $lines = explode($this->LE,
$message);
1818 foreach ($lines as $line) {
1819 $words = explode(
' ', $line);
1822 foreach ($words as $word) {
1823 if ($qp_mode and (strlen($word) > $length)) {
1824 $space_left = $length - strlen($buf) - $crlflen;
1826 if ($space_left > 20) {
1830 } elseif (substr($word, $len - 1, 1) ==
'=') {
1832 } elseif (substr($word, $len - 2, 1) ==
'=') {
1835 $part = substr($word, 0, $len);
1836 $word = substr($word, $len);
1837 $buf .=
' ' . $part;
1838 $message .= $buf . sprintf(
'=%s', self::CRLF);
1844 while (strlen($word) > 0) {
1851 } elseif (substr($word, $len - 1, 1) ==
'=') {
1853 } elseif (substr($word, $len - 2, 1) ==
'=') {
1856 $part = substr($word, 0, $len);
1857 $word = substr($word, $len);
1859 if (strlen($word) > 0) {
1860 $message .= $part . sprintf(
'=%s', self::CRLF);
1872 if (strlen($buf) > $length and $buf_o !=
'') {
1896 $foundSplitPos =
false;
1898 while (!$foundSplitPos) {
1899 $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack);
1900 $encodedCharPos = strpos($lastChunk,
'=');
1901 if (
false !== $encodedCharPos) {
1904 $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2);
1905 $dec = hexdec($hex);
1910 if ($encodedCharPos > 0) {
1911 $maxLength = $maxLength - ($lookBack - $encodedCharPos);
1913 $foundSplitPos =
true;
1914 } elseif ($dec >= 192) {
1917 $maxLength = $maxLength - ($lookBack - $encodedCharPos);
1918 $foundSplitPos =
true;
1919 } elseif ($dec < 192) {
1925 $foundSplitPos =
true;
1941 if ($this->WordWrap < 1) {
1945 switch ($this->message_type) {
1949 case 'alt_inline_attach':
1950 $this->AltBody = $this->
wrapText($this->AltBody, $this->WordWrap);
1953 $this->Body = $this->
wrapText($this->Body, $this->WordWrap);
1967 if ($this->MessageDate ==
'') {
1968 $this->MessageDate = self::rfcDate();
1970 $result .= $this->
headerLine(
'Date', $this->MessageDate);
1973 if ($this->SingleTo) {
1974 if ($this->Mailer !=
'mail') {
1975 foreach ($this->to as $toaddr) {
1976 $this->SingleToArray[] = $this->
addrFormat($toaddr);
1980 if (count($this->to) > 0) {
1981 if ($this->Mailer !=
'mail') {
1982 $result .= $this->
addrAppend(
'To', $this->to);
1984 } elseif (count($this->cc) == 0) {
1985 $result .= $this->
headerLine(
'To',
'undisclosed-recipients:;');
1989 $result .= $this->
addrAppend(
'From', array(array(trim($this->From), $this->FromName)));
1992 if (count($this->cc) > 0) {
1993 $result .= $this->
addrAppend(
'Cc', $this->cc);
1998 $this->Mailer ==
'sendmail' or $this->Mailer ==
'qmail' or $this->Mailer ==
'mail'
2000 and count($this->bcc) > 0
2002 $result .= $this->
addrAppend(
'Bcc', $this->bcc);
2005 if (count($this->ReplyTo) > 0) {
2006 $result .= $this->
addrAppend(
'Reply-To', $this->ReplyTo);
2010 if ($this->Mailer !=
'mail') {
2014 if ($this->MessageID !=
'') {
2017 $this->lastMessageID = sprintf(
'<%s@%s>', $this->uniqueid, $this->
serverHostname());
2019 $result .= $this->
headerLine(
'Message-ID', $this->lastMessageID);
2020 if (!is_null($this->Priority)) {
2021 $result .= $this->
headerLine(
'X-Priority', $this->Priority);
2023 if ($this->XMailer ==
'') {
2026 'PHPMailer ' . $this->Version .
' (https://github.com/PHPMailer/PHPMailer)'
2029 $myXmailer = trim($this->XMailer);
2031 $result .= $this->
headerLine(
'X-Mailer', $myXmailer);
2035 if ($this->ConfirmReadingTo !=
'') {
2036 $result .= $this->
headerLine(
'Disposition-Notification-To',
'<' . $this->ConfirmReadingTo .
'>');
2040 foreach ($this->CustomHeader as $header) {
2046 if (!$this->sign_key_file) {
2047 $result .= $this->
headerLine(
'MIME-Version',
'1.0');
2062 $ismultipart =
true;
2063 switch ($this->message_type) {
2065 $result .= $this->
headerLine(
'Content-Type',
'multipart/related;');
2066 $result .= $this->
textLine(
"\tboundary=\"" . $this->boundary[1] .
'"');
2069 case 'inline_attach':
2071 case 'alt_inline_attach':
2072 $result .= $this->
headerLine(
'Content-Type',
'multipart/mixed;');
2073 $result .= $this->
textLine(
"\tboundary=\"" . $this->boundary[1] .
'"');
2077 $result .= $this->
headerLine(
'Content-Type',
'multipart/alternative;');
2078 $result .= $this->
textLine(
"\tboundary=\"" . $this->boundary[1] .
'"');
2082 $result .= $this->
textLine(
'Content-Type: ' . $this->ContentType .
'; charset=' . $this->CharSet);
2083 $ismultipart =
false;
2087 if ($this->Encoding !=
'7bit') {
2090 if ($this->Encoding ==
'8bit') {
2091 $result .= $this->
headerLine(
'Content-Transfer-Encoding',
'8bit');
2095 $result .= $this->
headerLine(
'Content-Transfer-Encoding', $this->Encoding);
2099 if ($this->Mailer !=
'mail') {
2116 return $this->MIMEHeader . $this->mailHeader . self::CRLF .
$this->MIMEBody;
2130 $this->uniqueid = md5(uniqid(time()));
2135 if ($this->sign_key_file) {
2144 if ($bodyEncoding ==
'8bit' and !$this->
has8bitChars($this->Body)) {
2145 $bodyEncoding =
'7bit';
2146 $bodyCharSet =
'us-ascii';
2150 if (
'base64' != $this->Encoding and self::hasLineLongerThanMax($this->Body)) {
2151 $this->Encoding =
'quoted-printable';
2152 $bodyEncoding =
'quoted-printable';
2158 if ($altBodyEncoding ==
'8bit' and !$this->
has8bitChars($this->AltBody)) {
2159 $altBodyEncoding =
'7bit';
2160 $altBodyCharSet =
'us-ascii';
2163 if (self::hasLineLongerThanMax($this->AltBody)) {
2164 $altBodyEncoding =
'quoted-printable';
2167 $mimepre =
"This is a multi-part message in MIME format." . $this->LE .
$this->LE;
2168 switch ($this->message_type) {
2171 $body .= $this->
getBoundary($this->boundary[1], $bodyCharSet,
'', $bodyEncoding);
2172 $body .= $this->
encodeString($this->Body, $bodyEncoding);
2174 $body .= $this->
attachAll(
'inline', $this->boundary[1]);
2178 $body .= $this->
getBoundary($this->boundary[1], $bodyCharSet,
'', $bodyEncoding);
2179 $body .= $this->
encodeString($this->Body, $bodyEncoding);
2181 $body .= $this->
attachAll(
'attachment', $this->boundary[1]);
2183 case 'inline_attach':
2185 $body .= $this->
textLine(
'--' . $this->boundary[1]);
2186 $body .= $this->
headerLine(
'Content-Type',
'multipart/related;');
2187 $body .= $this->
textLine(
"\tboundary=\"" . $this->boundary[2] .
'"');
2189 $body .= $this->
getBoundary($this->boundary[2], $bodyCharSet,
'', $bodyEncoding);
2190 $body .= $this->
encodeString($this->Body, $bodyEncoding);
2192 $body .= $this->
attachAll(
'inline', $this->boundary[2]);
2194 $body .= $this->
attachAll(
'attachment', $this->boundary[1]);
2198 $body .= $this->
getBoundary($this->boundary[1], $altBodyCharSet,
'text/plain', $altBodyEncoding);
2199 $body .= $this->
encodeString($this->AltBody, $altBodyEncoding);
2201 $body .= $this->
getBoundary($this->boundary[1], $bodyCharSet,
'text/html', $bodyEncoding);
2202 $body .= $this->
encodeString($this->Body, $bodyEncoding);
2204 if (!empty($this->Ical)) {
2205 $body .= $this->
getBoundary($this->boundary[1],
'',
'text/calendar; method=REQUEST',
'');
2206 $body .= $this->
encodeString($this->Ical, $this->Encoding);
2213 $body .= $this->
getBoundary($this->boundary[1], $altBodyCharSet,
'text/plain', $altBodyEncoding);
2214 $body .= $this->
encodeString($this->AltBody, $altBodyEncoding);
2216 $body .= $this->
textLine(
'--' . $this->boundary[1]);
2217 $body .= $this->
headerLine(
'Content-Type',
'multipart/related;');
2218 $body .= $this->
textLine(
"\tboundary=\"" . $this->boundary[2] .
'"');
2220 $body .= $this->
getBoundary($this->boundary[2], $bodyCharSet,
'text/html', $bodyEncoding);
2221 $body .= $this->
encodeString($this->Body, $bodyEncoding);
2223 $body .= $this->
attachAll(
'inline', $this->boundary[2]);
2229 $body .= $this->
textLine(
'--' . $this->boundary[1]);
2230 $body .= $this->
headerLine(
'Content-Type',
'multipart/alternative;');
2231 $body .= $this->
textLine(
"\tboundary=\"" . $this->boundary[2] .
'"');
2233 $body .= $this->
getBoundary($this->boundary[2], $altBodyCharSet,
'text/plain', $altBodyEncoding);
2234 $body .= $this->
encodeString($this->AltBody, $altBodyEncoding);
2236 $body .= $this->
getBoundary($this->boundary[2], $bodyCharSet,
'text/html', $bodyEncoding);
2237 $body .= $this->
encodeString($this->Body, $bodyEncoding);
2241 $body .= $this->
attachAll(
'attachment', $this->boundary[1]);
2243 case 'alt_inline_attach':
2245 $body .= $this->
textLine(
'--' . $this->boundary[1]);
2246 $body .= $this->
headerLine(
'Content-Type',
'multipart/alternative;');
2247 $body .= $this->
textLine(
"\tboundary=\"" . $this->boundary[2] .
'"');
2249 $body .= $this->
getBoundary($this->boundary[2], $altBodyCharSet,
'text/plain', $altBodyEncoding);
2250 $body .= $this->
encodeString($this->AltBody, $altBodyEncoding);
2252 $body .= $this->
textLine(
'--' . $this->boundary[2]);
2253 $body .= $this->
headerLine(
'Content-Type',
'multipart/related;');
2254 $body .= $this->
textLine(
"\tboundary=\"" . $this->boundary[3] .
'"');
2256 $body .= $this->
getBoundary($this->boundary[3], $bodyCharSet,
'text/html', $bodyEncoding);
2257 $body .= $this->
encodeString($this->Body, $bodyEncoding);
2259 $body .= $this->
attachAll(
'inline', $this->boundary[3]);
2263 $body .= $this->
attachAll(
'attachment', $this->boundary[1]);
2267 $body .= $this->
encodeString($this->Body, $bodyEncoding);
2273 } elseif ($this->sign_key_file) {
2275 if (!defined(
'PKCS7_TEXT')) {
2279 $file = tempnam(sys_get_temp_dir(),
'mail');
2280 if (
false === file_put_contents(
$file, $body)) {
2283 $signed = tempnam(sys_get_temp_dir(),
'signed');
2285 if (empty($this->sign_extracerts_file)) {
2286 $sign = @openssl_pkcs7_sign(
2289 'file://' . realpath($this->sign_cert_file),
2290 array(
'file://' . realpath($this->sign_key_file), $this->sign_key_pass),
2294 $sign = @openssl_pkcs7_sign(
2297 'file://' . realpath($this->sign_cert_file),
2298 array(
'file://' . realpath($this->sign_key_file), $this->sign_key_pass),
2301 $this->sign_extracerts_file
2306 $body = file_get_contents($signed);
2309 $parts = explode(
"\n\n", $body, 2);
2310 $this->MIMEHeader .= $parts[0] . $this->LE .
$this->LE;
2319 if ($this->exceptions) {
2339 if ($charSet ==
'') {
2342 if ($contentType ==
'') {
2345 if ($encoding ==
'') {
2349 $result .= sprintf(
'Content-Type: %s; charset=%s', $contentType, $charSet);
2352 if ($encoding !=
'7bit') {
2353 $result .= $this->
headerLine(
'Content-Transfer-Encoding', $encoding);
2390 $this->message_type = implode(
'_',
$type);
2391 if ($this->message_type ==
'') {
2392 $this->message_type =
'plain';
2433 if (!@is_file(
$path)) {
2447 $this->attachment[] = array(
2459 $this->
setError($exc->getMessage());
2460 $this->
edebug($exc->getMessage());
2461 if ($this->exceptions) {
2496 if ($attachment[6] == $disposition_type) {
2500 $bString = $attachment[5];
2502 $string = $attachment[0];
2504 $path = $attachment[0];
2507 $inclhash = md5(serialize($attachment));
2508 if (in_array($inclhash, $incl)) {
2511 $incl[] = $inclhash;
2512 $name = $attachment[2];
2513 $encoding = $attachment[3];
2514 $type = $attachment[4];
2515 $disposition = $attachment[6];
2516 $cid = $attachment[7];
2517 if ($disposition ==
'inline' && array_key_exists($cid, $cidUniq)) {
2520 $cidUniq[$cid] =
true;
2522 $mime[] = sprintf(
'--%s%s',
$boundary, $this->LE);
2524 if (!empty($name)) {
2526 'Content-Type: %s; name="%s"%s',
2533 'Content-Type: %s%s',
2539 if ($encoding !=
'7bit') {
2540 $mime[] = sprintf(
'Content-Transfer-Encoding: %s%s', $encoding, $this->LE);
2543 if ($disposition ==
'inline') {
2544 $mime[] = sprintf(
'Content-ID: <%s>%s', $cid, $this->LE);
2551 if (!(empty($disposition))) {
2553 if (preg_match(
'/[ \(\)<>@,;:\\"\/\[\]\?=]/', $encoded_name)) {
2555 'Content-Disposition: %s; filename="%s"%s',
2558 $this->LE . $this->LE
2561 if (!empty($encoded_name)) {
2563 'Content-Disposition: %s; filename=%s%s',
2566 $this->LE . $this->LE
2570 'Content-Disposition: %s%s',
2572 $this->LE . $this->LE
2597 $mime[] = sprintf(
'--%s--%s',
$boundary, $this->LE);
2599 return implode(
'', $mime);
2614 if (!is_readable(
$path)) {
2617 $magic_quotes = get_magic_quotes_runtime();
2618 if ($magic_quotes) {
2619 if (version_compare(PHP_VERSION,
'5.3.0',
'<')) {
2620 set_magic_quotes_runtime(
false);
2625 ini_set(
'magic_quotes_runtime',
false);
2628 $file_buffer = file_get_contents(
$path);
2629 $file_buffer = $this->
encodeString($file_buffer, $encoding);
2630 if ($magic_quotes) {
2631 if (version_compare(PHP_VERSION,
'5.3.0',
'<')) {
2632 set_magic_quotes_runtime($magic_quotes);
2634 ini_set(
'magic_quotes_runtime', $magic_quotes);
2637 return $file_buffer;
2638 }
catch (Exception $exc) {
2639 $this->
setError($exc->getMessage());
2655 switch (strtolower($encoding)) {
2657 $encoded = chunk_split(base64_encode($str), 76, $this->LE);
2661 $encoded = $this->
fixEOL($str);
2663 if (substr($encoded, -(strlen($this->LE))) != $this->LE) {
2670 case 'quoted-printable':
2691 switch (strtolower($position)) {
2693 if (!preg_match(
'/[\200-\377]/', $str)) {
2695 $encoded = addcslashes($str,
"\0..\37\177\\\"");
2696 if (($str == $encoded) && !preg_match(
'/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) {
2699 return (
"\"$encoded\"");
2702 $matchcount = preg_match_all(
'/[^\040\041\043-\133\135-\176]/', $str, $matches);
2706 $matchcount = preg_match_all(
'/[()"]/', $str, $matches);
2710 $matchcount += preg_match_all(
'/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
2715 if ($matchcount == 0) {
2719 $maxlen = 75 - 7 - strlen($this->CharSet);
2721 if ($matchcount > strlen($str) / 3) {
2724 if (function_exists(
'mb_strlen') && $this->
hasMultiBytes($str)) {
2729 $encoded = base64_encode($str);
2730 $maxlen -= $maxlen % 4;
2731 $encoded = trim(chunk_split($encoded, $maxlen,
"\n"));
2735 $encoded = $this->
encodeQ($str, $position);
2736 $encoded = $this->
wrapText($encoded, $maxlen,
true);
2737 $encoded = str_replace(
'=' . self::CRLF,
"\n", trim($encoded));
2740 $encoded = preg_replace(
'/^(.*)$/m',
' =?' . $this->CharSet .
"?$encoding?\\1?=", $encoded);
2741 $encoded = trim(str_replace(
"\n", $this->LE, $encoded));
2754 if (function_exists(
'mb_strlen')) {
2755 return (strlen($str) > mb_strlen($str, $this->CharSet));
2768 return (
boolean)preg_match(
'/[\x80-\xFF]/', $text);
2783 $start =
'=?' . $this->CharSet .
'?B?';
2786 if ($linebreak === null) {
2790 $mb_length = mb_strlen($str, $this->CharSet);
2792 $length = 75 - strlen(
$start) - strlen($end);
2794 $ratio = $mb_length / strlen($str);
2796 $avgLength = floor($length *
$ratio * .75);
2798 for ($i = 0; $i < $mb_length; $i += $offset) {
2801 $offset = $avgLength - $lookBack;
2802 $chunk = mb_substr($str, $i, $offset, $this->CharSet);
2803 $chunk = base64_encode($chunk);
2805 }
while (strlen($chunk) > $length);
2806 $encoded .= $chunk . $linebreak;
2810 $encoded = substr($encoded, 0, -strlen($linebreak));
2826 if (function_exists(
'quoted_printable_encode')) {
2827 return quoted_printable_encode($string);
2830 $string = str_replace(
2831 array(
'%20',
'%0D%0A.',
'%0D%0A',
'%'),
2832 array(
' ',
"\r\n=2E",
"\r\n",
'='),
2833 rawurlencode($string)
2835 return preg_replace(
'/[^\r\n]{' . ($line_max - 3) .
'}[^=\r\n]{2}/',
"$0=\r\n", $string);
2853 return $this->
encodeQP($string, $line_max);
2868 $encoded = str_replace(array(
"\r",
"\n"),
'', $str);
2869 switch (strtolower($position)) {
2872 $pattern =
'^A-Za-z0-9!*+\/ -';
2884 $pattern =
'\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern;
2888 if (preg_match_all(
"/[{$pattern}]/", $encoded, $matches)) {
2891 $eqkey = array_search(
'=', $matches[0]);
2892 if (
false !== $eqkey) {
2893 unset($matches[0][$eqkey]);
2894 array_unshift($matches[0],
'=');
2896 foreach (array_unique($matches[0]) as $char) {
2897 $encoded = str_replace($char,
'=' . sprintf(
'%02X', ord($char)), $encoded);
2901 return str_replace(
' ',
'_', $encoded);
2918 $encoding =
'base64',
2920 $disposition =
'attachment'
2927 $this->attachment[] = array(
2957 if (!@is_file(
$path)) {
2973 $this->attachment[] = array(
3004 $encoding =
'base64',
3006 $disposition =
'inline'
3009 if (
$type ==
'' and !empty($name)) {
3010 $type = self::filenameToType($name);
3014 $this->attachment[] = array(
3035 if ($attachment[6] ==
'inline') {
3049 if ($attachment[6] ==
'attachment') {
3062 return !empty($this->AltBody);
3075 if ($params[0] == $kind) {
3076 unset($this->RecipientsQueue[$address]);
3087 foreach ($this->to as
$to) {
3088 unset($this->all_recipients[strtolower($to[0])]);
3090 $this->to = array();
3100 foreach ($this->cc as
$cc) {
3101 unset($this->all_recipients[strtolower($cc[0])]);
3103 $this->cc = array();
3113 foreach ($this->bcc as
$bcc) {
3114 unset($this->all_recipients[strtolower($bcc[0])]);
3116 $this->bcc = array();
3126 $this->ReplyTo = array();
3127 $this->ReplyToQueue = array();
3136 $this->to = array();
3137 $this->cc = array();
3138 $this->bcc = array();
3139 $this->all_recipients = array();
3140 $this->RecipientsQueue = array();
3149 $this->attachment = array();
3158 $this->CustomHeader = array();
3169 $this->error_count++;
3170 if ($this->Mailer ==
'smtp' and !is_null($this->smtp)) {
3171 $lasterror = $this->smtp->getError();
3172 if (!empty($lasterror[
'error'])) {
3173 $msg .= $this->
lang(
'smtp_error') . $lasterror[
'error'];
3174 if (!empty($lasterror[
'detail'])) {
3175 $msg .=
' Detail: '. $lasterror[
'detail'];
3177 if (!empty($lasterror[
'smtp_code'])) {
3178 $msg .=
' SMTP code: ' . $lasterror[
'smtp_code'];
3180 if (!empty($lasterror[
'smtp_code_ex'])) {
3181 $msg .=
' Additional SMTP info: ' . $lasterror[
'smtp_code_ex'];
3185 $this->ErrorInfo = $msg;
3198 date_default_timezone_set(@date_default_timezone_get());
3199 return date(
'D, j M Y H:i:s O');
3210 $result =
'localhost.localdomain';
3211 if (!empty($this->Hostname)) {
3215 } elseif (function_exists(
'gethostname') && gethostname() !==
false) {
3216 $result = gethostname();
3217 } elseif (php_uname(
'n') !==
false) {
3218 $result = php_uname(
'n');
3231 if (count($this->language) < 1) {
3235 if (array_key_exists($key, $this->language)) {
3236 if ($key ==
'smtp_connect_failed') {
3240 return $this->language[$key] .
' https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting';
3242 return $this->language[$key];
3256 return ($this->error_count > 0);
3269 $nstr = str_replace(array(
"\r\n",
"\r"),
"\n", $str);
3271 if ($this->LE !==
"\n") {
3272 $nstr = str_replace(
"\n", $this->LE, $nstr);
3290 $this->CustomHeader[] = explode(
':', $name, 2);
3292 $this->CustomHeader[] = array($name,
$value);
3319 preg_match_all(
'/(src|background)=["\'](.*)["\']/Ui',
$message, $images);
3320 if (array_key_exists(2, $images)) {
3321 foreach ($images[2] as $imgindex => $url) {
3323 if (preg_match(
'#^data:(image[^;,]*)(;base64)?,#', $url, $match)) {
3324 $data = substr($url, strpos($url,
','));
3330 $cid = md5($url) .
'@phpmailer.0';
3333 $images[0][$imgindex],
3334 $images[1][$imgindex] .
'="cid:' . $cid .
'"',
3338 } elseif (substr($url, 0, 4) !==
'cid:' && !preg_match(
'#^[A-z]+://#', $url)) {
3342 $directory = dirname($url);
3343 if ($directory ==
'.') {
3346 $cid = md5($url) .
'@phpmailer.0';
3347 if (strlen($basedir) > 1 && substr($basedir, -1) !=
'/') {
3350 if (strlen($directory) > 1 && substr($directory, -1) !=
'/') {
3358 self::_mime_types((
string)self::mb_pathinfo($filename, PATHINFO_EXTENSION))
3362 '/' . $images[1][$imgindex] .
'=["\']' . preg_quote($url,
'/') .
'["\']/Ui',
3363 $images[1][$imgindex] .
'="cid:' . $cid .
'"',
3374 if (empty($this->AltBody)) {
3375 $this->AltBody =
'To view this email message, open it in a program that understands HTML!' .
3376 self::CRLF . self::CRLF;
3403 if (is_callable($advanced)) {
3404 return call_user_func($advanced, $html);
3406 return html_entity_decode(
3407 trim(strip_tags(preg_replace(
'/<(head|title|style|script)[^>]*>.*?<\/\\1>/si',
'', $html))),
3423 'xl' =>
'application/excel',
3424 'js' =>
'application/javascript',
3425 'hqx' =>
'application/mac-binhex40',
3426 'cpt' =>
'application/mac-compactpro',
3427 'bin' =>
'application/macbinary',
3428 'doc' =>
'application/msword',
3429 'word' =>
'application/msword',
3430 'xlsx' =>
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3431 'xltx' =>
'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
3432 'potx' =>
'application/vnd.openxmlformats-officedocument.presentationml.template',
3433 'ppsx' =>
'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
3434 'pptx' =>
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
3435 'sldx' =>
'application/vnd.openxmlformats-officedocument.presentationml.slide',
3436 'docx' =>
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
3437 'dotx' =>
'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
3438 'xlam' =>
'application/vnd.ms-excel.addin.macroEnabled.12',
3439 'xlsb' =>
'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
3440 'class' =>
'application/octet-stream',
3441 'dll' =>
'application/octet-stream',
3442 'dms' =>
'application/octet-stream',
3443 'exe' =>
'application/octet-stream',
3444 'lha' =>
'application/octet-stream',
3445 'lzh' =>
'application/octet-stream',
3446 'psd' =>
'application/octet-stream',
3447 'sea' =>
'application/octet-stream',
3448 'so' =>
'application/octet-stream',
3449 'oda' =>
'application/oda',
3450 'pdf' =>
'application/pdf',
3451 'ai' =>
'application/postscript',
3452 'eps' =>
'application/postscript',
3453 'ps' =>
'application/postscript',
3454 'smi' =>
'application/smil',
3455 'smil' =>
'application/smil',
3456 'mif' =>
'application/vnd.mif',
3457 'xls' =>
'application/vnd.ms-excel',
3458 'ppt' =>
'application/vnd.ms-powerpoint',
3459 'wbxml' =>
'application/vnd.wap.wbxml',
3460 'wmlc' =>
'application/vnd.wap.wmlc',
3461 'dcr' =>
'application/x-director',
3462 'dir' =>
'application/x-director',
3463 'dxr' =>
'application/x-director',
3464 'dvi' =>
'application/x-dvi',
3465 'gtar' =>
'application/x-gtar',
3466 'php3' =>
'application/x-httpd-php',
3467 'php4' =>
'application/x-httpd-php',
3468 'php' =>
'application/x-httpd-php',
3469 'phtml' =>
'application/x-httpd-php',
3470 'phps' =>
'application/x-httpd-php-source',
3471 'swf' =>
'application/x-shockwave-flash',
3472 'sit' =>
'application/x-stuffit',
3473 'tar' =>
'application/x-tar',
3474 'tgz' =>
'application/x-tar',
3475 'xht' =>
'application/xhtml+xml',
3476 'xhtml' =>
'application/xhtml+xml',
3477 'zip' =>
'application/zip',
3478 'mid' =>
'audio/midi',
3479 'midi' =>
'audio/midi',
3480 'mp2' =>
'audio/mpeg',
3481 'mp3' =>
'audio/mpeg',
3482 'mpga' =>
'audio/mpeg',
3483 'aif' =>
'audio/x-aiff',
3484 'aifc' =>
'audio/x-aiff',
3485 'aiff' =>
'audio/x-aiff',
3486 'ram' =>
'audio/x-pn-realaudio',
3487 'rm' =>
'audio/x-pn-realaudio',
3488 'rpm' =>
'audio/x-pn-realaudio-plugin',
3489 'ra' =>
'audio/x-realaudio',
3490 'wav' =>
'audio/x-wav',
3491 'bmp' =>
'image/bmp',
3492 'gif' =>
'image/gif',
3493 'jpeg' =>
'image/jpeg',
3494 'jpe' =>
'image/jpeg',
3495 'jpg' =>
'image/jpeg',
3496 'png' =>
'image/png',
3497 'tiff' =>
'image/tiff',
3498 'tif' =>
'image/tiff',
3499 'eml' =>
'message/rfc822',
3500 'css' =>
'text/css',
3501 'html' =>
'text/html',
3502 'htm' =>
'text/html',
3503 'shtml' =>
'text/html',
3504 'log' =>
'text/plain',
3505 'text' =>
'text/plain',
3506 'txt' =>
'text/plain',
3507 'rtx' =>
'text/richtext',
3508 'rtf' =>
'text/rtf',
3509 'vcf' =>
'text/vcard',
3510 'vcard' =>
'text/vcard',
3511 'xml' =>
'text/xml',
3512 'xsl' =>
'text/xml',
3513 'mpeg' =>
'video/mpeg',
3514 'mpe' =>
'video/mpeg',
3515 'mpg' =>
'video/mpeg',
3516 'mov' =>
'video/quicktime',
3517 'qt' =>
'video/quicktime',
3518 'rv' =>
'video/vnd.rn-realvideo',
3519 'avi' =>
'video/x-msvideo',
3520 'movie' =>
'video/x-sgi-movie'
3522 if (array_key_exists(strtolower(
$ext), $mimes)) {
3523 return $mimes[strtolower(
$ext)];
3525 return 'application/octet-stream';
3539 if (
false !== $qpos) {
3542 $pathinfo = self::mb_pathinfo(
$filename);
3543 return self::_mime_types($pathinfo[
'extension']);
3559 $ret = array(
'dirname' =>
'',
'basename' =>
'',
'extension' =>
'',
'filename' =>
'');
3560 $pathinfo = array();
3561 if (preg_match(
'%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im',
$path, $pathinfo)) {
3562 if (array_key_exists(1, $pathinfo)) {
3563 $ret[
'dirname'] = $pathinfo[1];
3565 if (array_key_exists(2, $pathinfo)) {
3566 $ret[
'basename'] = $pathinfo[2];
3568 if (array_key_exists(5, $pathinfo)) {
3569 $ret[
'extension'] = $pathinfo[5];
3571 if (array_key_exists(3, $pathinfo)) {
3572 $ret[
'filename'] = $pathinfo[3];
3576 case PATHINFO_DIRNAME:
3578 return $ret[
'dirname'];
3579 case PATHINFO_BASENAME:
3581 return $ret[
'basename'];
3582 case PATHINFO_EXTENSION:
3584 return $ret[
'extension'];
3585 case PATHINFO_FILENAME:
3587 return $ret[
'filename'];
3609 if (property_exists($this, $name)) {
3626 return trim(str_replace(array(
"\r",
"\n"),
'', $str));
3641 return preg_replace(
'/(\r\n|\r|\n)/ms', $breaktype, $text);
3652 public function sign($cert_filename, $key_filename, $key_pass, $extracerts_filename =
'')
3654 $this->sign_cert_file = $cert_filename;
3655 $this->sign_key_file = $key_filename;
3656 $this->sign_key_pass = $key_pass;
3657 $this->sign_extracerts_file = $extracerts_filename;
3669 for ($i = 0; $i < strlen($txt); $i++) {
3670 $ord = ord($txt[$i]);
3671 if (((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E))) {
3674 $line .=
'=' . sprintf(
'%02X', $ord);
3689 if (!defined(
'PKCS7_TEXT')) {
3690 if ($this->exceptions) {
3695 $privKeyStr = file_get_contents($this->DKIM_private);
3696 if ($this->DKIM_passphrase !=
'') {
3697 $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase);
3699 $privKey = $privKeyStr;
3701 if (openssl_sign($signHeader, $signature, $privKey)) {
3702 return base64_encode($signature);
3715 $signHeader = preg_replace(
'/\r\n\s+/',
' ', $signHeader);
3716 $lines = explode(
"\r\n", $signHeader);
3717 foreach ($lines as $key => $line) {
3718 list($heading,
$value) = explode(
':', $line, 2);
3719 $heading = strtolower($heading);
3721 $lines[$key] = $heading .
':' . trim(
$value);
3723 $signHeader = implode(
"\r\n", $lines);
3739 $body = str_replace(
"\r\n",
"\n", $body);
3740 $body = str_replace(
"\n",
"\r\n", $body);
3742 while (substr($body, strlen($body) - 4, 4) ==
"\r\n\r\n") {
3743 $body = substr($body, 0, strlen($body) - 2);
3758 $DKIMsignatureType =
'rsa-sha1';
3759 $DKIMcanonicalization =
'relaxed/simple';
3760 $DKIMquery =
'dns/txt';
3762 $subject_header =
"Subject: $subject";
3763 $headers = explode($this->LE, $headers_line);
3767 foreach ($headers as $header) {
3768 if (strpos($header,
'From:') === 0) {
3769 $from_header = $header;
3770 $current =
'from_header';
3771 } elseif (strpos($header,
'To:') === 0) {
3772 $to_header = $header;
3773 $current =
'to_header';
3775 if (!empty($$current) && strpos($header,
' =?') === 0) {
3776 $$current .= $header;
3782 $from = str_replace(
'|',
'=7C', $this->
DKIM_QP($from_header));
3783 $to = str_replace(
'|',
'=7C', $this->
DKIM_QP($to_header));
3787 $this->
DKIM_QP($subject_header)
3790 $DKIMlen = strlen($body);
3791 $DKIMb64 = base64_encode(pack(
'H*', sha1($body)));
3792 if (
'' == $this->DKIM_identity) {
3795 $ident =
' i=' . $this->DKIM_identity .
';';
3797 $dkimhdrs =
'DKIM-Signature: v=1; a=' .
3798 $DKIMsignatureType .
'; q=' .
3799 $DKIMquery .
'; l=' .
3801 $this->DKIM_selector .
3803 "\tt=" . $DKIMtime .
'; c=' . $DKIMcanonicalization .
";\r\n" .
3804 "\th=From:To:Subject;\r\n" .
3805 "\td=" . $this->DKIM_domain .
';' . $ident .
"\r\n" .
3808 "\t|$subject;\r\n" .
3809 "\tbh=" . $DKIMb64 .
";\r\n" .
3812 $from_header .
"\r\n" .
3813 $to_header .
"\r\n" .
3814 $subject_header .
"\r\n" .
3818 return $dkimhdrs . $signed .
"\r\n";
3830 return (
boolean)preg_match(
'/^(.{'.(self::MAX_LINE_LENGTH + 2).
',})/m', $str);
3900 if (!empty($this->action_function) && is_callable($this->action_function)) {
3902 call_user_func_array($this->action_function, $params);
3919 $errorMsg =
'<strong>' . $this->getMessage() .
"</strong><br />\n";
addCustomHeader($name, $value=null)
addStringAttachment($string, $filename, $encoding= 'base64', $type= '', $disposition= 'attachment')
encodeQ($str, $position= 'text')
attachAll($disposition_type, $boundary)
parseAddresses($addrstr, $useimap=true)
addAttachment($path, $name= '', $encoding= 'base64', $type= '', $disposition= 'attachment')
getAllRecipientAddresses()
DKIM_HeaderC($signHeader)
doCallback($isSent, $to, $cc, $bcc, $subject, $body, $from)
__construct($exceptions=false)
punyencodeAddress($address)
wrapText($message, $length, $qp_mode=false)
encodeFile($path, $encoding= 'base64')
addOrEnqueueAnAddress($kind, $address, $name)
sendmailSend($header, $body)
encodeQP($string, $line_max=76)
addStringEmbeddedImage($string, $cid, $name= '', $encoding= 'base64', $type= '', $disposition= 'inline')
getBoundary($boundary, $charSet, $contentType, $encoding)
encodeQPphp($string, $line_max=76, $space_conv=false)
addAnAddress($kind, $address, $name= '')
addEmbeddedImage($path, $cid, $name= '', $encoding= 'base64', $type= '', $disposition= 'inline')
addBCC($address, $name= '')
static normalizeBreaks($text, $breaktype="\r\n")
addCC($address, $name= '')
DKIM_Add($headers_line, $subject, $body)
static isShellSafe($string)
$PHPMAILER_LANG['authenticate']
headerLine($name, $value)
static mb_pathinfo($path, $options=null)
clearQueuedAddresses($kind)
static validateAddress($address, $patternselect= 'auto')
msgHTML($message, $basedir= '', $advanced=false)
utf8CharBoundary($encodedText, $maxLength)
static filenameToType($filename)
base64EncodeWrapMB($str, $linebreak=null)
static hasLineLongerThanMax($str)
encodeString($str, $encoding= 'base64')
html2text($html, $advanced=false)
static _mime_types($ext= '')
setFrom($address, $name= '', $auto=true)
sign($cert_filename, $key_filename, $key_pass, $extracerts_filename= '')
setLanguage($langcode= 'en', $lang_path= '')
encodeHeader($str, $position= 'text')
smtpConnect($options=array())
addReplyTo($address, $name= '')
addAddress($address, $name= '')