Guest User

Untitled

a guest
Jan 23rd, 2017
1,027
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 89.80 KB | None | 0 0
  1. <?php
  2. echo php_uname();
  3. function PHPMailerAutoload($classname)
  4. {
  5. $filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'class.' . strtolower($classname) . '.php';
  6. if (is_readable($filename)) {
  7. require $filename;
  8. }
  9. }
  10.  
  11. if (version_compare(PHP_VERSION, '5.1.2', '>=')) {
  12. if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
  13. spl_autoload_register('PHPMailerAutoload', true, true);
  14. } else {
  15. spl_autoload_register('PHPMailerAutoload');
  16. }
  17. } else {
  18. function __autoload($classname)
  19. {
  20. PHPMailerAutoload($classname);
  21. }
  22. }
  23. ?>
  24. <?php
  25.  
  26. class PHPMailer
  27. {
  28. public $Version = '5.2.8';
  29. public $Priority = 3;
  30. public $CharSet = 'iso-8859-1';
  31. public $ContentType = 'text/plain';
  32. public $Encoding = '8bit';
  33. public $ErrorInfo = '';
  34. public $From = 'root@localhost';
  35. public $FromName = 'Root User';
  36. public $Sender = '';
  37. public $ReturnPath = '';
  38. public $Subject = '';
  39. public $Body = '';
  40. public $AltBody = '';
  41. public $Ical = '';
  42. protected $MIMEBody = '';
  43. protected $MIMEHeader = '';
  44. protected $mailHeader = '';
  45. public $WordWrap = 0;
  46. public $Mailer = 'mail';
  47. public $Sendmail = '/usr/sbin/sendmail';
  48. public $UseSendmailOptions = true;
  49. public $PluginDir = '';
  50. public $ConfirmReadingTo = '';
  51. public $Hostname = '';
  52. public $MessageID = '';
  53. public $MessageDate = '';
  54. public $Host = 'localhost';
  55. public $Port = 25;
  56. public $Helo = '';
  57. public $SMTPSecure = '';
  58. public $SMTPAuth = false;
  59. public $Username = '';
  60. public $Password = '';
  61. public $AuthType = '';
  62. public $Realm = '';
  63. public $Workstation = '';
  64. public $Timeout = 10;
  65. public $SMTPDebug = 0;
  66. public $Debugoutput = 'echo';
  67. public $SMTPKeepAlive = false;
  68. public $SingleTo = false;
  69. public $SingleToArray = array();
  70. public $do_verp = false;
  71. public $AllowEmpty = false;
  72. public $LE = "\n";
  73. public $DKIM_selector = '';
  74. public $DKIM_identity = '';
  75. public $DKIM_passphrase = '';
  76. public $DKIM_domain = '';
  77. public $DKIM_private = '';
  78. public $action_function = '';
  79. public $XMailer = '';
  80. protected $smtp = null;
  81. protected $to = array();
  82. protected $cc = array();
  83. protected $bcc = array();
  84. protected $ReplyTo = array();
  85. protected $all_recipients = array();
  86. protected $attachment = array();
  87. protected $CustomHeader = array();
  88. protected $lastMessageID = '';
  89. protected $message_type = '';
  90. protected $boundary = array();
  91. protected $language = array();
  92. protected $error_count = 0;
  93. protected $sign_cert_file = '';
  94. protected $sign_key_file = '';
  95. protected $sign_key_pass = '';
  96. protected $exceptions = false;
  97. const STOP_MESSAGE = 0;
  98. const STOP_CONTINUE = 1;
  99. const STOP_CRITICAL = 2;
  100. const CRLF = "\r\n";
  101.  
  102. public function __construct($exceptions = false)
  103. {
  104. $this->exceptions = ($exceptions == true);
  105. if (version_compare(PHP_VERSION, '5.1.2', '>=')) {
  106. $autoload = spl_autoload_functions();
  107. if ($autoload === false or !in_array('PHPMailerAutoload', $autoload)) {
  108.  
  109. }
  110. }
  111. }
  112.  
  113. public function __destruct()
  114. {
  115. if ($this->Mailer == 'smtp') {
  116. $this->smtpClose();
  117. }
  118. }
  119.  
  120. private function mailPassthru($to, $subject, $body, $header, $params)
  121. {
  122. if (ini_get('mbstring.func_overload') & 1) {
  123. $subject = $this->secureHeader($subject);
  124. } else {
  125. $subject = $this->encodeHeader($this->secureHeader($subject));
  126. }
  127. if (ini_get('safe_mode') || !($this->UseSendmailOptions)) {
  128. $result = @mail($to, $subject, $body, $header);
  129. } else {
  130. $result = @mail($to, $subject, $body, $header, $params);
  131. }
  132. return $result;
  133. }
  134.  
  135. protected function edebug($str)
  136. {
  137. if (!$this->SMTPDebug) {
  138. return;
  139. }
  140. switch ($this->Debugoutput) {
  141. case 'error_log':
  142. error_log($str);
  143. break;
  144. case 'html':
  145. echo htmlentities(preg_replace('/[\r\n]+/', '', $str), ENT_QUOTES, $this->CharSet) . "<br>\n";
  146. break;
  147. case 'echo':
  148. default:
  149. echo $str . "\n";
  150. }
  151. }
  152.  
  153. public function isHTML($isHtml = true)
  154. {
  155. if ($isHtml) {
  156. $this->ContentType = 'text/html';
  157. } else {
  158. $this->ContentType = 'text/plain';
  159. }
  160. }
  161.  
  162. public function isSMTP()
  163. {
  164. $this->Mailer = 'smtp';
  165. }
  166.  
  167. public function isMail()
  168. {
  169. $this->Mailer = 'mail';
  170. }
  171.  
  172. public function isSendmail()
  173. {
  174. $ini_sendmail_path = ini_get('sendmail_path');
  175. if (!stristr($ini_sendmail_path, 'sendmail')) {
  176. $this->Sendmail = '/usr/sbin/sendmail';
  177. } else {
  178. $this->Sendmail = $ini_sendmail_path;
  179. }
  180. $this->Mailer = 'sendmail';
  181. }
  182.  
  183. public function isQmail()
  184. {
  185. $ini_sendmail_path = ini_get('sendmail_path');
  186. if (!stristr($ini_sendmail_path, 'qmail')) {
  187. $this->Sendmail = '/var/qmail/bin/qmail-inject';
  188. } else {
  189. $this->Sendmail = $ini_sendmail_path;
  190. }
  191. $this->Mailer = 'qmail';
  192. }
  193.  
  194. public function addAddress($address, $name = '')
  195. {
  196. return $this->addAnAddress('to', $address, $name);
  197. }
  198.  
  199. public function addCC($address, $name = '')
  200. {
  201. return $this->addAnAddress('cc', $address, $name);
  202. }
  203.  
  204. public function addBCC($address, $name = '')
  205. {
  206. return $this->addAnAddress('bcc', $address, $name);
  207. }
  208.  
  209. public function addReplyTo($address, $name = '')
  210. {
  211. return $this->addAnAddress('Reply-To', $address, $name);
  212. }
  213.  
  214. protected function addAnAddress($kind, $address, $name = '')
  215. {
  216. if (!preg_match('/^(to|cc|bcc|Reply-To)$/', $kind)) {
  217. $this->setError($this->lang('Invalid recipient array') . ': ' . $kind);
  218. $this->edebug($this->lang('Invalid recipient array') . ': ' . $kind);
  219. if ($this->exceptions) {
  220. throw new phpmailerException('Invalid recipient array: ' . $kind);
  221. }
  222. return false;
  223. }
  224. $address = trim($address);
  225. $name = trim(preg_replace('/[\r\n]+/', '', $name));
  226. if (!$this->validateAddress($address)) {
  227. $this->setError($this->lang('invalid_address') . ': ' . $address);
  228. $this->edebug($this->lang('invalid_address') . ': ' . $address);
  229. if ($this->exceptions) {
  230. throw new phpmailerException($this->lang('invalid_address') . ': ' . $address);
  231. }
  232. return false;
  233. }
  234. if ($kind != 'Reply-To') {
  235. if (!isset($this->all_recipients[strtolower($address)])) {
  236. array_push($this->$kind, array($address, $name));
  237. $this->all_recipients[strtolower($address)] = true;
  238. return true;
  239. }
  240. } else {
  241. if (!array_key_exists(strtolower($address), $this->ReplyTo)) {
  242. $this->ReplyTo[strtolower($address)] = array($address, $name);
  243. return true;
  244. }
  245. }
  246. return false;
  247. }
  248.  
  249. public function setFrom($address, $name = '', $auto = true)
  250. {
  251. $address = trim($address);
  252. $name = trim(preg_replace('/[\r\n]+/', '', $name));
  253. if (!$this->validateAddress($address)) {
  254. $this->setError($this->lang('invalid_address') . ': ' . $address);
  255. $this->edebug($this->lang('invalid_address') . ': ' . $address);
  256. if ($this->exceptions) {
  257. throw new phpmailerException($this->lang('invalid_address') . ': ' . $address);
  258. }
  259. return false;
  260. }
  261. $this->From = $address;
  262. $this->FromName = $name;
  263. if ($auto) {
  264. if (empty($this->Sender)) {
  265. $this->Sender = $address;
  266. }
  267. }
  268. return true;
  269. }
  270.  
  271. public function getLastMessageID()
  272. {
  273. return $this->lastMessageID;
  274. }
  275.  
  276. public static function validateAddress($address, $patternselect = 'auto')
  277. {
  278. if (!$patternselect or $patternselect == 'auto') {
  279. if (defined('PCRE_VERSION')) {
  280. if (version_compare(PCRE_VERSION, '8.0') >= 0) {
  281. $patternselect = 'pcre8';
  282. } else {
  283. $patternselect = 'pcre';
  284. }
  285. } else {
  286. if (version_compare(PHP_VERSION, '5.2.0') >= 0) {
  287. $patternselect = 'php';
  288. } else {
  289. $patternselect = 'noregex';
  290. }
  291. }
  292. }
  293. switch ($patternselect) {
  294. case 'pcre8':
  295. return (boolean)preg_match('/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)' . '((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)' . '(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)' . '([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*' . '(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)' . '(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}' . '|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:' . '|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}' . '|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD', $address);
  296. case 'pcre':
  297. return (boolean)preg_match('/^(?!(?>"?(?>\\\[ -~]|[^"])"?){255,})(?!(?>"?(?>\\\[ -~]|[^"])"?){65,}@)(?>' . '[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*")' . '(?>\.(?>[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*"))*' . '@(?>(?![a-z0-9-]{64,})(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)(?>\.(?![a-z0-9-]{64,})' . '(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)){0,126}|\[(?:(?>IPv6:(?>(?>[a-f0-9]{1,4})(?>:' . '[a-f0-9]{1,4}){7}|(?!(?:.*[a-f0-9][:\]]){8,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?' . '::(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?))|(?>(?>IPv6:(?>[a-f0-9]{1,4}(?>:' . '[a-f0-9]{1,4}){5}:|(?!(?:.*[a-f0-9]:){6,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4})?' . '::(?>(?:[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4}):)?))?(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}' . '|[1-9]?[0-9])(?>\.(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}))\])$/isD', $address);
  298. case 'html5':
  299. return (boolean)preg_match('/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}' . '[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/sD', $address);
  300. case 'noregex':
  301. return (strlen($address) >= 3 and strpos($address, '@') >= 1 and strpos($address, '@') != strlen($address) - 1);
  302. case 'php':
  303. default:
  304. return (boolean)filter_var($address, FILTER_VALIDATE_EMAIL);
  305. }
  306. }
  307.  
  308. public function send()
  309. {
  310. try {
  311. if (!$this->preSend()) {
  312. return false;
  313. }
  314. return $this->postSend();
  315. } catch (phpmailerException $exc) {
  316. $this->mailHeader = '';
  317. $this->setError($exc->getMessage());
  318. if ($this->exceptions) {
  319. throw $exc;
  320. }
  321. return false;
  322. }
  323. }
  324.  
  325. public function preSend()
  326. {
  327. try {
  328. $this->mailHeader = '';
  329. if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
  330. throw new phpmailerException($this->lang('provide_address'), self::STOP_CRITICAL);
  331. }
  332. if (!empty($this->AltBody)) {
  333. $this->ContentType = 'multipart/alternative';
  334. }
  335. $this->error_count = 0;
  336. $this->setMessageType();
  337. if (!$this->AllowEmpty and empty($this->Body)) {
  338. throw new phpmailerException($this->lang('empty_message'), self::STOP_CRITICAL);
  339. }
  340. $this->MIMEHeader = $this->createHeader();
  341. $this->MIMEBody = $this->createBody();
  342. if ($this->Mailer == 'mail') {
  343. if (count($this->to) > 0) {
  344. $this->mailHeader .= $this->addrAppend('To', $this->to);
  345. } else {
  346. $this->mailHeader .= $this->headerLine('To', 'undisclosed-recipients:;');
  347. }
  348. $this->mailHeader .= $this->headerLine('Subject', $this->encodeHeader($this->secureHeader(trim($this->Subject))));
  349. }
  350. if (!empty($this->DKIM_domain) && !empty($this->DKIM_private) && !empty($this->DKIM_selector) && !empty($this->DKIM_domain) && file_exists($this->DKIM_private)) {
  351. $header_dkim = $this->DKIM_Add($this->MIMEHeader . $this->mailHeader, $this->encodeHeader($this->secureHeader($this->Subject)), $this->MIMEBody);
  352. $this->MIMEHeader = rtrim($this->MIMEHeader, "\r\n ") . self::CRLF . str_replace("\r\n", "\n", $header_dkim) . self::CRLF;
  353. }
  354. return true;
  355. } catch (phpmailerException $exc) {
  356. $this->setError($exc->getMessage());
  357. if ($this->exceptions) {
  358. throw $exc;
  359. }
  360. return false;
  361. }
  362. }
  363.  
  364. public function postSend()
  365. {
  366. try {
  367. switch ($this->Mailer) {
  368. case 'sendmail':
  369. case 'qmail':
  370. return $this->sendmailSend($this->MIMEHeader, $this->MIMEBody);
  371. case 'smtp':
  372. return $this->smtpSend($this->MIMEHeader, $this->MIMEBody);
  373. case 'mail':
  374. return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
  375. default:
  376. $sendMethod = $this->Mailer . 'Send';
  377. if (method_exists($this, $sendMethod)) {
  378. return $this->$sendMethod($this->MIMEHeader, $this->MIMEBody);
  379. }
  380. return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
  381. }
  382. } catch (phpmailerException $exc) {
  383. $this->setError($exc->getMessage());
  384. $this->edebug($exc->getMessage());
  385. if ($this->exceptions) {
  386. throw $exc;
  387. }
  388. }
  389. return false;
  390. }
  391.  
  392. protected function sendmailSend($header, $body)
  393. {
  394. if ($this->Sender != '') {
  395. if ($this->Mailer == 'qmail') {
  396. $sendmail = sprintf('%s -f%s', escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
  397. } else {
  398. $sendmail = sprintf('%s -oi -f%s -t', escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
  399. }
  400. } else {
  401. if ($this->Mailer == 'qmail') {
  402. $sendmail = sprintf('%s', escapeshellcmd($this->Sendmail));
  403. } else {
  404. $sendmail = sprintf('%s -oi -t', escapeshellcmd($this->Sendmail));
  405. }
  406. }
  407. if ($this->SingleTo === true) {
  408. foreach ($this->SingleToArray as $toAddr) {
  409. if (!@$mail = popen($sendmail, 'w')) {
  410. throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
  411. }
  412. fputs($mail, 'To: ' . $toAddr . "\n");
  413. fputs($mail, $header);
  414. fputs($mail, $body);
  415. $result = pclose($mail);
  416. $this->doCallback(($result == 0), array($toAddr), $this->cc, $this->bcc, $this->Subject, $body, $this->From);
  417. if ($result != 0) {
  418. throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
  419. }
  420. }
  421. } else {
  422. if (!@$mail = popen($sendmail, 'w')) {
  423. throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
  424. }
  425. fputs($mail, $header);
  426. fputs($mail, $body);
  427. $result = pclose($mail);
  428. $this->doCallback(($result == 0), $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From);
  429. if ($result != 0) {
  430. throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
  431. }
  432. }
  433. return true;
  434. }
  435.  
  436. protected function mailSend($header, $body)
  437. {
  438. $toArr = array();
  439. foreach ($this->to as $toaddr) {
  440. $toArr[] = $this->addrFormat($toaddr);
  441. }
  442. $to = implode(', ', $toArr);
  443. if (empty($this->Sender)) {
  444. $params = ' ';
  445. } else {
  446. $params = sprintf('-f%s', $this->Sender);
  447. }
  448. if ($this->Sender != '' and !ini_get('safe_mode')) {
  449. $old_from = ini_get('sendmail_from');
  450. ini_set('sendmail_from', $this->Sender);
  451. }
  452. $result = false;
  453. if ($this->SingleTo === true && count($toArr) > 1) {
  454. foreach ($toArr as $toAddr) {
  455. $result = $this->mailPassthru($toAddr, $this->Subject, $body, $header, $params);
  456. $this->doCallback($result, array($toAddr), $this->cc, $this->bcc, $this->Subject, $body, $this->From);
  457. }
  458. } else {
  459. $result = $this->mailPassthru($to, $this->Subject, $body, $header, $params);
  460. $this->doCallback($result, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From);
  461. }
  462. if (isset($old_from)) {
  463. ini_set('sendmail_from', $old_from);
  464. }
  465. if (!$result) {
  466. throw new phpmailerException($this->lang('instantiate'), self::STOP_CRITICAL);
  467. }
  468. return true;
  469. }
  470.  
  471. public function getSMTPInstance()
  472. {
  473. if (!is_object($this->smtp)) {
  474. $this->smtp = new SMTP;
  475. }
  476. return $this->smtp;
  477. }
  478.  
  479. protected function smtpSend($header, $body)
  480. {
  481. $bad_rcpt = array();
  482. if (!$this->smtpConnect()) {
  483. throw new phpmailerException($this->lang('smtp_connect_failed'), self::STOP_CRITICAL);
  484. }
  485. $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
  486. if (!$this->smtp->mail($smtp_from)) {
  487. $this->setError($this->lang('from_failed') . $smtp_from . ' : ' . implode(',', $this->smtp->getError()));
  488. throw new phpmailerException($this->ErrorInfo, self::STOP_CRITICAL);
  489. }
  490. foreach ($this->to as $to) {
  491. if (!$this->smtp->recipient($to[0])) {
  492. $bad_rcpt[] = $to[0];
  493. $isSent = false;
  494. } else {
  495. $isSent = true;
  496. }
  497. $this->doCallback($isSent, array($to[0]), array(), array(), $this->Subject, $body, $this->From);
  498. }
  499. foreach ($this->cc as $cc) {
  500. if (!$this->smtp->recipient($cc[0])) {
  501. $bad_rcpt[] = $cc[0];
  502. $isSent = false;
  503. } else {
  504. $isSent = true;
  505. }
  506. $this->doCallback($isSent, array(), array($cc[0]), array(), $this->Subject, $body, $this->From);
  507. }
  508. foreach ($this->bcc as $bcc) {
  509. if (!$this->smtp->recipient($bcc[0])) {
  510. $bad_rcpt[] = $bcc[0];
  511. $isSent = false;
  512. } else {
  513. $isSent = true;
  514. }
  515. $this->doCallback($isSent, array(), array(), array($bcc[0]), $this->Subject, $body, $this->From);
  516. }
  517. if ((count($this->all_recipients) > count($bad_rcpt)) and !$this->smtp->data($header . $body)) {
  518. throw new phpmailerException($this->lang('data_not_accepted'), self::STOP_CRITICAL);
  519. }
  520. if ($this->SMTPKeepAlive == true) {
  521. $this->smtp->reset();
  522. } else {
  523. $this->smtp->quit();
  524. $this->smtp->close();
  525. }
  526. if (count($bad_rcpt) > 0) {
  527. throw new phpmailerException($this->lang('recipients_failed') . implode(', ', $bad_rcpt), self::STOP_CONTINUE);
  528. }
  529. return true;
  530. }
  531.  
  532. public function smtpConnect($options = array())
  533. {
  534. if (is_null($this->smtp)) {
  535. $this->smtp = $this->getSMTPInstance();
  536. }
  537. if ($this->smtp->connected()) {
  538. return true;
  539. }
  540. $this->smtp->setTimeout($this->Timeout);
  541. $this->smtp->setDebugLevel($this->SMTPDebug);
  542. $this->smtp->setDebugOutput($this->Debugoutput);
  543. $this->smtp->setVerp($this->do_verp);
  544. $hosts = explode(';', $this->Host);
  545. $lastexception = null;
  546. foreach ($hosts as $hostentry) {
  547. $hostinfo = array();
  548. if (!preg_match('/^((ssl|tls):\/\/)*([a-zA-Z0-9\.-]*):?([0-9]*)$/', trim($hostentry), $hostinfo)) {
  549. continue;
  550. }
  551. $prefix = '';
  552. $tls = ($this->SMTPSecure == 'tls');
  553. if ($hostinfo[2] == 'ssl' or ($hostinfo[2] == '' and $this->SMTPSecure == 'ssl')) {
  554. $prefix = 'ssl://';
  555. $tls = false;
  556. } elseif ($hostinfo[2] == 'tls') {
  557. $tls = true;
  558. }
  559. $host = $hostinfo[3];
  560. $port = $this->Port;
  561. $tport = (integer)$hostinfo[4];
  562. if ($tport > 0 and $tport < 65536) {
  563. $port = $tport;
  564. }
  565. if ($this->smtp->connect($prefix . $host, $port, $this->Timeout, $options)) {
  566. try {
  567. if ($this->Helo) {
  568. $hello = $this->Helo;
  569. } else {
  570. $hello = $this->serverHostname();
  571. }
  572. $this->smtp->hello($hello);
  573. if ($tls) {
  574. if (!$this->smtp->startTLS()) {
  575. throw new phpmailerException($this->lang('connect_host'));
  576. }
  577. $this->smtp->hello($hello);
  578. }
  579. if ($this->SMTPAuth) {
  580. if (!$this->smtp->authenticate($this->Username, $this->Password, $this->AuthType, $this->Realm, $this->Workstation)) {
  581. throw new phpmailerException($this->lang('authenticate'));
  582. }
  583. }
  584. return true;
  585. } catch (phpmailerException $exc) {
  586. $lastexception = $exc;
  587. $this->smtp->quit();
  588. }
  589. }
  590. }
  591. $this->smtp->close();
  592. if ($this->exceptions and !is_null($lastexception)) {
  593. throw $lastexception;
  594. }
  595. return false;
  596. }
  597.  
  598. public function smtpClose()
  599. {
  600. if ($this->smtp !== null) {
  601. if ($this->smtp->connected()) {
  602. $this->smtp->quit();
  603. $this->smtp->close();
  604. }
  605. }
  606. }
  607.  
  608. public function setLanguage($langcode = 'en', $lang_path = '')
  609. {
  610. $PHPMAILER_LANG = array('authenticate' => 'SMTP Error: Could not authenticate.', 'connect_host' => 'SMTP Error: Could not connect to SMTP host.', 'data_not_accepted' => 'SMTP Error: data not accepted.', 'empty_message' => 'Message body empty', 'encoding' => 'Unknown encoding: ', 'execute' => 'Could not execute: ', 'file_access' => 'Could not access file: ', 'file_open' => 'File Error: Could not open file: ', 'from_failed' => 'The following From address failed: ', 'instantiate' => 'Could not instantiate mail function.', 'invalid_address' => 'Invalid address', 'mailer_not_supported' => ' mailer is not supported.', 'provide_address' => 'You must provide at least one recipient email address.', 'recipients_failed' => 'SMTP Error: The following recipients failed: ', 'signing' => 'Signing Error: ', 'smtp_connect_failed' => 'SMTP connect() failed.', 'smtp_error' => 'SMTP server error: ', 'variable_set' => 'Cannot set or reset variable: ');
  611. if (empty($lang_path)) {
  612. $lang_path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'language' . DIRECTORY_SEPARATOR;
  613. }
  614. $foundlang = true;
  615. $lang_file = $lang_path . 'phpmailer.lang-' . $langcode . '.php';
  616. if ($langcode != 'en') {
  617. if (!is_readable($lang_file)) {
  618. $foundlang = false;
  619. } else {
  620. $foundlang = include $lang_file;
  621. }
  622. }
  623. $this->language = $PHPMAILER_LANG;
  624. return ($foundlang == true);
  625. }
  626.  
  627. public function getTranslations()
  628. {
  629. return $this->language;
  630. }
  631.  
  632. public function addrAppend($type, $addr)
  633. {
  634. $addresses = array();
  635. foreach ($addr as $address) {
  636. $addresses[] = $this->addrFormat($address);
  637. }
  638. return $type . ': ' . implode(', ', $addresses) . $this->LE;
  639. }
  640.  
  641. public function addrFormat($addr)
  642. {
  643. if (empty($addr[1])) {
  644. return $this->secureHeader($addr[0]);
  645. } else {
  646. return $this->encodeHeader($this->secureHeader($addr[1]), 'phrase') . ' <' . $this->secureHeader($addr[0]) . '>';
  647. }
  648. }
  649.  
  650. public function wrapText($message, $length, $qp_mode = false)
  651. {
  652. $soft_break = ($qp_mode) ? sprintf(' =%s', $this->LE) : $this->LE;
  653. $is_utf8 = (strtolower($this->CharSet) == 'utf-8');
  654. $lelen = strlen($this->LE);
  655. $crlflen = strlen(self::CRLF);
  656. $message = $this->fixEOL($message);
  657. if (substr($message, -$lelen) == $this->LE) {
  658. $message = substr($message, 0, -$lelen);
  659. }
  660. $line = explode($this->LE, $message);
  661. $message = '';
  662. for ($i = 0; $i < count($line); $i++) {
  663. $line_part = explode(' ', $line[$i]);
  664. $buf = '';
  665. for ($e = 0; $e < count($line_part); $e++) {
  666. $word = $line_part[$e];
  667. if ($qp_mode and (strlen($word) > $length)) {
  668. $space_left = $length - strlen($buf) - $crlflen;
  669. if ($e != 0) {
  670. if ($space_left > 20) {
  671. $len = $space_left;
  672. if ($is_utf8) {
  673. $len = $this->utf8CharBoundary($word, $len);
  674. } elseif (substr($word, $len - 1, 1) == '=') {
  675. $len--;
  676. } elseif (substr($word, $len - 2, 1) == '=') {
  677. $len -= 2;
  678. }
  679. $part = substr($word, 0, $len);
  680. $word = substr($word, $len);
  681. $buf .= ' ' . $part;
  682. $message .= $buf . sprintf('=%s', self::CRLF);
  683. } else {
  684. $message .= $buf . $soft_break;
  685. }
  686. $buf = '';
  687. }
  688. while (strlen($word) > 0) {
  689. if ($length <= 0) {
  690. break;
  691. }
  692. $len = $length;
  693. if ($is_utf8) {
  694. $len = $this->utf8CharBoundary($word, $len);
  695. } elseif (substr($word, $len - 1, 1) == '=') {
  696. $len--;
  697. } elseif (substr($word, $len - 2, 1) == '=') {
  698. $len -= 2;
  699. }
  700. $part = substr($word, 0, $len);
  701. $word = substr($word, $len);
  702. if (strlen($word) > 0) {
  703. $message .= $part . sprintf('=%s', self::CRLF);
  704. } else {
  705. $buf = $part;
  706. }
  707. }
  708. } else {
  709. $buf_o = $buf;
  710. $buf .= ($e == 0) ? $word : (' ' . $word);
  711. if (strlen($buf) > $length and $buf_o != '') {
  712. $message .= $buf_o . $soft_break;
  713. $buf = $word;
  714. }
  715. }
  716. }
  717. $message .= $buf . self::CRLF;
  718. }
  719. return $message;
  720. }
  721.  
  722. public function utf8CharBoundary($encodedText, $maxLength)
  723. {
  724. $foundSplitPos = false;
  725. $lookBack = 3;
  726. while (!$foundSplitPos) {
  727. $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack);
  728. $encodedCharPos = strpos($lastChunk, '=');
  729. if ($encodedCharPos !== false) {
  730. $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2);
  731. $dec = hexdec($hex);
  732. if ($dec < 128) {
  733. $maxLength = ($encodedCharPos == 0) ? $maxLength : $maxLength - ($lookBack - $encodedCharPos);
  734. $foundSplitPos = true;
  735. } elseif ($dec >= 192) {
  736. $maxLength = $maxLength - ($lookBack - $encodedCharPos);
  737. $foundSplitPos = true;
  738. } elseif ($dec < 192) {
  739. $lookBack += 3;
  740. }
  741. } else {
  742. $foundSplitPos = true;
  743. }
  744. }
  745. return $maxLength;
  746. }
  747.  
  748. public function setWordWrap()
  749. {
  750. if ($this->WordWrap < 1) {
  751. return;
  752. }
  753. switch ($this->message_type) {
  754. case 'alt':
  755. case 'alt_inline':
  756. case 'alt_attach':
  757. case 'alt_inline_attach':
  758. $this->AltBody = $this->wrapText($this->AltBody, $this->WordWrap);
  759. break;
  760. default:
  761. $this->Body = $this->wrapText($this->Body, $this->WordWrap);
  762. break;
  763. }
  764. }
  765.  
  766. public function createHeader()
  767. {
  768. $result = '';
  769. $uniq_id = md5(uniqid(time()));
  770. $this->boundary[1] = 'b1_' . $uniq_id;
  771. $this->boundary[2] = 'b2_' . $uniq_id;
  772. $this->boundary[3] = 'b3_' . $uniq_id;
  773. if ($this->MessageDate == '') {
  774. $this->MessageDate = self::rfcDate();
  775. }
  776. $result .= $this->headerLine('Date', $this->MessageDate);
  777. if ($this->SingleTo === true) {
  778. if ($this->Mailer != 'mail') {
  779. foreach ($this->to as $toaddr) {
  780. $this->SingleToArray[] = $this->addrFormat($toaddr);
  781. }
  782. }
  783. } else {
  784. if (count($this->to) > 0) {
  785. if ($this->Mailer != 'mail') {
  786. $result .= $this->addrAppend('To', $this->to);
  787. }
  788. } elseif (count($this->cc) == 0) {
  789. $result .= $this->headerLine('To', 'undisclosed-recipients:;');
  790. }
  791. }
  792. $result .= $this->addrAppend('From', array(array(trim($this->From), $this->FromName)));
  793. if (count($this->cc) > 0) {
  794. $result .= $this->addrAppend('Cc', $this->cc);
  795. }
  796. if (($this->Mailer == 'sendmail' or $this->Mailer == 'qmail' or $this->Mailer == 'mail') and count($this->bcc) > 0) {
  797. $result .= $this->addrAppend('Bcc', $this->bcc);
  798. }
  799. if (count($this->ReplyTo) > 0) {
  800. $result .= $this->addrAppend('Reply-To', $this->ReplyTo);
  801. }
  802. if ($this->Mailer != 'mail') {
  803. $result .= $this->headerLine('Subject', $this->encodeHeader($this->secureHeader($this->Subject)));
  804. }
  805. if ($this->MessageID != '') {
  806. $this->lastMessageID = $this->MessageID;
  807. } else {
  808. $this->lastMessageID = sprintf('<%s@%s>', $uniq_id, $this->ServerHostname());
  809. }
  810. $result .= $this->HeaderLine('Message-ID', $this->lastMessageID);
  811. $result .= $this->headerLine('X-Priority', $this->Priority);
  812. if ($this->XMailer == '') {
  813. $result .= $this->headerLine('X-Mailer', 'PHPMailer ' . $this->Version . 'Wahib Priv8 Mailer');
  814. } else {
  815. $myXmailer = trim($this->XMailer);
  816. if ($myXmailer) {
  817. $result .= $this->headerLine('X-Mailer', $myXmailer);
  818. }
  819. }
  820. if ($this->ConfirmReadingTo != '') {
  821. $result .= $this->headerLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
  822. }
  823. for ($index = 0; $index < count($this->CustomHeader); $index++) {
  824. $result .= $this->headerLine(trim($this->CustomHeader[$index][0]), $this->encodeHeader(trim($this->CustomHeader[$index][1])));
  825. }
  826. if (!$this->sign_key_file) {
  827. $result .= $this->headerLine('MIME-Version', '1.0');
  828. $result .= $this->getMailMIME();
  829. }
  830. return $result;
  831. }
  832.  
  833. public function getMailMIME()
  834. {
  835. $result = '';
  836. $ismultipart = true;
  837. switch ($this->message_type) {
  838. case 'inline':
  839. $result .= $this->headerLine('Content-Type', 'multipart/related;');
  840. $result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"');
  841. break;
  842. case 'attach':
  843. case 'inline_attach':
  844. case 'alt_attach':
  845. case 'alt_inline_attach':
  846. $result .= $this->headerLine('Content-Type', 'multipart/mixed;');
  847. $result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"');
  848. break;
  849. case 'alt':
  850. case 'alt_inline':
  851. $result .= $this->headerLine('Content-Type', 'multipart/alternative;');
  852. $result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"');
  853. break;
  854. default:
  855. $result .= $this->textLine('Content-Type: ' . $this->ContentType . '; charset=' . $this->CharSet);
  856. $ismultipart = false;
  857. break;
  858. }
  859. if ($this->Encoding != '7bit') {
  860. if ($ismultipart) {
  861. if ($this->Encoding == '8bit') {
  862. $result .= $this->headerLine('Content-Transfer-Encoding', '8bit');
  863. }
  864. } else {
  865. $result .= $this->headerLine('Content-Transfer-Encoding', $this->Encoding);
  866. }
  867. }
  868. if ($this->Mailer != 'mail') {
  869. $result .= $this->LE;
  870. }
  871. return $result;
  872. }
  873.  
  874. public function getSentMIMEMessage()
  875. {
  876. return $this->MIMEHeader . $this->mailHeader . self::CRLF . $this->MIMEBody;
  877. }
  878.  
  879. public function createBody()
  880. {
  881. $body = '';
  882. if ($this->sign_key_file) {
  883. $body .= $this->getMailMIME() . $this->LE;
  884. }
  885. $this->setWordWrap();
  886. $bodyEncoding = $this->Encoding;
  887. $bodyCharSet = $this->CharSet;
  888. if ($bodyEncoding == '8bit' and !$this->has8bitChars($this->Body)) {
  889. $bodyEncoding = '7bit';
  890. $bodyCharSet = 'us-ascii';
  891. }
  892. $altBodyEncoding = $this->Encoding;
  893. $altBodyCharSet = $this->CharSet;
  894. if ($altBodyEncoding == '8bit' and !$this->has8bitChars($this->AltBody)) {
  895. $altBodyEncoding = '7bit';
  896. $altBodyCharSet = 'us-ascii';
  897. }
  898. switch ($this->message_type) {
  899. case 'inline':
  900. $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding);
  901. $body .= $this->encodeString($this->Body, $bodyEncoding);
  902. $body .= $this->LE . $this->LE;
  903. $body .= $this->attachAll('inline', $this->boundary[1]);
  904. break;
  905. case 'attach':
  906. $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding);
  907. $body .= $this->encodeString($this->Body, $bodyEncoding);
  908. $body .= $this->LE . $this->LE;
  909. $body .= $this->attachAll('attachment', $this->boundary[1]);
  910. break;
  911. case 'inline_attach':
  912. $body .= $this->textLine('--' . $this->boundary[1]);
  913. $body .= $this->headerLine('Content-Type', 'multipart/related;');
  914. $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"');
  915. $body .= $this->LE;
  916. $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, '', $bodyEncoding);
  917. $body .= $this->encodeString($this->Body, $bodyEncoding);
  918. $body .= $this->LE . $this->LE;
  919. $body .= $this->attachAll('inline', $this->boundary[2]);
  920. $body .= $this->LE;
  921. $body .= $this->attachAll('attachment', $this->boundary[1]);
  922. break;
  923. case 'alt':
  924. $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, 'text/plain', $altBodyEncoding);
  925. $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
  926. $body .= $this->LE . $this->LE;
  927. $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, 'text/html', $bodyEncoding);
  928. $body .= $this->encodeString($this->Body, $bodyEncoding);
  929. $body .= $this->LE . $this->LE;
  930. if (!empty($this->Ical)) {
  931. $body .= $this->getBoundary($this->boundary[1], '', 'text/calendar; method=REQUEST', '');
  932. $body .= $this->encodeString($this->Ical, $this->Encoding);
  933. $body .= $this->LE . $this->LE;
  934. }
  935. $body .= $this->endBoundary($this->boundary[1]);
  936. break;
  937. case 'alt_inline':
  938. $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, 'text/plain', $altBodyEncoding);
  939. $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
  940. $body .= $this->LE . $this->LE;
  941. $body .= $this->textLine('--' . $this->boundary[1]);
  942. $body .= $this->headerLine('Content-Type', 'multipart/related;');
  943. $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"');
  944. $body .= $this->LE;
  945. $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, 'text/html', $bodyEncoding);
  946. $body .= $this->encodeString($this->Body, $bodyEncoding);
  947. $body .= $this->LE . $this->LE;
  948. $body .= $this->attachAll('inline', $this->boundary[2]);
  949. $body .= $this->LE;
  950. $body .= $this->endBoundary($this->boundary[1]);
  951. break;
  952. case 'alt_attach':
  953. $body .= $this->textLine('--' . $this->boundary[1]);
  954. $body .= $this->headerLine('Content-Type', 'multipart/alternative;');
  955. $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"');
  956. $body .= $this->LE;
  957. $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, 'text/plain', $altBodyEncoding);
  958. $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
  959. $body .= $this->LE . $this->LE;
  960. $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, 'text/html', $bodyEncoding);
  961. $body .= $this->encodeString($this->Body, $bodyEncoding);
  962. $body .= $this->LE . $this->LE;
  963. $body .= $this->endBoundary($this->boundary[2]);
  964. $body .= $this->LE;
  965. $body .= $this->attachAll('attachment', $this->boundary[1]);
  966. break;
  967. case 'alt_inline_attach':
  968. $body .= $this->textLine('--' . $this->boundary[1]);
  969. $body .= $this->headerLine('Content-Type', 'multipart/alternative;');
  970. $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"');
  971. $body .= $this->LE;
  972. $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, 'text/plain', $altBodyEncoding);
  973. $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
  974. $body .= $this->LE . $this->LE;
  975. $body .= $this->textLine('--' . $this->boundary[2]);
  976. $body .= $this->headerLine('Content-Type', 'multipart/related;');
  977. $body .= $this->textLine("\tboundary=\"" . $this->boundary[3] . '"');
  978. $body .= $this->LE;
  979. $body .= $this->getBoundary($this->boundary[3], $bodyCharSet, 'text/html', $bodyEncoding);
  980. $body .= $this->encodeString($this->Body, $bodyEncoding);
  981. $body .= $this->LE . $this->LE;
  982. $body .= $this->attachAll('inline', $this->boundary[3]);
  983. $body .= $this->LE;
  984. $body .= $this->endBoundary($this->boundary[2]);
  985. $body .= $this->LE;
  986. $body .= $this->attachAll('attachment', $this->boundary[1]);
  987. break;
  988. default:
  989. $body .= $this->encodeString($this->Body, $bodyEncoding);
  990. break;
  991. }
  992. if ($this->isError()) {
  993. $body = '';
  994. } elseif ($this->sign_key_file) {
  995. try {
  996. if (!defined('PKCS7_TEXT')) {
  997. throw new phpmailerException($this->lang('signing') . ' OpenSSL extension missing.');
  998. }
  999. $file = tempnam(sys_get_temp_dir(), 'mail');
  1000. file_put_contents($file, $body);
  1001. $signed = tempnam(sys_get_temp_dir(), 'signed');
  1002. if (@openssl_pkcs7_sign($file, $signed, 'file://' . realpath($this->sign_cert_file), array('file://' . realpath($this->sign_key_file), $this->sign_key_pass), null)) {
  1003. @unlink($file);
  1004. $body = file_get_contents($signed);
  1005. @unlink($signed);
  1006. } else {
  1007. @unlink($file);
  1008. @unlink($signed);
  1009. throw new phpmailerException($this->lang('signing') . openssl_error_string());
  1010. }
  1011. } catch (phpmailerException $exc) {
  1012. $body = '';
  1013. if ($this->exceptions) {
  1014. throw $exc;
  1015. }
  1016. }
  1017. }
  1018. return $body;
  1019. }
  1020.  
  1021. protected function getBoundary($boundary, $charSet, $contentType, $encoding)
  1022. {
  1023. $result = '';
  1024. if ($charSet == '') {
  1025. $charSet = $this->CharSet;
  1026. }
  1027. if ($contentType == '') {
  1028. $contentType = $this->ContentType;
  1029. }
  1030. if ($encoding == '') {
  1031. $encoding = $this->Encoding;
  1032. }
  1033. $result .= $this->textLine('--' . $boundary);
  1034. $result .= sprintf('Content-Type: %s; charset=%s', $contentType, $charSet);
  1035. $result .= $this->LE;
  1036. if ($encoding != '7bit') {
  1037. $result .= $this->headerLine('Content-Transfer-Encoding', $encoding);
  1038. }
  1039. $result .= $this->LE;
  1040. return $result;
  1041. }
  1042.  
  1043. protected function endBoundary($boundary)
  1044. {
  1045. return $this->LE . '--' . $boundary . '--' . $this->LE;
  1046. }
  1047.  
  1048. protected function setMessageType()
  1049. {
  1050. $this->message_type = array();
  1051. if ($this->alternativeExists()) {
  1052. $this->message_type[] = 'alt';
  1053. }
  1054. if ($this->inlineImageExists()) {
  1055. $this->message_type[] = 'inline';
  1056. }
  1057. if ($this->attachmentExists()) {
  1058. $this->message_type[] = 'attach';
  1059. }
  1060. $this->message_type = implode('_', $this->message_type);
  1061. if ($this->message_type == '') {
  1062. $this->message_type = 'plain';
  1063. }
  1064. }
  1065.  
  1066. public function headerLine($name, $value)
  1067. {
  1068. return $name . ': ' . $value . $this->LE;
  1069. }
  1070.  
  1071. public function textLine($value)
  1072. {
  1073. return $value . $this->LE;
  1074. }
  1075.  
  1076. public function addAttachment($path, $name = '', $encoding = 'base64', $type = '', $disposition = 'attachment')
  1077. {
  1078. try {
  1079. if (!@is_file($path)) {
  1080. throw new phpmailerException($this->lang('file_access') . $path, self::STOP_CONTINUE);
  1081. }
  1082. if ($type == '') {
  1083. $type = self::filenameToType($path);
  1084. }
  1085. $filename = basename($path);
  1086. if ($name == '') {
  1087. $name = $filename;
  1088. }
  1089. $this->attachment[] = array(0 => $path, 1 => $filename, 2 => $name, 3 => $encoding, 4 => $type, 5 => false, 6 => $disposition, 7 => 0);
  1090. } catch (phpmailerException $exc) {
  1091. $this->setError($exc->getMessage());
  1092. $this->edebug($exc->getMessage());
  1093. if ($this->exceptions) {
  1094. throw $exc;
  1095. }
  1096. return false;
  1097. }
  1098. return true;
  1099. }
  1100.  
  1101. public function getAttachments()
  1102. {
  1103. return $this->attachment;
  1104. }
  1105.  
  1106. protected function attachAll($disposition_type, $boundary)
  1107. {
  1108. $mime = array();
  1109. $cidUniq = array();
  1110. $incl = array();
  1111. foreach ($this->attachment as $attachment) {
  1112. if ($attachment[6] == $disposition_type) {
  1113. $string = '';
  1114. $path = '';
  1115. $bString = $attachment[5];
  1116. if ($bString) {
  1117. $string = $attachment[0];
  1118. } else {
  1119. $path = $attachment[0];
  1120. }
  1121. $inclhash = md5(serialize($attachment));
  1122. if (in_array($inclhash, $incl)) {
  1123. continue;
  1124. }
  1125. $incl[] = $inclhash;
  1126. $name = $attachment[2];
  1127. $encoding = $attachment[3];
  1128. $type = $attachment[4];
  1129. $disposition = $attachment[6];
  1130. $cid = $attachment[7];
  1131. if ($disposition == 'inline' && isset($cidUniq[$cid])) {
  1132. continue;
  1133. }
  1134. $cidUniq[$cid] = true;
  1135. $mime[] = sprintf('--%s%s', $boundary, $this->LE);
  1136. $mime[] = sprintf('Content-Type: %s; name="%s"%s', $type, $this->encodeHeader($this->secureHeader($name)), $this->LE);
  1137. if ($encoding != '7bit') {
  1138. $mime[] = sprintf('Content-Transfer-Encoding: %s%s', $encoding, $this->LE);
  1139. }
  1140. if ($disposition == 'inline') {
  1141. $mime[] = sprintf('Content-ID: <%s>%s', $cid, $this->LE);
  1142. }
  1143. if (!(empty($disposition))) {
  1144. if (preg_match('/[ \(\)<>@,;:\\"\/\[\]\?=]/', $name)) {
  1145. $mime[] = sprintf('Content-Disposition: %s; filename="%s"%s', $disposition, $this->encodeHeader($this->secureHeader($name)), $this->LE . $this->LE);
  1146. } else {
  1147. $mime[] = sprintf('Content-Disposition: %s; filename=%s%s', $disposition, $this->encodeHeader($this->secureHeader($name)), $this->LE . $this->LE);
  1148. }
  1149. } else {
  1150. $mime[] = $this->LE;
  1151. }
  1152. if ($bString) {
  1153. $mime[] = $this->encodeString($string, $encoding);
  1154. if ($this->isError()) {
  1155. return '';
  1156. }
  1157. $mime[] = $this->LE . $this->LE;
  1158. } else {
  1159. $mime[] = $this->encodeFile($path, $encoding);
  1160. if ($this->isError()) {
  1161. return '';
  1162. }
  1163. $mime[] = $this->LE . $this->LE;
  1164. }
  1165. }
  1166. }
  1167. $mime[] = sprintf('--%s--%s', $boundary, $this->LE);
  1168. return implode('', $mime);
  1169. }
  1170.  
  1171. protected function encodeFile($path, $encoding = 'base64')
  1172. {
  1173. try {
  1174. if (!is_readable($path)) {
  1175. throw new phpmailerException($this->lang('file_open') . $path, self::STOP_CONTINUE);
  1176. }
  1177. $magic_quotes = get_magic_quotes_runtime();
  1178. if ($magic_quotes) {
  1179. if (version_compare(PHP_VERSION, '5.3.0', '<')) {
  1180. set_magic_quotes_runtime(false);
  1181. } else {
  1182. ini_set('magic_quotes_runtime', 0);
  1183. }
  1184. }
  1185. $file_buffer = file_get_contents($path);
  1186. $file_buffer = $this->encodeString($file_buffer, $encoding);
  1187. if ($magic_quotes) {
  1188. if (version_compare(PHP_VERSION, '5.3.0', '<')) {
  1189. set_magic_quotes_runtime($magic_quotes);
  1190. } else {
  1191. ini_set('magic_quotes_runtime', ($magic_quotes ? '1' : '0'));
  1192. }
  1193. }
  1194. return $file_buffer;
  1195. } catch (Exception $exc) {
  1196. $this->setError($exc->getMessage());
  1197. return '';
  1198. }
  1199. }
  1200.  
  1201. public function encodeString($str, $encoding = 'base64')
  1202. {
  1203. $encoded = '';
  1204. switch (strtolower($encoding)) {
  1205. case 'base64':
  1206. $encoded = chunk_split(base64_encode($str), 76, $this->LE);
  1207. break;
  1208. case '7bit':
  1209. case '8bit':
  1210. $encoded = $this->fixEOL($str);
  1211. if (substr($encoded, -(strlen($this->LE))) != $this->LE) {
  1212. $encoded .= $this->LE;
  1213. }
  1214. break;
  1215. case 'binary':
  1216. $encoded = $str;
  1217. break;
  1218. case 'quoted-printable':
  1219. $encoded = $this->encodeQP($str);
  1220. break;
  1221. default:
  1222. $this->setError($this->lang('encoding') . $encoding);
  1223. break;
  1224. }
  1225. return $encoded;
  1226. }
  1227.  
  1228. public function encodeHeader($str, $position = 'text')
  1229. {
  1230. $matchcount = 0;
  1231. switch (strtolower($position)) {
  1232. case 'phrase':
  1233. if (!preg_match('/[\200-\377]/', $str)) {
  1234. $encoded = addcslashes($str, "\0..\37\177\\\"");
  1235. if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) {
  1236. return ($encoded);
  1237. } else {
  1238. return ("\"$encoded\"");
  1239. }
  1240. }
  1241. $matchcount = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
  1242. break;
  1243. case 'comment':
  1244. $matchcount = preg_match_all('/[()"]/', $str, $matches);
  1245. case 'text':
  1246. default:
  1247. $matchcount += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
  1248. break;
  1249. }
  1250. if ($matchcount == 0) {
  1251. return ($str);
  1252. }
  1253. $maxlen = 75 - 7 - strlen($this->CharSet);
  1254. if ($matchcount > strlen($str) / 3) {
  1255. $encoding = 'B';
  1256. if (function_exists('mb_strlen') && $this->hasMultiBytes($str)) {
  1257. $encoded = $this->base64EncodeWrapMB($str, "\n");
  1258. } else {
  1259. $encoded = base64_encode($str);
  1260. $maxlen -= $maxlen % 4;
  1261. $encoded = trim(chunk_split($encoded, $maxlen, "\n"));
  1262. }
  1263. } else {
  1264. $encoding = 'Q';
  1265. $encoded = $this->encodeQ($str, $position);
  1266. $encoded = $this->wrapText($encoded, $maxlen, true);
  1267. $encoded = str_replace('=' . self::CRLF, "\n", trim($encoded));
  1268. }
  1269. $encoded = preg_replace('/^(.*)$/m', ' =?' . $this->CharSet . "?$encoding?\\1?=", $encoded);
  1270. $encoded = trim(str_replace("\n", $this->LE, $encoded));
  1271. return $encoded;
  1272. }
  1273.  
  1274. public function hasMultiBytes($str)
  1275. {
  1276. if (function_exists('mb_strlen')) {
  1277. return (strlen($str) > mb_strlen($str, $this->CharSet));
  1278. } else {
  1279. return false;
  1280. }
  1281. }
  1282.  
  1283. public function has8bitChars($text)
  1284. {
  1285. return (boolean)preg_match('/[\x80-\xFF]/', $text);
  1286. }
  1287.  
  1288. public function base64EncodeWrapMB($str, $linebreak = null)
  1289. {
  1290. $start = '=?' . $this->CharSet . '?B?';
  1291. $end = '?=';
  1292. $encoded = '';
  1293. if ($linebreak === null) {
  1294. $linebreak = $this->LE;
  1295. }
  1296. $mb_length = mb_strlen($str, $this->CharSet);
  1297. $length = 75 - strlen($start) - strlen($end);
  1298. $ratio = $mb_length / strlen($str);
  1299. $avgLength = floor($length * $ratio * .75);
  1300. for ($i = 0; $i < $mb_length; $i += $offset) {
  1301. $lookBack = 0;
  1302. do {
  1303. $offset = $avgLength - $lookBack;
  1304. $chunk = mb_substr($str, $i, $offset, $this->CharSet);
  1305. $chunk = base64_encode($chunk);
  1306. $lookBack++;
  1307. } while (strlen($chunk) > $length);
  1308. $encoded .= $chunk . $linebreak;
  1309. }
  1310. $encoded = substr($encoded, 0, -strlen($linebreak));
  1311. return $encoded;
  1312. }
  1313.  
  1314. public function encodeQP($string, $line_max = 76)
  1315. {
  1316. if (function_exists('quoted_printable_encode')) {
  1317. return $this->fixEOL(quoted_printable_encode($string));
  1318. }
  1319. $string = str_replace(array('%20', '%0D%0A.', '%0D%0A', '%'), array(' ', "\r\n=2E", "\r\n", '='), rawurlencode($string));
  1320. $string = preg_replace('/[^\r\n]{' . ($line_max - 3) . '}[^=\r\n]{2}/', "$0=\r\n", $string);
  1321. return $this->fixEOL($string);
  1322. }
  1323.  
  1324. public function encodeQPphp($string, $line_max = 76, $space_conv = false)
  1325. {
  1326. return $this->encodeQP($string, $line_max);
  1327. }
  1328.  
  1329. public function encodeQ($str, $position = 'text')
  1330. {
  1331. $pattern = '';
  1332. $encoded = str_replace(array("\r", "\n"), '', $str);
  1333. switch (strtolower($position)) {
  1334. case 'phrase':
  1335. $pattern = '^A-Za-z0-9!*+\/ -';
  1336. break;
  1337. case 'comment':
  1338. $pattern = '\(\)"';
  1339. case 'text':
  1340. default:
  1341. $pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern;
  1342. break;
  1343. }
  1344. $matches = array();
  1345. if (preg_match_all("/[{$pattern}]/", $encoded, $matches)) {
  1346. $eqkey = array_search('=', $matches[0]);
  1347. if ($eqkey !== false) {
  1348. unset($matches[0][$eqkey]);
  1349. array_unshift($matches[0], '=');
  1350. }
  1351. foreach (array_unique($matches[0]) as $char) {
  1352. $encoded = str_replace($char, '=' . sprintf('%02X', ord($char)), $encoded);
  1353. }
  1354. }
  1355. return str_replace(' ', '_', $encoded);
  1356. }
  1357.  
  1358. public function addStringAttachment($string, $filename, $encoding = 'base64', $type = '', $disposition = 'attachment')
  1359. {
  1360. if ($type == '') {
  1361. $type = self::filenameToType($filename);
  1362. }
  1363. $this->attachment[] = array(0 => $string, 1 => $filename, 2 => basename($filename), 3 => $encoding, 4 => $type, 5 => true, 6 => $disposition, 7 => 0);
  1364. }
  1365.  
  1366. public function addEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = '', $disposition = 'inline')
  1367. {
  1368. if (!@is_file($path)) {
  1369. $this->setError($this->lang('file_access') . $path);
  1370. return false;
  1371. }
  1372. if ($type == '') {
  1373. $type = self::filenameToType($path);
  1374. }
  1375. $filename = basename($path);
  1376. if ($name == '') {
  1377. $name = $filename;
  1378. }
  1379. $this->attachment[] = array(0 => $path, 1 => $filename, 2 => $name, 3 => $encoding, 4 => $type, 5 => false, 6 => $disposition, 7 => $cid);
  1380. return true;
  1381. }
  1382.  
  1383. public function addStringEmbeddedImage($string, $cid, $name = '', $encoding = 'base64', $type = '', $disposition = 'inline')
  1384. {
  1385. if ($type == '') {
  1386. $type = self::filenameToType($name);
  1387. }
  1388. $this->attachment[] = array(0 => $string, 1 => $name, 2 => $name, 3 => $encoding, 4 => $type, 5 => true, 6 => $disposition, 7 => $cid);
  1389. return true;
  1390. }
  1391.  
  1392. public function inlineImageExists()
  1393. {
  1394. foreach ($this->attachment as $attachment) {
  1395. if ($attachment[6] == 'inline') {
  1396. return true;
  1397. }
  1398. }
  1399. return false;
  1400. }
  1401.  
  1402. public function attachmentExists()
  1403. {
  1404. foreach ($this->attachment as $attachment) {
  1405. if ($attachment[6] == 'attachment') {
  1406. return true;
  1407. }
  1408. }
  1409. return false;
  1410. }
  1411.  
  1412. public function alternativeExists()
  1413. {
  1414. return !empty($this->AltBody);
  1415. }
  1416.  
  1417. public function clearAddresses()
  1418. {
  1419. foreach ($this->to as $to) {
  1420. unset($this->all_recipients[strtolower($to[0])]);
  1421. }
  1422. $this->to = array();
  1423. }
  1424.  
  1425. public function clearCCs()
  1426. {
  1427. foreach ($this->cc as $cc) {
  1428. unset($this->all_recipients[strtolower($cc[0])]);
  1429. }
  1430. $this->cc = array();
  1431. }
  1432.  
  1433. public function clearBCCs()
  1434. {
  1435. foreach ($this->bcc as $bcc) {
  1436. unset($this->all_recipients[strtolower($bcc[0])]);
  1437. }
  1438. $this->bcc = array();
  1439. }
  1440.  
  1441. public function clearReplyTos()
  1442. {
  1443. $this->ReplyTo = array();
  1444. }
  1445.  
  1446. public function clearAllRecipients()
  1447. {
  1448. $this->to = array();
  1449. $this->cc = array();
  1450. $this->bcc = array();
  1451. $this->all_recipients = array();
  1452. }
  1453.  
  1454. public function clearAttachments()
  1455. {
  1456. $this->attachment = array();
  1457. }
  1458.  
  1459. public function clearCustomHeaders()
  1460. {
  1461. $this->CustomHeader = array();
  1462. }
  1463.  
  1464. protected function setError($msg)
  1465. {
  1466. $this->error_count++;
  1467. if ($this->Mailer == 'smtp' and !is_null($this->smtp)) {
  1468. $lasterror = $this->smtp->getError();
  1469. if (!empty($lasterror) and array_key_exists('smtp_msg', $lasterror)) {
  1470. $msg .= '<p>' . $this->lang('smtp_error') . $lasterror['smtp_msg'] . "</p>\n";
  1471. }
  1472. }
  1473. $this->ErrorInfo = $msg;
  1474. }
  1475.  
  1476. public static function rfcDate()
  1477. {
  1478. date_default_timezone_set(@date_default_timezone_get());
  1479. return date('D, j M Y H:i:s O');
  1480. }
  1481.  
  1482. protected function serverHostname()
  1483. {
  1484. $result = 'localhost.localdomain';
  1485. if (!empty($this->Hostname)) {
  1486. $result = $this->Hostname;
  1487. } elseif (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER) and !empty($_SERVER['SERVER_NAME'])) {
  1488. $result = $_SERVER['SERVER_NAME'];
  1489. } elseif (function_exists('gethostname') && gethostname() !== false) {
  1490. $result = gethostname();
  1491. } elseif (php_uname('n') !== false) {
  1492. $result = php_uname('n');
  1493. }
  1494. return $result;
  1495. }
  1496.  
  1497. protected function lang($key)
  1498. {
  1499. if (count($this->language) < 1) {
  1500. $this->setLanguage('en');
  1501. }
  1502. if (isset($this->language[$key])) {
  1503. return $this->language[$key];
  1504. } else {
  1505. return 'Language string failed to load: ' . $key;
  1506. }
  1507. }
  1508.  
  1509. public function isError()
  1510. {
  1511. return ($this->error_count > 0);
  1512. }
  1513.  
  1514. public function fixEOL($str)
  1515. {
  1516. $nstr = str_replace(array("\r\n", "\r"), "\n", $str);
  1517. if ($this->LE !== "\n") {
  1518. $nstr = str_replace("\n", $this->LE, $nstr);
  1519. }
  1520. return $nstr;
  1521. }
  1522.  
  1523. public function addCustomHeader($name, $value = null)
  1524. {
  1525. if ($value === null) {
  1526. $this->CustomHeader[] = explode(':', $name, 2);
  1527. } else {
  1528. $this->CustomHeader[] = array($name, $value);
  1529. }
  1530. }
  1531.  
  1532. public function msgHTML($message, $basedir = '', $advanced = false)
  1533. {
  1534. preg_match_all('/(src|background)=["\'](.*)["\']/Ui', $message, $images);
  1535. if (isset($images[2])) {
  1536. foreach ($images[2] as $imgindex => $url) {
  1537. if (!preg_match('#^[A-z]+://#', $url)) {
  1538. $filename = basename($url);
  1539. $directory = dirname($url);
  1540. if ($directory == '.') {
  1541. $directory = '';
  1542. }
  1543. $cid = md5($url) . '@phpmailer.0';
  1544. if (strlen($basedir) > 1 && substr($basedir, -1) != '/') {
  1545. $basedir .= '/';
  1546. }
  1547. if (strlen($directory) > 1 && substr($directory, -1) != '/') {
  1548. $directory .= '/';
  1549. }
  1550. if ($this->addEmbeddedImage($basedir . $directory . $filename, $cid, $filename, 'base64', self::_mime_types(self::mb_pathinfo($filename, PATHINFO_EXTENSION)))) {
  1551. $message = preg_replace('/' . $images[1][$imgindex] . '=["\']' . preg_quote($url, '/') . '["\']/Ui', $images[1][$imgindex] . '="cid:' . $cid . '"', $message);
  1552. }
  1553. }
  1554. }
  1555. }
  1556. $this->isHTML(true);
  1557. $this->Body = $this->normalizeBreaks($message);
  1558. $this->AltBody = $this->normalizeBreaks($this->html2text($message, $advanced));
  1559. if (empty($this->AltBody)) {
  1560. $this->AltBody = 'To view this email message, open it in a program that understands HTML!' . self::CRLF . self::CRLF;
  1561. }
  1562. return $this->Body;
  1563. }
  1564.  
  1565. public function html2text($html, $advanced = false)
  1566. {
  1567. if ($advanced) {
  1568. require_once 'extras/class.html2text.php';
  1569. $htmlconverter = new html2text($html);
  1570. return $htmlconverter->get_text();
  1571. }
  1572. return html_entity_decode(trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/si', '', $html))), ENT_QUOTES, $this->CharSet);
  1573. }
  1574.  
  1575. public static function _mime_types($ext = '')
  1576. {
  1577. $mimes = array('xl' => 'application/excel', 'hqx' => 'application/mac-binhex40', 'cpt' => 'application/mac-compactpro', 'bin' => 'application/macbinary', 'doc' => 'application/msword', 'word' => 'application/msword', 'class' => 'application/octet-stream', 'dll' => 'application/octet-stream', 'dms' => 'application/octet-stream', 'exe' => 'application/octet-stream', 'lha' => 'application/octet-stream', 'lzh' => 'application/octet-stream', 'psd' => 'application/octet-stream', 'sea' => 'application/octet-stream', 'so' => 'application/octet-stream', 'oda' => 'application/oda', 'pdf' => 'application/pdf', 'ai' => 'application/postscript', 'eps' => 'application/postscript', 'ps' => 'application/postscript', 'smi' => 'application/smil', 'smil' => 'application/smil', 'mif' => 'application/vnd.mif', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', 'wbxml' => 'application/vnd.wap.wbxml', 'wmlc' => 'application/vnd.wap.wmlc', 'dcr' => 'application/x-director', 'dir' => 'application/x-director', 'dxr' => 'application/x-director', 'dvi' => 'application/x-dvi', 'gtar' => 'application/x-gtar', 'php3' => 'application/x-httpd-php', 'php4' => 'application/x-httpd-php', 'php' => 'application/x-httpd-php', 'phtml' => 'application/x-httpd-php', 'phps' => 'application/x-httpd-php-source', 'js' => 'application/x-javascript', 'swf' => 'application/x-shockwave-flash', 'sit' => 'application/x-stuffit', 'tar' => 'application/x-tar', 'tgz' => 'application/x-tar', 'xht' => 'application/xhtml+xml', 'xhtml' => 'application/xhtml+xml', 'zip' => 'application/zip', 'mid' => 'audio/midi', 'midi' => 'audio/midi', 'mp2' => 'audio/mpeg', 'mp3' => 'audio/mpeg', 'mpga' => 'audio/mpeg', 'aif' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff', 'aiff' => 'audio/x-aiff', 'ram' => 'audio/x-pn-realaudio', 'rm' => 'audio/x-pn-realaudio', 'rpm' => 'audio/x-pn-realaudio-plugin', 'ra' => 'audio/x-realaudio', 'wav' => 'audio/x-wav', 'bmp' => 'image/bmp', 'gif' => 'image/gif', 'jpeg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'jpg' => 'image/jpeg', 'png' => 'image/png', 'tiff' => 'image/tiff', 'tif' => 'image/tiff', 'eml' => 'message/rfc822', 'css' => 'text/css', 'html' => 'text/html', 'htm' => 'text/html', 'shtml' => 'text/html', 'log' => 'text/plain', 'text' => 'text/plain', 'txt' => 'text/plain', 'rtx' => 'text/richtext', 'rtf' => 'text/rtf', 'vcf' => 'text/vcard', 'vcard' => 'text/vcard', 'xml' => 'text/xml', 'xsl' => 'text/xml', 'mpeg' => 'video/mpeg', 'mpe' => 'video/mpeg', 'mpg' => 'video/mpeg', 'mov' => 'video/quicktime', 'qt' => 'video/quicktime', 'rv' => 'video/vnd.rn-realvideo', 'avi' => 'video/x-msvideo', 'movie' => 'video/x-sgi-movie');
  1578. return (array_key_exists(strtolower($ext), $mimes) ? $mimes[strtolower($ext)] : 'application/octet-stream');
  1579. }
  1580.  
  1581. public static function filenameToType($filename)
  1582. {
  1583. $qpos = strpos($filename, '?');
  1584. if ($qpos !== false) {
  1585. $filename = substr($filename, 0, $qpos);
  1586. }
  1587. $pathinfo = self::mb_pathinfo($filename);
  1588. return self::_mime_types($pathinfo['extension']);
  1589. }
  1590.  
  1591. public static function mb_pathinfo($path, $options = null)
  1592. {
  1593. $ret = array('dirname' => '', 'basename' => '', 'extension' => '', 'filename' => '');
  1594. $pathinfo = array();
  1595. if (preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im', $path, $pathinfo)) {
  1596. if (array_key_exists(1, $pathinfo)) {
  1597. $ret['dirname'] = $pathinfo[1];
  1598. }
  1599. if (array_key_exists(2, $pathinfo)) {
  1600. $ret['basename'] = $pathinfo[2];
  1601. }
  1602. if (array_key_exists(5, $pathinfo)) {
  1603. $ret['extension'] = $pathinfo[5];
  1604. }
  1605. if (array_key_exists(3, $pathinfo)) {
  1606. $ret['filename'] = $pathinfo[3];
  1607. }
  1608. }
  1609. switch ($options) {
  1610. case PATHINFO_DIRNAME:
  1611. case 'dirname':
  1612. return $ret['dirname'];
  1613. case PATHINFO_BASENAME:
  1614. case 'basename':
  1615. return $ret['basename'];
  1616. case PATHINFO_EXTENSION:
  1617. case 'extension':
  1618. return $ret['extension'];
  1619. case PATHINFO_FILENAME:
  1620. case 'filename':
  1621. return $ret['filename'];
  1622. default:
  1623. return $ret;
  1624. }
  1625. }
  1626.  
  1627. public function set($name, $value = '')
  1628. {
  1629. try {
  1630. if (isset($this->$name)) {
  1631. $this->$name = $value;
  1632. } else {
  1633. throw new phpmailerException($this->lang('variable_set') . $name, self::STOP_CRITICAL);
  1634. }
  1635. } catch (Exception $exc) {
  1636. $this->setError($exc->getMessage());
  1637. if ($exc->getCode() == self::STOP_CRITICAL) {
  1638. return false;
  1639. }
  1640. }
  1641. return true;
  1642. }
  1643.  
  1644. public function secureHeader($str)
  1645. {
  1646. return trim(str_replace(array("\r", "\n"), '', $str));
  1647. }
  1648.  
  1649. public static function normalizeBreaks($text, $breaktype = "\r\n")
  1650. {
  1651. return preg_replace('/(\r\n|\r|\n)/ms', $breaktype, $text);
  1652. }
  1653.  
  1654. public function sign($cert_filename, $key_filename, $key_pass)
  1655. {
  1656. $this->sign_cert_file = $cert_filename;
  1657. $this->sign_key_file = $key_filename;
  1658. $this->sign_key_pass = $key_pass;
  1659. }
  1660.  
  1661. public function DKIM_QP($txt)
  1662. {
  1663. $line = '';
  1664. for ($i = 0; $i < strlen($txt); $i++) {
  1665. $ord = ord($txt[$i]);
  1666. if (((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E))) {
  1667. $line .= $txt[$i];
  1668. } else {
  1669. $line .= '=' . sprintf('%02X', $ord);
  1670. }
  1671. }
  1672. return $line;
  1673. }
  1674.  
  1675. public function DKIM_Sign($signHeader)
  1676. {
  1677. if (!defined('PKCS7_TEXT')) {
  1678. if ($this->exceptions) {
  1679. throw new phpmailerException($this->lang('signing') . ' OpenSSL extension missing.');
  1680. }
  1681. return '';
  1682. }
  1683. $privKeyStr = file_get_contents($this->DKIM_private);
  1684. if ($this->DKIM_passphrase != '') {
  1685. $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase);
  1686. } else {
  1687. $privKey = $privKeyStr;
  1688. }
  1689. if (openssl_sign($signHeader, $signature, $privKey)) {
  1690. return base64_encode($signature);
  1691. }
  1692. return '';
  1693. }
  1694.  
  1695. public function DKIM_HeaderC($signHeader)
  1696. {
  1697. $signHeader = preg_replace('/\r\n\s+/', ' ', $signHeader);
  1698. $lines = explode("\r\n", $signHeader);
  1699. foreach ($lines as $key => $line) {
  1700. list($heading, $value) = explode(':', $line, 2);
  1701. $heading = strtolower($heading);
  1702. $value = preg_replace('/\s+/', ' ', $value);
  1703. $lines[$key] = $heading . ':' . trim($value);
  1704. }
  1705. $signHeader = implode("\r\n", $lines);
  1706. return $signHeader;
  1707. }
  1708.  
  1709. public function DKIM_BodyC($body)
  1710. {
  1711. if ($body == '') {
  1712. return "\r\n";
  1713. }
  1714. $body = str_replace("\r\n", "\n", $body);
  1715. $body = str_replace("\n", "\r\n", $body);
  1716. while (substr($body, strlen($body) - 4, 4) == "\r\n\r\n") {
  1717. $body = substr($body, 0, strlen($body) - 2);
  1718. }
  1719. return $body;
  1720. }
  1721.  
  1722. public function DKIM_Add($headers_line, $subject, $body)
  1723. {
  1724. $DKIMsignatureType = 'rsa-sha1';
  1725. $DKIMcanonicalization = 'relaxed/simple';
  1726. $DKIMquery = 'dns/txt';
  1727. $DKIMtime = time();
  1728. $subject_header = "Subject: $subject";
  1729. $headers = explode($this->LE, $headers_line);
  1730. $from_header = '';
  1731. $to_header = '';
  1732. $current = '';
  1733. foreach ($headers as $header) {
  1734. if (strpos($header, 'From:') === 0) {
  1735. $from_header = $header;
  1736. $current = 'from_header';
  1737. } elseif (strpos($header, 'To:') === 0) {
  1738. $to_header = $header;
  1739. $current = 'to_header';
  1740. } else {
  1741. if ($current && strpos($header, ' =?') === 0) {
  1742. $current .= $header;
  1743. } else {
  1744. $current = '';
  1745. }
  1746. }
  1747. }
  1748. $from = str_replace('|', '=7C', $this->DKIM_QP($from_header));
  1749. $to = str_replace('|', '=7C', $this->DKIM_QP($to_header));
  1750. $subject = str_replace('|', '=7C', $this->DKIM_QP($subject_header));
  1751. $body = $this->DKIM_BodyC($body);
  1752. $DKIMlen = strlen($body);
  1753. $DKIMb64 = base64_encode(pack('H*', sha1($body)));
  1754. $ident = ($this->DKIM_identity == '') ? '' : ' i=' . $this->DKIM_identity . ';';
  1755. $dkimhdrs = 'DKIM-Signature: v=1; a=' . $DKIMsignatureType . '; q=' . $DKIMquery . '; l=' . $DKIMlen . '; s=' . $this->DKIM_selector . ";\r\n" . "\tt=" . $DKIMtime . '; c=' . $DKIMcanonicalization . ";\r\n" . "\th=From:To:Subject;\r\n" . "\td=" . $this->DKIM_domain . ';' . $ident . "\r\n" . "\tz=$from\r\n" . "\t|$to\r\n" . "\t|$subject;\r\n" . "\tbh=" . $DKIMb64 . ";\r\n" . "\tb=";
  1756. $toSign = $this->DKIM_HeaderC($from_header . "\r\n" . $to_header . "\r\n" . $subject_header . "\r\n" . $dkimhdrs);
  1757. $signed = $this->DKIM_Sign($toSign);
  1758. return $dkimhdrs . $signed . "\r\n";
  1759. }
  1760.  
  1761. public function getToAddresses()
  1762. {
  1763. return $this->to;
  1764. }
  1765.  
  1766. public function getCcAddresses()
  1767. {
  1768. return $this->cc;
  1769. }
  1770.  
  1771. public function getBccAddresses()
  1772. {
  1773. return $this->bcc;
  1774. }
  1775.  
  1776. public function getReplyToAddresses()
  1777. {
  1778. return $this->ReplyTo;
  1779. }
  1780.  
  1781. public function getAllRecipientAddresses()
  1782. {
  1783. return $this->all_recipients;
  1784. }
  1785.  
  1786. protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body, $from)
  1787. {
  1788. if (!empty($this->action_function) && is_callable($this->action_function)) {
  1789. $params = array($isSent, $to, $cc, $bcc, $subject, $body, $from);
  1790. call_user_func_array($this->action_function, $params);
  1791. }
  1792. }
  1793. }
  1794.  
  1795. class phpmailerException extends Exception
  1796. {
  1797. public function errorMessage()
  1798. {
  1799. $errorMsg = '<strong>' . $this->getMessage() . "</strong><br />\n";
  1800. return $errorMsg;
  1801. }
  1802. }
  1803. ?>
  1804.  
  1805. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  1806. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  1807. <html xmlns="http://www.w3.org/1999/xhtml">
  1808. <head>
  1809. <title>.: Wahib Mkadmi Priv8 Mail3R :.</title>
  1810.  
  1811. <!-- TODO re-add jquery form validation -->
  1812.  
  1813. <style type="text/css">
  1814. /*<![CDATA[*/
  1815. <!--
  1816. .style1 {
  1817. font-size: 20px;
  1818. font-family: Geneva, Arial, Helvetica, sans-serif;
  1819. }
  1820. -->
  1821. /*]]>*/
  1822. </style>
  1823. <style type="text/css">
  1824. /*<![CDATA[*/
  1825. <!--
  1826. .style1 {
  1827. font-family: Geneva, Arial, Helvetica, sans-serif;
  1828. font-size: 20px;
  1829. }
  1830. -->
  1831. /*]]>*/
  1832. </style>
  1833. <style type="text/css">
  1834. /*<![CDATA[*/
  1835. <!--
  1836. .style1 {
  1837. font-size: 60px;
  1838. font-family: Geneva, Arial, Helvetica, sans-serif;
  1839. }
  1840. body {
  1841. background-color: #000000;
  1842. }
  1843. -->
  1844. /*]]>*/
  1845. </style>
  1846. <style type="text/css">
  1847. /*<![CDATA[*/
  1848. body {
  1849. color: white;
  1850. }
  1851. div.c6 {
  1852. text-align: right
  1853. }
  1854. p.c5 {
  1855. font-family: Verdana, Arial, Helvetica, sans-serif;
  1856. font-size: 100%
  1857. }
  1858. span.c4 {
  1859. font-family: Verdana, Arial, Helvetica, sans-serif;
  1860. font-size: 100%
  1861. }
  1862. div.c3 {
  1863. font-family: Verdana, Arial, Helvetica, sans-serif;
  1864. font-size: 70%;
  1865. text-align: right
  1866. }
  1867. span.c3 {
  1868. font-family: Verdana, Arial, Helvetica, sans-serif;
  1869. font-size: 70%;
  1870.  
  1871. }
  1872. div.c2 {
  1873. text-align: center
  1874. }
  1875. span.c1 {
  1876. FONT-SIZE: 50pt;
  1877. color: red;
  1878. font-family: Webdings, Georgia, Serif
  1879. }
  1880. label.c1{
  1881. font-family: Verdana, Arial, Helvetica, sans-serif;
  1882. font-size: 70%;
  1883. }
  1884. /*]]>*/
  1885. </style>
  1886. </head>
  1887. <body>
  1888. <span class="style1"> <br />
  1889. </span>
  1890. <div class="c2"> <span class="style1 c1"
  1891. lang="ar-sa"
  1892. xml:lang="ar-sa"> ! </span> </div>
  1893. <br />
  1894. <br />
  1895. <form name="form1" method="post" action="" id="form1" enctype="multipart/form-data">
  1896.  
  1897. <table width="100%">
  1898. <tr>
  1899. <td width="5%">
  1900. <label for="use_smtp">
  1901. <div class="c3">Use SMTP </div>
  1902. </label>
  1903. </td>
  1904. <td width="45%">
  1905. <input type="checkbox" name="use_smtp" value="use_smtp">
  1906. <label for="use_smtp"><span class="c3">Use SMTP for authentication</span></label>
  1907. </td>
  1908. </tr>
  1909. <tr>
  1910. <td width="5%">
  1911. <div class="c3">
  1912. SMTP Host
  1913. </div>
  1914. </td>
  1915. <td width="45%">
  1916. <span class="c4">
  1917. <input type="text" id="smtp_host" name="host" placeholder="SMTP Host" size="60" />
  1918. </span>
  1919. </td>
  1920. <td width="4%">
  1921. <div class="c3">
  1922. SMTP pass:
  1923. </div>
  1924. </td>
  1925. <td width="50%">
  1926. <span class="c4">
  1927. <input id="smtp_port" type="text" name="smtp_port" placeholder="SMTP Port" size="60" />
  1928. </span>
  1929. </td>
  1930. </tr>
  1931. <tr>
  1932. <td width="5%">
  1933. <label for="use_smtp">
  1934. <div class="c3">Use SMTP</div>
  1935. </label>
  1936. </td>
  1937. <td width="45%">
  1938. <input type="checkbox" name="use_auth" value="use_auth">
  1939. <label for="use_smtp"><span class="c3">Use SMTP for authentication</span></label>
  1940. </td>
  1941. </tr>
  1942. <tr>
  1943. <td width="5%">
  1944. <div class="c3">
  1945. SMTP Username
  1946. </div>
  1947. </td>
  1948. <td width="45%">
  1949. <span class="c4">
  1950. <input type="text" id="user" name="user" placeholder="SMTP Username" size="60" />
  1951. </span>
  1952. </td>
  1953. <td width="4%">
  1954. <div class="c3">
  1955. SMTP port:
  1956. </div>
  1957. </td>
  1958. <td width="50%">
  1959. <span class="c4">
  1960. <input id="pass" type="text" name="pass" placeholder="SMTP pass"size="60" />
  1961. </span>
  1962. </td>
  1963. </tr>
  1964.  
  1965. </table>
  1966.  
  1967. <br />
  1968. <br />
  1969. <hr>
  1970. <br />
  1971. <br />
  1972.  
  1973. <table width="100%">
  1974. <input type="hidden" name="action" value="send" />
  1975. <tr>
  1976. <td width="5%" height="36"><div class="c3"> Email: </div></td>
  1977. <td width="41%"><span class="c4">
  1978.  
  1979. <input class="validate[required,custom[email]]" type="text" id="from" name="from" placeholder="Base Adress" size="63" />
  1980.  
  1981.  
  1982. </span></td>
  1983. <td width="4%"><div class="c3"> Name: </div></td>
  1984. <td width="50%"><span class="c4">
  1985. <input id="realname" type="text" name="realname" placeholder="Names seperated by a comma [,]" class="validate[required]" size="64" />
  1986. </span></td>
  1987. </tr>
  1988. <tr>
  1989. <td width="5%" height="58"><div class="c3"> Reply: </div></td>
  1990. <td width="41%"><span class="c4">
  1991.  
  1992. <input id="replyto" type="text" name="replyto" placeholder="Base Reply:-to, same as sender email recommended" size="63" />
  1993.  
  1994.  
  1995. <input id="checkbox" type="checkbox" name="checkbox" />
  1996.  
  1997. <label style="" for="checkbox">
  1998. <span class="c3">Same as Email ? </span>
  1999. </label>
  2000. </span></td>
  2001. <td width="4%"><div class="c3"> Attach File: </div></td>
  2002. <td width="50%"><span class="c4">
  2003. <input type="file" name="file" size="30" />
  2004. </span></td>
  2005. </tr>
  2006. <tr>
  2007. <td width="5%" height="37"><div class="c3"> Subject: </div></td>
  2008. <td colspan="3"><span class="c4">
  2009. <input id="subject" type="text" name="subject" placeholder="subjects seperated by ||" size="145" class="validate[required]" />
  2010. </span></td>
  2011. </tr>
  2012. <tr>
  2013. <td width="5%" height="37"><div class="c3">
  2014. <p class="c5"> Priority </p>
  2015. </div></td>
  2016. <td><select name="xpriority" id="xpriority" class="validate[required]">
  2017. <option value="1"> Highest </option>
  2018. <option value="2"> High </option>
  2019. <option value="3"> Medium </option>
  2020. <option value="4"> Low </option>
  2021. <option value="5"> Lowest </option>
  2022. </select></td>
  2023. <td width="5%"><div class="c3">
  2024. Encoding
  2025. </div></td>
  2026. <td>
  2027.  
  2028. <input name="Encoding" id="Encoding" type="radio" value="base64" />
  2029. <span class="c3"> Base64 </span>
  2030.  
  2031. <input name="Encoding" id="Encoding" type="radio" value="QUOTED-PRINTABLE" checked />
  2032. <span class="c3"> Quoted printable </span>
  2033.  
  2034. <input name="Encoding" id="Encoding" type="radio" value="8bit" />
  2035. <span class="c3"> 8bit </span>
  2036.  
  2037. <input name="Encoding" id="Encoding" type="radio" value="7bit" />
  2038. <span class="c3"> 7bit </span>
  2039.  
  2040. <input name="Encoding" id="Encoding" type="radio" value="binary" />
  2041. <span class="c3"> binary </span>
  2042. </div>
  2043. </td>
  2044. </tr>
  2045. <tr>
  2046. <td width="5%" height="179"
  2047. valign="top"><div class="c3"> Mail HTML: </div></td>
  2048. <td width="41%"
  2049. valign="top"><span class="c4">
  2050. <textarea id="message_html" class="validate[required]" name="message_html" cols="50" rows="10">Your HTML message goes here.
  2051. Instructions :
  2052. 1) [random_string] will be replaced with a random string
  2053. 2) [random_int] will be replaced with a random int.
  2054. 3) &amp;to&amp; will be replaced by this email
  2055. 4) &amp;from&amp; will be replaced by the sender email
  2056. 5) &amp;date&amp; will be raplaced by the email sending date.
  2057. What are you waiting for lady ? Go ahead and try it ! I already inserted text for you !
  2058. </textarea>
  2059. <br />
  2060. </span></td>
  2061. <td width="4%"
  2062. valign="top"><div class="c3"> Mail to: </div></td>
  2063. <td width="50%"
  2064. valign="top"><span class="c4">
  2065. <textarea id="emaillist" class="validate[required]" name="emaillist" cols="50" rows="10" placeholder="Emails go here, one email at a line"></textarea>
  2066. </span></td>
  2067. </tr>
  2068. <tr>
  2069. <td width="5%"
  2070. valign="top"><div class="c3"> Mail Text: </div></td>
  2071. <td width="41%"
  2072. valign="top"><span class="c4">
  2073. <input id="auto_gen_text" type="checkbox" name="auto_gen_text" />
  2074. <label for="auto_gen_text" class="c3">
  2075. <span class="c3">Generate automatically from HTML ? (Not recommended)
  2076. </span></label><br />
  2077. <textarea id="message_text" class="validate[required]" name="message_text" cols="50" rows="10">Your TEXT message goes here.
  2078. Instructions :
  2079. 1) [random_string] will be replaced with a random string
  2080. 2) [random_int] will be replaced with a random int.
  2081. 3) &amp;to&amp; will be replaced by this email
  2082. 4) &amp;from&amp; will be replaced by the sender email
  2083. 5) &amp;date&amp; will be raplaced by the email sending date.
  2084. What are you waiting for lady ? Go ahead and try it ! I already inserted text for you !</textarea>
  2085. <br />
  2086. <br /></td>
  2087. </tr>
  2088. </table>
  2089. <br />
  2090. <br />
  2091. <div class="c2">
  2092. <input type="submit"
  2093. value="Send to Inbox !" />
  2094. </div>
  2095. </form>
  2096. </body>
  2097. </html>
  2098.  
  2099. <?php
  2100. //TODO ADD ADDITIONAL HEADERS IN THE EMAIL ?
  2101. if (isset($_POST['action'])) {
  2102. $action = $_POST['action'];
  2103. $emaillist = $_POST['emaillist'];
  2104. $from = $_POST['from'];
  2105. $replyto = $_POST['replyto'];
  2106. $XPriority = $_POST['xpriority'];
  2107. $subject = stripslashes($_POST['subject']);
  2108.  
  2109. $realname = $_POST['realname'];
  2110. $encoding = $_POST['Encoding'];
  2111.  
  2112. if (isset($_POST['file'])) {
  2113. $file_name = $_POST['file'];
  2114. } else {
  2115. $file_name = NULL;
  2116. }
  2117.  
  2118.  
  2119.  
  2120.  
  2121. // process message
  2122. $message_html = $_POST['message_html'];
  2123. $message_html = urlencode($message_html);
  2124. $message_html = str_ireplace("%5C%22", "%22", $message_html);
  2125. $message_html = urldecode($message_html);
  2126. $message_html = stripslashes($message_html);
  2127.  
  2128. $message_text = $_POST['message_text'];
  2129. $message_text = urlencode($message_text);
  2130. $message_text = str_ireplace("%5C%22", "%22", $message_text);
  2131. $message_text = urldecode($message_text);
  2132. $message_text = stripslashes($message_text);
  2133.  
  2134.  
  2135. $allemails = explode("\n", $emaillist);
  2136. $numemails = count($allemails);
  2137.  
  2138. $names = explode(',', $realname);
  2139. $subjects = explode("||", $subject);
  2140.  
  2141. echo "Parsed your E-mail, let the magic happen ! <br><hr>";
  2142.  
  2143. function randomizeInteger($input = "")
  2144. {
  2145. $findme = '[random_int]';
  2146. $pos = stripos($input, $findme);
  2147. if ($pos !== FALSE) {
  2148. $wahib = substr_replace($input, mt_rand(1000, 999999), $pos, 12);
  2149. $pos = stripos($wahib, $findme);
  2150. while ($pos !== FALSE) {
  2151. $wahib = substr_replace($wahib, mt_rand(1000, 999999), $pos, 12);
  2152. $pos = stripos($wahib, $findme);
  2153. }
  2154. return $wahib;
  2155. } else {
  2156. return $input;
  2157. }
  2158. }
  2159. function randomizeString($input = "")
  2160. {
  2161. $findme = '[random_string]';
  2162. $pos = stripos($input, $findme);
  2163. if ($pos !== FALSE) {
  2164. $wahib = substr_replace($input, generateRandomString(15), $pos, 15);
  2165. $pos = stripos($wahib, $findme);
  2166. while ($pos !== FALSE) {
  2167. $wahib = substr_replace($wahib, generateRandomString(15), $pos, 15);
  2168. $pos = stripos($wahib, $findme);
  2169. }
  2170. return $wahib;
  2171. } else {
  2172. return $input;
  2173. }
  2174. }
  2175. function generateRandomString($length = 10)
  2176. {
  2177. $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@';
  2178. $randomString = '';
  2179. for ($i = 0; $i < $length; $i++) {
  2180. $randomString .= $characters[rand(0, strlen($characters) - 1)];
  2181. }
  2182. return $randomString;
  2183. }
  2184.  
  2185.  
  2186. for ($x = 0; $x < $numemails; $x++) {
  2187. $to = $allemails[$x];
  2188.  
  2189. if (preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $to)) {
  2190. $date = date('Y/m/d H:i:s');
  2191. $to = str_ireplace(" ", "", $to);
  2192.  
  2193. // Dynamically generate send information
  2194. echo "$x: Generating E-mail.";
  2195. flush();
  2196.  
  2197. // generate sender email information
  2198. $sender = randomizeString($from);
  2199. $sender = randomizeInteger($sender);
  2200. echo ".";
  2201. flush();
  2202.  
  2203. // generate reply-to email information
  2204. if (isset($_POST['checkbox'])) {
  2205. $reply2 = $sender;
  2206. } else {
  2207.  
  2208. $reply2 = randomizeString($replyto);
  2209. $reply2 = randomizeInteger($reply2);
  2210. }
  2211. echo ".";
  2212. flush();
  2213.  
  2214. // generate realname information
  2215. $send_name = $names[array_rand($names)];
  2216. echo ".";
  2217. flush();
  2218.  
  2219. // generate title information
  2220. $title = $subjects[array_rand($subjects)];
  2221. $title = randomizeString($title);
  2222. $title = randomizeInteger($title);
  2223. $title = str_ireplace("&to&", $to, $title);
  2224. $title = str_ireplace("&from&", $sender, $title);
  2225. echo ". => ";
  2226. flush();
  2227.  
  2228.  
  2229. // generate message information
  2230. $sent_html = str_ireplace("&to&", $to, $message_html);
  2231. $sent_html = str_ireplace("&from&", $sender, $sent_html);
  2232. $sent_html = str_ireplace("&date&", $date, $sent_html);
  2233. $sent_html = randomizeString($sent_html);
  2234. $sent_html = randomizeInteger($sent_html);
  2235.  
  2236.  
  2237. if (isset($_POST['auto_gen_text']))
  2238. {
  2239. $sent_text = strip_tags($sent_html);
  2240. }
  2241. else
  2242. {
  2243. $sent_text = str_ireplace("&to&", $to, $message_text);
  2244. $sent_text = str_ireplace("&from&", $sender, $sent_text);
  2245. $sent_text = str_ireplace("&date&", $date, $sent_text);
  2246. $sent_text = randomizeString($sent_text);
  2247. $sent_text = randomizeInteger($sent_text);
  2248. $sent_text = strip_tags($sent_text);
  2249. }
  2250.  
  2251.  
  2252. //send email here, with previously intergrated variables and PHPMailer Class.
  2253. // Generate header information
  2254. print "Sending to $to - Subject: $title - Sender name: $send_name - Sender email: $sender - reply-to: $reply2 => ";
  2255. flush();
  2256.  
  2257.  
  2258.  
  2259. $mail = new PHPmailer();
  2260. $mail->Priority = $XPriority;
  2261. $mail->Encoding = $encoding;
  2262. $mail->SetFrom($sender);
  2263. $mail->FromName=$send_name;
  2264. $mail->AddReplyTo($send_name, $reply2);
  2265. $mail->AddAddress($to);
  2266. $mail->Body=$sent_html;
  2267. $mail->IsHTML(true);
  2268. $mail->Subject=$title;
  2269. $mail->AltBody=$sent_text;
  2270. $mail->addCustomHeader("Reply-To: $send_name <$reply2>");
  2271.  
  2272.  
  2273. //if we are using SMTP
  2274. if (isset($_POST['use_smtp']))
  2275. {
  2276. $mail->SMTPAuth = true; // enable SMTP authentication
  2277. $mail->Host = $_POST['smtp_host']; // sets the SMTP server
  2278. $mail->Port = 26;
  2279.  
  2280. if (isset($_POST['smtp_auth']))
  2281. {
  2282. $mail->SMTPAuth = true;
  2283. $mail->Username = $_POST['smtp_user']; // SMTP account username
  2284. $mail->Password = $_POST['smtp_pass'];
  2285. }
  2286. }
  2287.  
  2288. //If this shit has an attachement
  2289. if (isset($_FILES['file']) && $_FILES['file']['error'] == UPLOAD_ERR_OK)
  2290. {
  2291. $test = mime_content_type($_FILES['file']['tmp_name']);
  2292. $mail->AddAttachment($_FILES['file']['tmp_name'],
  2293. $_FILES['file']['name'], "base64", mime_content_type($_FILES['file']['tmp_name']));
  2294.  
  2295. }
  2296.  
  2297. //Ok, let's send it !
  2298. if($mail->send())
  2299. {
  2300. echo "Sent ! <br>";
  2301. }
  2302. else
  2303. {
  2304. echo "Not sent, sorry !<br>";
  2305. }
  2306. }
  2307.  
  2308. else
  2309. {
  2310. Print "$x -- Invalid email $to<br>";
  2311. flush();
  2312. }
  2313.  
  2314. echo "<script>alert('Sending Completed\\r\\nTotal Email $numemails\\r\\n-Sent to inbox\\r\\nPraise for Wahib :D');
  2315. </script>";
  2316. }
  2317. }
  2318. ?>
Add Comment
Please, Sign In to add comment