Guest User

Untitled

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