Viewing File server/base/phpmailer/class.phpmailer.php of 1.17.7a
|
' . $this->Lang('smtp_error') . $lasterror['smtp_msg'] . "
\n"; 1787: } 1788: } 1789: $this->ErrorInfo = $msg; 1790: } 1791: 1792: /** 1793: * Returns the proper RFC 822 formatted date. 1794: * @access public 1795: * @return string 1796: * @static 1797: */ 1798: public static function RFCDate() { 1799: $tz = date('Z'); 1800: $tzs = ($tz < 0) ? '-' : '+'; 1801: $tz = abs($tz); 1802: $tz = (int)($tz/3600)*100 + ($tz%3600)/60; 1803: $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz); 1804: 1805: return $result; 1806: } 1807: 1808: /** 1809: * Returns the server hostname or 'localhost.localdomain' if unknown. 1810: * @access private 1811: * @return string 1812: */ 1813: private function ServerHostname() { 1814: if (!empty($this->Hostname)) { 1815: $result = $this->Hostname; 1816: } elseif (isset($_SERVER['SERVER_NAME'])) { 1817: $result = $_SERVER['SERVER_NAME']; 1818: } else { 1819: $result = 'localhost.localdomain'; 1820: } 1821: 1822: return $result; 1823: } 1824: 1825: /** 1826: * Returns a message in the appropriate language. 1827: * @access private 1828: * @return string 1829: */ 1830: private function Lang($key) { 1831: if(count($this->language) < 1) { 1832: $this->SetLanguage('en'); // set the default language 1833: } 1834: 1835: if(isset($this->language[$key])) { 1836: return $this->language[$key]; 1837: } else { 1838: return 'Language string failed to load: ' . $key; 1839: } 1840: } 1841: 1842: /** 1843: * Returns true if an error occurred. 1844: * @access public 1845: * @return bool 1846: */ 1847: public function IsError() { 1848: return ($this->error_count > 0); 1849: } 1850: 1851: /** 1852: * Changes every end of line from CR or LF to CRLF. 1853: * @access private 1854: * @return string 1855: */ 1856: private function FixEOL($str) { 1857: $str = str_replace("\r\n", "\n", $str); 1858: $str = str_replace("\r", "\n", $str); 1859: $str = str_replace("\n", $this->LE, $str); 1860: return $str; 1861: } 1862: 1863: /** 1864: * Adds a custom header. 1865: * @access public 1866: * @return void 1867: */ 1868: public function AddCustomHeader($custom_header) { 1869: $this->CustomHeader[] = explode(':', $custom_header, 2); 1870: } 1871: 1872: /** 1873: * Evaluates the message and returns modifications for inline images and backgrounds 1874: * @access public 1875: * @return $message 1876: */ 1877: public function MsgHTML($message, $basedir = '') { 1878: preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images); 1879: if(isset($images[2])) { 1880: foreach($images[2] as $i => $url) { 1881: // do not change urls for absolute images (thanks to corvuscorax) 1882: if (!preg_match('#^[A-z]+://#',$url)) { 1883: $filename = basename($url); 1884: $directory = dirname($url); 1885: ($directory == '.')?$directory='':''; 1886: $cid = 'cid:' . md5($filename); 1887: $ext = pathinfo($filename, PATHINFO_EXTENSION); 1888: $mimeType = self::_mime_types($ext); 1889: if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; } 1890: if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; } 1891: if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) { 1892: $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message); 1893: } 1894: } 1895: } 1896: } 1897: $this->IsHTML(true); 1898: $this->Body = $message; 1899: $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message))); 1900: if (!empty($textMsg) && empty($this->AltBody)) { 1901: $this->AltBody = html_entity_decode($textMsg); 1902: } 1903: if (empty($this->AltBody)) { 1904: $this->AltBody = 'To view this email message, open it in a program that understands HTML!' . "\n\n"; 1905: } 1906: } 1907: 1908: /** 1909: * Gets the MIME type of the embedded or inline image 1910: * @param string File extension 1911: * @access public 1912: * @return string MIME type of ext 1913: * @static 1914: */ 1915: public static function _mime_types($ext = '') { 1916: $mimes = array( 1917: 'hqx' => 'application/mac-binhex40', 1918: 'cpt' => 'application/mac-compactpro', 1919: 'doc' => 'application/msword', 1920: 'bin' => 'application/macbinary', 1921: 'dms' => 'application/octet-stream', 1922: 'lha' => 'application/octet-stream', 1923: 'lzh' => 'application/octet-stream', 1924: 'exe' => 'application/octet-stream', 1925: 'class' => 'application/octet-stream', 1926: 'psd' => 'application/octet-stream', 1927: 'so' => 'application/octet-stream', 1928: 'sea' => 'application/octet-stream', 1929: 'dll' => 'application/octet-stream', 1930: 'oda' => 'application/oda', 1931: 'pdf' => 'application/pdf', 1932: 'ai' => 'application/postscript', 1933: 'eps' => 'application/postscript', 1934: 'ps' => 'application/postscript', 1935: 'smi' => 'application/smil', 1936: 'smil' => 'application/smil', 1937: 'mif' => 'application/vnd.mif', 1938: 'xls' => 'application/vnd.ms-excel', 1939: 'ppt' => 'application/vnd.ms-powerpoint', 1940: 'wbxml' => 'application/vnd.wap.wbxml', 1941: 'wmlc' => 'application/vnd.wap.wmlc', 1942: 'dcr' => 'application/x-director', 1943: 'dir' => 'application/x-director', 1944: 'dxr' => 'application/x-director', 1945: 'dvi' => 'application/x-dvi', 1946: 'gtar' => 'application/x-gtar', 1947: 'php' => 'application/x-httpd-php', 1948: 'php4' => 'application/x-httpd-php', 1949: 'php3' => 'application/x-httpd-php', 1950: 'phtml' => 'application/x-httpd-php', 1951: 'phps' => 'application/x-httpd-php-source', 1952: 'js' => 'application/x-javascript', 1953: 'swf' => 'application/x-shockwave-flash', 1954: 'sit' => 'application/x-stuffit', 1955: 'tar' => 'application/x-tar', 1956: 'tgz' => 'application/x-tar', 1957: 'xhtml' => 'application/xhtml+xml', 1958: 'xht' => 'application/xhtml+xml', 1959: 'zip' => 'application/zip', 1960: 'mid' => 'audio/midi', 1961: 'midi' => 'audio/midi', 1962: 'mpga' => 'audio/mpeg', 1963: 'mp2' => 'audio/mpeg', 1964: 'mp3' => 'audio/mpeg', 1965: 'aif' => 'audio/x-aiff', 1966: 'aiff' => 'audio/x-aiff', 1967: 'aifc' => 'audio/x-aiff', 1968: 'ram' => 'audio/x-pn-realaudio', 1969: 'rm' => 'audio/x-pn-realaudio', 1970: 'rpm' => 'audio/x-pn-realaudio-plugin', 1971: 'ra' => 'audio/x-realaudio', 1972: 'rv' => 'video/vnd.rn-realvideo', 1973: 'wav' => 'audio/x-wav', 1974: 'bmp' => 'image/bmp', 1975: 'gif' => 'image/gif', 1976: 'jpeg' => 'image/jpeg', 1977: 'jpg' => 'image/jpeg', 1978: 'jpe' => 'image/jpeg', 1979: 'png' => 'image/png', 1980: 'tiff' => 'image/tiff', 1981: 'tif' => 'image/tiff', 1982: 'css' => 'text/css', 1983: 'html' => 'text/html', 1984: 'htm' => 'text/html', 1985: 'shtml' => 'text/html', 1986: 'txt' => 'text/plain', 1987: 'text' => 'text/plain', 1988: 'log' => 'text/plain', 1989: 'rtx' => 'text/richtext', 1990: 'rtf' => 'text/rtf', 1991: 'xml' => 'text/xml', 1992: 'xsl' => 'text/xml', 1993: 'mpeg' => 'video/mpeg', 1994: 'mpg' => 'video/mpeg', 1995: 'mpe' => 'video/mpeg', 1996: 'qt' => 'video/quicktime', 1997: 'mov' => 'video/quicktime', 1998: 'avi' => 'video/x-msvideo', 1999: 'movie' => 'video/x-sgi-movie', 2000: 'doc' => 'application/msword', 2001: 'word' => 'application/msword', 2002: 'xl' => 'application/excel', 2003: 'eml' => 'message/rfc822' 2004: ); 2005: return (!isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)]; 2006: } 2007: 2008: /** 2009: * Set (or reset) Class Objects (variables) 2010: * 2011: * Usage Example: 2012: * $page->set('X-Priority', '3'); 2013: * 2014: * @access public 2015: * @param string $name Parameter Name 2016: * @param mixed $value Parameter Value 2017: * NOTE: will not work with arrays, there are no arrays to set/reset 2018: * @todo Should this not be using __set() magic function? 2019: */ 2020: public function set($name, $value = '') { 2021: try { 2022: if (isset($this->$name) ) { 2023: $this->$name = $value; 2024: } else { 2025: throw new phpmailerException($this->Lang('variable_set') . $name, self::STOP_CRITICAL); 2026: } 2027: } catch (Exception $e) { 2028: $this->SetError($e->getMessage()); 2029: if ($e->getCode() == self::STOP_CRITICAL) { 2030: return false; 2031: } 2032: } 2033: return true; 2034: } 2035: 2036: /** 2037: * Strips newlines to prevent header injection. 2038: * @access public 2039: * @param string $str String 2040: * @return string 2041: */ 2042: public function SecureHeader($str) { 2043: $str = str_replace("\r", '', $str); 2044: $str = str_replace("\n", '', $str); 2045: return trim($str); 2046: } 2047: 2048: /** 2049: * Set the private key file and password to sign the message. 2050: * 2051: * @access public 2052: * @param string $key_filename Parameter File Name 2053: * @param string $key_pass Password for private key 2054: */ 2055: public function Sign($cert_filename, $key_filename, $key_pass) { 2056: $this->sign_cert_file = $cert_filename; 2057: $this->sign_key_file = $key_filename; 2058: $this->sign_key_pass = $key_pass; 2059: } 2060: } 2061: 2062: class phpmailerException extends Exception { 2063: public function errorMessage() { 2064: $errorMsg = '' . $this->getMessage() . "