Project

General

Profile

« Previous | Next » 

Revision 1853

Added by Dietmar almost 12 years ago

! update phpmailer to version 5.2.1
! update jquery to 1.8.3 and jQuery UI to 1.9.2

View differences:

class.phpmailer.php
2 2
/*~ class.phpmailer.php
3 3
.---------------------------------------------------------------------------.
4 4
|  Software: PHPMailer - PHP email class                                    |
5
|   Version: 5.2                                                            |
5
|   Version: 5.2.1                                                          |
6 6
|      Site: https://code.google.com/a/apache-extras.org/p/phpmailer/       |
7 7
| ------------------------------------------------------------------------- |
8 8
|     Admin: Jim Jagielski (project admininistrator)                        |
......
10 10
|          : Marcus Bointon (coolbru) coolbru@users.sourceforge.net         |
11 11
|          : Jim Jagielski (jimjag) jimjag@gmail.com                        |
12 12
|   Founder: Brent R. Matzelle (original founder)                           |
13
| Copyright (c) 2010-2011, Jim Jagielski. All Rights Reserved.               |
13
| Copyright (c) 2010-2012, Jim Jagielski. All Rights Reserved.              |
14 14
| Copyright (c) 2004-2009, Andy Prevost. All Rights Reserved.               |
15 15
| Copyright (c) 2001-2003, Brent R. Matzelle                                |
16 16
| ------------------------------------------------------------------------- |
......
29 29
 * @author Andy Prevost
30 30
 * @author Marcus Bointon
31 31
 * @author Jim Jagielski
32
 * @copyright 2010 - 2011 Jim Jagielski
32
 * @copyright 2010 - 2012 Jim Jagielski
33 33
 * @copyright 2004 - 2009 Andy Prevost
34 34
 * @version $Id: class.phpmailer.php 450 2010-06-23 16:46:33Z coolbru $
35 35
 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
......
130 130
  protected $MIMEHeader     = '';
131 131

  
132 132
  /**
133
   * Stores the complete sent MIME message (Body and Headers)
134
   * @var string
135
   * @access protected
136
  */
137
  protected $SentMIMEMessage     = '';
138

  
139
  /**
133 140
   * Sets word wrapping on the body of the message to a given number of
134 141
   * characters.
135 142
   * @var int
......
317 324
   * Sets the PHPMailer Version number
318 325
   * @var string
319 326
   */
320
  public $Version         = '5.2';
327
  public $Version         = '5.2.1';
321 328

  
322 329
  /**
323 330
   * What to use in the X-Mailer header
......
460 467
   * @return boolean
461 468
   */
462 469
  public function AddReplyTo($address, $name = '') {
463
    return $this->AddAnAddress('ReplyTo', $address, $name);
470
    return $this->AddAnAddress('Reply-To', $address, $name);
464 471
  }
465 472

  
466 473
  /**
......
473 480
   * @access protected
474 481
   */
475 482
  protected function AddAnAddress($kind, $address, $name = '') {
476
    if (!preg_match('/^(to|cc|bcc|ReplyTo)$/', $kind)) {
483
    if (!preg_match('/^(to|cc|bcc|Reply-To)$/', $kind)) {
477 484
      $this->SetError($this->Lang('Invalid recipient array').': '.$kind);
478 485
      if ($this->exceptions) {
479 486
        throw new phpmailerException('Invalid recipient array: ' . $kind);
480 487
      }
481
      echo $this->Lang('Invalid recipient array').': '.$kind;
488
	  if ($this->SMTPDebug) {
489
        echo $this->Lang('Invalid recipient array').': '.$kind;
490
      }
482 491
      return false;
483 492
    }
484 493
    $address = trim($address);
......
488 497
      if ($this->exceptions) {
489 498
        throw new phpmailerException($this->Lang('invalid_address').': '.$address);
490 499
      }
491
      echo $this->Lang('invalid_address').': '.$address;
500
	  if ($this->SMTPDebug) {
501
        echo $this->Lang('invalid_address').': '.$address;
502
      }
492 503
      return false;
493 504
    }
494
    if ($kind != 'ReplyTo') {
505
    if ($kind != 'Reply-To') {
495 506
      if (!isset($this->all_recipients[strtolower($address)])) {
496 507
        array_push($this->$kind, array($address, $name));
497 508
        $this->all_recipients[strtolower($address)] = true;
......
520 531
      if ($this->exceptions) {
521 532
        throw new phpmailerException($this->Lang('invalid_address').': '.$address);
522 533
      }
523
      echo $this->Lang('invalid_address').': '.$address;
534
	  if ($this->SMTPDebug) {
535
        echo $this->Lang('invalid_address').': '.$address;
536
      }
524 537
      return false;
525 538
    }
526 539
    $this->From = $address;
527 540
    $this->FromName = $name;
528 541
    if ($auto) {
529 542
      if (empty($this->ReplyTo)) {
530
        $this->AddAnAddress('ReplyTo', $address, $name);
543
        $this->AddAnAddress('Reply-To', $address, $name);
531 544
      }
532 545
      if (empty($this->Sender)) {
533 546
        $this->Sender = $address;
......
574 587
      if(!$this->PreSend()) return false;
575 588
      return $this->PostSend();
576 589
    } catch (phpmailerException $e) {
590
	  $this->SentMIMEMessage = '';
577 591
      $this->SetError($e->getMessage());
578 592
      if ($this->exceptions) {
579 593
        throw $e;
......
584 598

  
585 599
  protected function PreSend() {
586 600
    try {
601
	  $mailHeader = "";
587 602
      if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
588 603
        throw new phpmailerException($this->Lang('provide_address'), self::STOP_CRITICAL);
589 604
      }
......
603 618
      $this->MIMEHeader = $this->CreateHeader();
604 619
      $this->MIMEBody = $this->CreateBody();
605 620

  
621
      // To capture the complete message when using mail(), create
622
	  // an extra header list which CreateHeader() doesn't fold in
623
      if ($this->Mailer == 'mail') {
624
        if (count($this->to) > 0) {
625
          $mailHeader .= $this->AddrAppend("To", $this->to);
626
        } else {
627
          $mailHeader .= $this->HeaderLine("To", "undisclosed-recipients:;");
628
        }
629
        $mailHeader .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader(trim($this->Subject))));
630
        // if(count($this->cc) > 0) {
631
            // $mailHeader .= $this->AddrAppend("Cc", $this->cc);
632
        // }
633
      }
606 634

  
607 635
      // digitally sign with DKIM if enabled
608 636
      if ($this->DKIM_domain && $this->DKIM_private) {
......
610 638
        $this->MIMEHeader = str_replace("\r\n", "\n", $header_dkim) . $this->MIMEHeader;
611 639
      }
612 640

  
641
      $this->SentMIMEMessage = sprintf("%s%s\r\n\r\n%s",$this->MIMEHeader,$mailHeader,$this->MIMEBody);
613 642
      return true;
643

  
614 644
    } catch (phpmailerException $e) {
615 645
      $this->SetError($e->getMessage());
616 646
      if ($this->exceptions) {
......
628 658
          return $this->SendmailSend($this->MIMEHeader, $this->MIMEBody);
629 659
        case 'smtp':
630 660
          return $this->SmtpSend($this->MIMEHeader, $this->MIMEBody);
661
        case 'mail':
662
          return $this->MailSend($this->MIMEHeader, $this->MIMEBody);
631 663
        default:
632 664
          return $this->MailSend($this->MIMEHeader, $this->MIMEBody);
633 665
      }
......
637 669
      if ($this->exceptions) {
638 670
        throw $e;
639 671
      }
640
      echo $e->getMessage()."\n";
672
	  if ($this->SMTPDebug) {
673
        echo $e->getMessage()."\n";
674
      }
641 675
      return false;
642 676
    }
643 677
  }
......
703 737
    $to = implode(', ', $toArr);
704 738

  
705 739
    if (empty($this->Sender)) {
706
      $params = "-oi -f %s";
740
      $params = "-oi ";
707 741
    } else {
708 742
      $params = sprintf("-oi -f %s", $this->Sender);
709 743
    }
......
732 766
          $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body);
733 767
        }
734 768
      } else {
735
        $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
769
        $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
736 770
        // implement call back function if it exists
737 771
        $isSent = ($rt == 1) ? 1 : 0;
738 772
        $this->doCallback($isSent, $to, $this->cc, $this->bcc, $this->Subject, $body);
......
880 914
      }
881 915
    } catch (phpmailerException $e) {
882 916
      $this->smtp->Reset();
883
      throw $e;
917
	  if ($this->exceptions) {
918
        throw $e;
919
      }
884 920
    }
885 921
    return true;
886 922
  }
......
1159 1195
          $result .= $this->HeaderLine('To', 'undisclosed-recipients:;');
1160 1196
        }
1161 1197
      }
1162
    }
1198
	}
1163 1199

  
1164 1200
    $from = array();
1165 1201
    $from[0][0] = trim($this->From);
......
1177 1213
    }
1178 1214

  
1179 1215
    if(count($this->ReplyTo) > 0) {
1180
      $result .= $this->AddrAppend('Reply-to', $this->ReplyTo);
1216
      $result .= $this->AddrAppend('Reply-To', $this->ReplyTo);
1181 1217
    }
1182 1218

  
1183 1219
    // mail() sets the subject itself
......
1251 1287
  }
1252 1288

  
1253 1289
  /**
1290
   * Returns the MIME message (headers and body). Only really valid post PreSend().
1291
   * @access public
1292
   * @return string
1293
   */
1294
  public function GetSentMIMEMessage() {
1295
    return $this->SentMIMEMessage;
1296
  }
1297

  
1298

  
1299
  /**
1254 1300
   * Assembles the message body.  Returns an empty string on failure.
1255 1301
   * @access public
1256 1302
   * @return string The assembled message body
......
1363 1409
        $signed = tempnam("", "signed");
1364 1410
        if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_cert_file, array("file://".$this->sign_key_file, $this->sign_key_pass), NULL)) {
1365 1411
          @unlink($file);
1412
          $body = file_get_contents($signed);
1366 1413
          @unlink($signed);
1367
          $body = file_get_contents($signed);
1368 1414
        } else {
1369 1415
          @unlink($file);
1370 1416
          @unlink($signed);
......
1487 1533
      if ($this->exceptions) {
1488 1534
        throw $e;
1489 1535
      }
1490
      echo $e->getMessage()."\n";
1536
	  if ($this->SMTPDebug) {
1537
        echo $e->getMessage()."\n";
1538
      }
1491 1539
      if ( $e->getCode() == self::STOP_CRITICAL ) {
1492 1540
        return false;
1493 1541
      }
......
1590 1638
          return false;
1591 1639
        }
1592 1640
      }
1593
      if (version_compare(PHP_VERSION, '5.3.0', '<')) {
1594
        $magic_quotes = get_magic_quotes_runtime();
1595
        set_magic_quotes_runtime(0);
1596
      }
1641
	  $magic_quotes = get_magic_quotes_runtime();
1642
	  if ($magic_quotes) {
1643
        if (version_compare(PHP_VERSION, '5.3.0', '<')) {
1644
          set_magic_quotes_runtime(0);
1645
        } else {
1646
		  ini_set('magic_quotes_runtime', 0); 
1647
		}
1648
	  }
1597 1649
      $file_buffer  = file_get_contents($path);
1598 1650
      $file_buffer  = $this->EncodeString($file_buffer, $encoding);
1599
      if (version_compare(PHP_VERSION, '5.3.0', '<')) {
1600
        set_magic_quotes_runtime($magic_quotes);
1601
      }
1651
	  if ($magic_quotes) {
1652
        if (version_compare(PHP_VERSION, '5.3.0', '<')) {
1653
          set_magic_quotes_runtime($magic_quotes);
1654
        } else {
1655
		  ini_set('magic_quotes_runtime', $magic_quotes); 
1656
	    }
1657
	  }
1602 1658
      return $file_buffer;
1603 1659
    } catch (Exception $e) {
1604 1660
      $this->SetError($e->getMessage());
......
2154 2210
   * @return $message
2155 2211
   */
2156 2212
  public function MsgHTML($message, $basedir = '') {
2157
    preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images);
2213
    preg_match_all("/(src|background)=[\"'](.*)[\"']/Ui", $message, $images);
2158 2214
    if(isset($images[2])) {
2159 2215
      foreach($images[2] as $i => $url) {
2160 2216
        // do not change urls for absolute images (thanks to corvuscorax)
......
2168 2224
          if ( strlen($basedir) > 1 && substr($basedir, -1) != '/') { $basedir .= '/'; }
2169 2225
          if ( strlen($directory) > 1 && substr($directory, -1) != '/') { $directory .= '/'; }
2170 2226
          if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64', $mimeType) ) {
2171
            $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message);
2227
            $message = preg_replace("/".$images[1][$i]."=[\"']".preg_quote($url, '/')."[\"']/Ui", $images[1][$i]."=\"".$cid."\"", $message);
2172 2228
          }
2173 2229
        }
2174 2230
      }
2175 2231
    }
2176 2232
    $this->IsHTML(true);
2177 2233
    $this->Body = $message;
2178
    $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s', '', $message)));
2179
    if (!empty($textMsg) && empty($this->AltBody)) {
2180
      $this->AltBody = html_entity_decode($textMsg);
2181
    }
2234
	if (empty($this->AltBody)) {
2235
		$textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s', '', $message)));
2236
		if (!empty($textMsg)) {
2237
			$this->AltBody = html_entity_decode($textMsg, ENT_QUOTES, $this->CharSet);
2238
		}
2239
	}
2182 2240
    if (empty($this->AltBody)) {
2183 2241
      $this->AltBody = 'To view this email message, open it in a program that understands HTML!' . "\n\n";
2184 2242
    }
2243
	return $message;
2185 2244
  }
2186 2245

  
2187 2246
  /**

Also available in: Unified diff