From: Roland Häder Date: Wed, 4 Mar 2009 07:39:44 +0000 (+0000) Subject: PHPMailer updated to 2.0.3 X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=commitdiff_plain;h=3634be9f95a83075bbfca9368b60bbd1bbe2d31f PHPMailer updated to 2.0.3 --- diff --git a/.gitattributes b/.gitattributes index 8b11bfc1e9..50977e6cb7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -565,6 +565,7 @@ inc/phpmailer/language/phpmailer.lang-br.php -text inc/phpmailer/language/phpmailer.lang-ca.php -text inc/phpmailer/language/phpmailer.lang-cz.php -text inc/phpmailer/language/phpmailer.lang-de.php -text +inc/phpmailer/language/phpmailer.lang-de.zip -text inc/phpmailer/language/phpmailer.lang-dk.php -text inc/phpmailer/language/phpmailer.lang-en.php -text inc/phpmailer/language/phpmailer.lang-es.php -text diff --git a/inc/databases.php b/inc/databases.php index 08d8b170bd..e9908a8396 100644 --- a/inc/databases.php +++ b/inc/databases.php @@ -98,7 +98,7 @@ define('SERVER_URL', "http://www.mxchange.org"); // Current SVN revision //define('CURR_SVN_REVISION', getActualVersion(0)); -define('CURR_SVN_REVISION', "814"); +define('CURR_SVN_REVISION', "815"); define('CURR_SVN_DATE' , getActualVersion(1)); define('CURR_SVN_VERSION' , getActualVersion(2)); diff --git a/inc/phpmailer/ChangeLog.txt b/inc/phpmailer/ChangeLog.txt index 44e4e87e44..ed992db3f6 100644 --- a/inc/phpmailer/ChangeLog.txt +++ b/inc/phpmailer/ChangeLog.txt @@ -1,5 +1,19 @@ ChangeLog +Version 2.0.3 (November 08 2008) +* fixed line 1041 in class.smtp.php (endless loop from missing = sign) +* fixed duplicate images in email body +* removed English language from language files and made it a default within + class.phpmailer.php - if no language is found, it will default to use + the english language translation +* corrected $basedir to $directory +* changed default of $LE to "\r\n" to comply with RFC 2822. Can be set by the user + if default is not acceptable +* removed trim() from return results in EncodeQP +* changed $this->AltBody = $textMsg; to $this->AltBody = html_entity_decode($textMsg); +* We have removed the /phpdoc from the downloads. All documentation is now on + the http://phpmailer.codeworxtech.com website. + Version 2.0.2 (June 04 2008) ** NOTE: WE HAVE A NEW LANGUAGE VARIABLE FOR DIGITALLY SIGNED S/MIME EMAILS. @@ -8,9 +22,9 @@ Version 2.0.2 (June 04 2008) * added S/MIME functionality (ability to digitally sign emails) BIG THANKS TO "sergiocambra" for posting this patch back in November 2007. - The "Signed Emails" functionality adds the Sign method to pass the private key - filename and the password to read it, and then email will be sent with - content-type multipart/signed and with the digital signature attached. + The "Signed Emails" functionality adds the Sign method to pass the private key + filename and the password to read it, and then email will be sent with + content-type multipart/signed and with the digital signature attached. * added ability to define path (mainly for embedded images) function MsgHTML($message,$basedir='') ... where: $basedir is the fully qualified path @@ -90,11 +104,11 @@ Version 2.0.0 rc1 (Thu, Nov 08 2007), interim release * added TLS/SSL SMTP support example of use: $mail = new PHPMailer(); - $mail->Mailer = "smtp"; - $mail->Host = "smtp.example.com"; - $mail->SMTPSecure = "tls"; // option - //$mail->SMTPSecure = "ssl"; // option - ... + $mail->Mailer = "smtp"; + $mail->Host = "smtp.example.com"; + $mail->SMTPSecure = "tls"; // option + //$mail->SMTPSecure = "ssl"; // option + ... $mail->Send(); * PHPMailer has been tested with PHP4 (4.4.7) and PHP5 (5.2.7) * Works with PHP installed as a module or as CGI-PHP diff --git a/inc/phpmailer/README b/inc/phpmailer/README index 75b76c10a4..57a9f4bc5c 100644 --- a/inc/phpmailer/README +++ b/inc/phpmailer/README @@ -9,6 +9,23 @@ PHPMailer Full Featured Email Transfer Class for PHP ========================================== +Version 2.3 (November 08, 2008) + +PHP4 continues to be a major platform for developers. We are responding +to the emails received to continue development for PHP4 with this +release. + +We have removed the /phpdoc from the downloads. All documentation is now on +the http://phpmailer.codeworxtech.com website. + +For all other changes and notes, please see the changelog. + +Donations are accepted at PayPal with our id "paypal@worxteam.com". + +Version 2.2 (July 15 2008) + +- see the changelog. + Version 2.0.2 (June 04 2008) With this release, we are announcing that the development of PHPMailer for PHP5 @@ -47,7 +64,7 @@ its leadership position. Our goals are to simplify use of PHPMailer, provide good documentation and examples, and retain backward compatibility to level 1.7.3 standards. -If you are interested in helping out, visit http://sourceforge.net/phpmailer +If you are interested in helping out, visit http://sourceforge.net/projects/phpmailer and indicate your interest. ** diff --git a/inc/phpmailer/class.phpmailer.php b/inc/phpmailer/class.phpmailer.php index 2ddc30fd27..e8186154f7 100644 --- a/inc/phpmailer/class.phpmailer.php +++ b/inc/phpmailer/class.phpmailer.php @@ -2,7 +2,7 @@ /*~ class.phpmailer.php .---------------------------------------------------------------------------. | Software: PHPMailer - PHP email class | -| Version: 2.0.2 | +| Version: 2.0.3 | | Contact: via sourceforge.net support pages (also www.codeworxtech.com) | | Info: http://phpmailer.sourceforge.net | | Support: http://sourceforge.net/projects/phpmailer/ | @@ -139,7 +139,7 @@ class PHPMailer { * Holds PHPMailer version. * @var string */ - var $Version = "2.0.2"; + var $Version = "2.0.3"; /** * Sets the email address that a reading confirmation will be sent. @@ -256,7 +256,8 @@ class PHPMailer { var $boundary = array(); var $language = array(); var $error_count = 0; - var $LE = "\n"; + var $LE = "\r\n"; + var $sign_cert_file = ""; var $sign_key_file = ""; var $sign_key_pass = ""; @@ -649,8 +650,20 @@ class PHPMailer { } elseif (file_exists($lang_path.'phpmailer.lang-en.php')) { include($lang_path.'phpmailer.lang-en.php'); } else { - $this->SetError('Could not load language file'); - return false; + $PHPMAILER_LANG = array(); + $PHPMAILER_LANG["provide_address"] = 'You must provide at least one ' . + $PHPMAILER_LANG["mailer_not_supported"] = ' mailer is not supported.'; + $PHPMAILER_LANG["execute"] = 'Could not execute: '; + $PHPMAILER_LANG["instantiate"] = 'Could not instantiate mail function.'; + $PHPMAILER_LANG["authenticate"] = 'SMTP Error: Could not authenticate.'; + $PHPMAILER_LANG["from_failed"] = 'The following From address failed: '; + $PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: The following ' . + $PHPMAILER_LANG["data_not_accepted"] = 'SMTP Error: Data not accepted.'; + $PHPMAILER_LANG["connect_host"] = 'SMTP Error: Could not connect to SMTP host.'; + $PHPMAILER_LANG["file_access"] = 'Could not access file: '; + $PHPMAILER_LANG["file_open"] = 'File Error: Could not open file: '; + $PHPMAILER_LANG["encoding"] = 'Unknown encoding: '; + $PHPMAILER_LANG["signing"] = 'Signing Error: '; } $this->language = $PHPMAILER_LANG; @@ -864,9 +877,6 @@ class PHPMailer { } elseif (count($this->cc) == 0) { $result .= $this->HeaderLine('To', 'undisclosed-recipients:;'); } - if(count($this->cc) > 0) { - $result .= $this->AddrAppend('Cc', $this->cc); - } } $from = array(); @@ -1007,9 +1017,13 @@ class PHPMailer { fclose($fp); $signed = tempnam("", "signed"); - if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_key_file, array("file://".$this->sign_key_file, $this->sign_key_pass), null)) { + if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_cert_file, array("file://".$this->sign_key_file, $this->sign_key_pass), null)) { $fp = fopen($signed, "r"); $result = fread($fp, filesize($this->sign_key_file)); + $result = ''; + while(!feof($fp)){ + $result = $result . fread($fp, 1024); + } fclose($fp); } else { $this->SetError($this->Lang("signing").openssl_error_string()); @@ -1159,14 +1173,14 @@ class PHPMailer { $cid = $this->attachment[$i][7]; $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE); - $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $name, $this->LE); + $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE); $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE); if($disposition == 'inline') { $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE); } - $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $name, $this->LE.$this->LE); + $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE); /* Encode as string attachment */ if($bString) { @@ -1399,7 +1413,7 @@ class PHPMailer { } // end of for $output .= $newline.$eol; } // end of while - return trim($output); + return $output; } /** @@ -1710,8 +1724,7 @@ class PHPMailer { $ext = $fileParts[1]; $mimeType = $this->_mime_types($ext); if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; } - if ( strlen($directory) > 1 && substr($basedir,-1) != '/') { $directory .= '/'; } - $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64', $mimeType); + if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; } if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) { $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message); } @@ -1722,7 +1735,7 @@ class PHPMailer { $this->Body = $message; $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message))); if ( !empty($textMsg) && empty($this->AltBody) ) { - $this->AltBody = $textMsg; + $this->AltBody = html_entity_decode($textMsg); } if ( empty($this->AltBody) ) { $this->AltBody = 'To view this email message, open the email in with HTML compatibility!' . "\n\n"; @@ -1736,93 +1749,92 @@ class PHPMailer { */ function _mime_types($ext = '') { $mimes = array( - 'hqx' => 'application/mac-binhex40', - 'cpt' => 'application/mac-compactpro', - 'doc' => 'application/msword', + 'ai' => 'application/postscript', + 'aif' => 'audio/x-aiff', + 'aifc' => 'audio/x-aiff', + 'aiff' => 'audio/x-aiff', + 'avi' => 'video/x-msvideo', 'bin' => 'application/macbinary', - 'dms' => 'application/octet-stream', - 'lha' => 'application/octet-stream', - 'lzh' => 'application/octet-stream', - 'exe' => 'application/octet-stream', + 'bmp' => 'image/bmp', 'class' => 'application/octet-stream', - 'psd' => 'application/octet-stream', - 'so' => 'application/octet-stream', - 'sea' => 'application/octet-stream', - 'dll' => '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', + 'cpt' => 'application/mac-compactpro', + 'css' => 'text/css', 'dcr' => 'application/x-director', 'dir' => 'application/x-director', - 'dxr' => 'application/x-director', + 'dll' => 'application/octet-stream', + 'dms' => 'application/octet-stream', + 'doc' => 'application/msword', 'dvi' => 'application/x-dvi', + 'dxr' => 'application/x-director', + 'eml' => 'message/rfc822', + 'eps' => 'application/postscript', + 'exe' => 'application/octet-stream', + 'gif' => 'image/gif', 'gtar' => 'application/x-gtar', - 'php' => 'application/x-httpd-php', - 'php4' => 'application/x-httpd-php', - 'php3' => 'application/x-httpd-php', - 'phtml' => 'application/x-httpd-php', - 'phps' => 'application/x-httpd-php-source', + 'htm' => 'text/html', + 'html' => 'text/html', + 'jpe' => 'image/jpeg', + 'jpeg' => 'image/jpeg', + 'jpg' => 'image/jpeg', + 'hqx' => 'application/mac-binhex40', 'js' => 'application/x-javascript', - 'swf' => 'application/x-shockwave-flash', - 'sit' => 'application/x-stuffit', - 'tar' => 'application/x-tar', - 'tgz' => 'application/x-tar', - 'xhtml' => 'application/xhtml+xml', - 'xht' => 'application/xhtml+xml', - 'zip' => 'application/zip', + 'lha' => 'application/octet-stream', + 'log' => 'text/plain', + 'lzh' => 'application/octet-stream', 'mid' => 'audio/midi', 'midi' => 'audio/midi', - 'mpga' => 'audio/mpeg', + 'mif' => 'application/vnd.mif', + 'mov' => 'video/quicktime', + 'movie' => 'video/x-sgi-movie', 'mp2' => 'audio/mpeg', 'mp3' => 'audio/mpeg', - 'aif' => 'audio/x-aiff', - 'aiff' => 'audio/x-aiff', - 'aifc' => 'audio/x-aiff', + 'mpe' => 'video/mpeg', + 'mpeg' => 'video/mpeg', + 'mpg' => 'video/mpeg', + 'mpga' => 'audio/mpeg', + 'oda' => 'application/oda', + 'pdf' => 'application/pdf', + 'php' => 'application/x-httpd-php', + 'php3' => 'application/x-httpd-php', + 'php4' => 'application/x-httpd-php', + 'phps' => 'application/x-httpd-php-source', + 'phtml' => 'application/x-httpd-php', + 'png' => 'image/png', + 'ppt' => 'application/vnd.ms-powerpoint', + 'ps' => 'application/postscript', + 'psd' => 'application/octet-stream', + 'qt' => 'video/quicktime', + 'ra' => 'audio/x-realaudio', 'ram' => 'audio/x-pn-realaudio', 'rm' => 'audio/x-pn-realaudio', 'rpm' => 'audio/x-pn-realaudio-plugin', - 'ra' => 'audio/x-realaudio', + 'rtf' => 'text/rtf', + 'rtx' => 'text/richtext', 'rv' => 'video/vnd.rn-realvideo', - 'wav' => 'audio/x-wav', - 'bmp' => 'image/bmp', - 'gif' => 'image/gif', - 'jpeg' => 'image/jpeg', - 'jpg' => 'image/jpeg', - 'jpe' => 'image/jpeg', - 'png' => 'image/png', - 'tiff' => 'image/tiff', - 'tif' => 'image/tiff', - 'css' => 'text/css', - 'html' => 'text/html', - 'htm' => 'text/html', + 'sea' => 'application/octet-stream', 'shtml' => 'text/html', - 'txt' => 'text/plain', + 'sit' => 'application/x-stuffit', + 'so' => 'application/octet-stream', + 'smi' => 'application/smil', + 'smil' => 'application/smil', + 'swf' => 'application/x-shockwave-flash', + 'tar' => 'application/x-tar', 'text' => 'text/plain', - 'log' => 'text/plain', - 'rtx' => 'text/richtext', - 'rtf' => 'text/rtf', - 'xml' => 'text/xml', - 'xsl' => 'text/xml', - 'mpeg' => 'video/mpeg', - 'mpg' => 'video/mpeg', - 'mpe' => 'video/mpeg', - 'qt' => 'video/quicktime', - 'mov' => 'video/quicktime', - 'avi' => 'video/x-msvideo', - 'movie' => 'video/x-sgi-movie', - 'doc' => 'application/msword', + 'txt' => 'text/plain', + 'tgz' => 'application/x-tar', + 'tif' => 'image/tiff', + 'tiff' => 'image/tiff', + 'wav' => 'audio/x-wav', + 'wbxml' => 'application/vnd.wap.wbxml', + 'wmlc' => 'application/vnd.wap.wmlc', 'word' => 'application/msword', + 'xht' => 'application/xhtml+xml', + 'xhtml' => 'application/xhtml+xml', 'xl' => 'application/excel', - 'eml' => 'message/rfc822' + 'xls' => 'application/vnd.ms-excel', + 'xml' => 'text/xml', + 'xsl' => 'text/xml', + 'zip' => 'application/zip' ); return ( ! isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)]; } @@ -1886,11 +1898,12 @@ class PHPMailer { * @param string $key_filename Parameter File Name * @param string $key_pass Password for private key */ - function Sign($key_filename, $key_pass) { + function Sign($cert_filename, $key_filename, $key_pass) { + $this->sign_cert_file = $cert_filename; $this->sign_key_file = $key_filename; $this->sign_key_pass = $key_pass; } } -?> +?> \ No newline at end of file diff --git a/inc/phpmailer/class.pop3.php b/inc/phpmailer/class.pop3.php index e97a0c9c90..09f790adc8 100644 --- a/inc/phpmailer/class.pop3.php +++ b/inc/phpmailer/class.pop3.php @@ -2,7 +2,7 @@ /*~ class.pop3.php .---------------------------------------------------------------------------. | Software: PHPMailer - PHP email class | -| Version: 2.0.2 | +| Version: 2.0.3 | | Contact: via sourceforge.net support pages (also www.codeworxtech.com) | | Info: http://phpmailer.sourceforge.net | | Support: http://sourceforge.net/projects/phpmailer/ | diff --git a/inc/phpmailer/class.smtp.php b/inc/phpmailer/class.smtp.php index 398c3ffbac..e7d4abda22 100644 --- a/inc/phpmailer/class.smtp.php +++ b/inc/phpmailer/class.smtp.php @@ -2,7 +2,7 @@ /*~ class.smtp.php .---------------------------------------------------------------------------. | Software: PHPMailer - PHP email class | -| Version: 2.0.2 | +| Version: 2.0.3 | | Contact: via sourceforge.net support pages (also www.codeworxtech.com) | | Info: http://phpmailer.sourceforge.net | | Support: http://sourceforge.net/projects/phpmailer/ | @@ -1038,7 +1038,7 @@ class SMTP */ function get_lines() { $data = ""; - while($str = @fgets($this->smtp_conn,515)) { + while($str == @fgets($this->smtp_conn,515)) { if($this->do_debug >= 4) { echo "SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF; diff --git a/inc/phpmailer/codeworxtech.html b/inc/phpmailer/codeworxtech.html index 4a5cfd38f2..68ccaa9319 100644 --- a/inc/phpmailer/codeworxtech.html +++ b/inc/phpmailer/codeworxtech.html @@ -1,121 +1,121 @@ - - - - - - -
-
-
-The http://phpmailer.codeworxtech.com/ website now carries a few -advertisements through the Google Adsense network. Please visit -the advertiser sites and help us offset some of our costs.
-Thanks ....
-
-

My name is Andy Prevost, AKA "codeworxtech".
-www.codeworxtech.com for more information.
-

-

WHY USE OUR TOOLS & WHAT'S IN IT FOR YOU?

-

A valid question. We're developers too. We've been writing software, primarily for the internet, for more than 15 years. Along the way, there are two major things that had tremendous impact of our company: PHP and Open Source. PHP is without doubt the most popular platform for the internet. There has been more progress in this area of technology because of Open Source software than in any other IT segment. We have used many open source tools, some as learning tools, some as components in projects we were working on. To us, it's not about popularity ... we're committed to robust, stable, and efficient tools you can use to get your projects in your user's hands quickly. So the shorter answer: what's in it for you? rapid development and rapid deployment without fuss and with straight forward open source licensing.

-

Now, the introductions:

-

Our company, Codeworx Technologies, is the publisher of several Open Source applications and developer tools as well as several commercial PHP applications. The Open Source applications are ttCMS and DCP Portal. The Open Source developer tools include QuickComponents (QuickSkin, QuickCache, and QuickTabs) and now PHPMailer. -We have staff and offices in the United States, Canada, Caribbean, the Middle -East, and our primary development center in India. Our company is represented by -agents and resellers globally.

-

Codeworx Technologies is at the forefront of developing PHP applications. Our staff are all Zend Certified university educated and experts at object oriented programming. While Codeworx Technologies can handle any project from trouble shooting programs written by others all the way to finished mission-critical applications, we specialize in taking projects from inception all the way through to implementation - on budget, and on time. If you need help with your projects, we're the team to get it done right at a reasonable price.

-

Over the years, there have been a number of tools that have been constant favorites in all of our projects. We have become the project administrators for most of these tools.

-

Our developer tools are all Open Source. Here's a brief description:

-
    -
  • PHPMailer. Originally authored by Brent Matzelle, PHPMailer is the leading "email transfer class" for PHP. PHPMailer is downloaded more than 18000 times each and every month by developers looking for a stable, simple email solution. We used it ourselves for years as our favorite tool. It's always been small (the entire footprint is around 100 Kb), stable, and as complete a solution as you can find. Other tools are nowhere near as simple. And more importantly, most of our applications (including PHPMailer) is implemented in a smaller footprint than one competing email class. Our thanks to Brent Matzelle for this superb tool - our commitment is to keep it lean, keep it focused, and compliant with standards. Visit the PHPMailer website at - http://phpmailer.codeworxtech.com/.
    - Please note: all of our focus is now on the PHPMailer for PHP5.
    - PS. While you are at it, please visit our sponsor's sites, click on their ads. - It helps offset some of our costs.
    - Want to help? We're looking for progressive developers to join our team of volunteer professionals working on PHPMailer. Our entire focus is on PHPMailer for PHP5, and our next major task is to enhance our - exception/error handling with PHP 5's object oriented try/throw/catch mechanisms. If you are interested, let us know.
    -
    -
  • -
  • QuickCache. Originally authored by Jean Pierre Deckers as jpCache, QuickCache is an HTTP OpCode caching strategy that works on your entire site with only one line of code at the top of your script. The cached pages can be stored as files or as database objects. The benefits are absolutely astounding: bandwidth savings of up to 80% and screen display times increased by 8 - 10x. Visit the QuickCache website at - http://quickcache.codeworxtech.com/.
    -
    -
  • -
  • QuickSkin. Originally authored by Philipp v. Criegern and named "SmartTemplate". The project was taken over by Manuel 'EndelWar' Dalla Lana and now by "codeworxtech". QuickSkin is one of the truly outstanding templating engines available, but has always been confused with Smarty Templating Engine. QuickSkin is even more relevant today than when it was launched. It's a small footprint with big impact on your projects. It features a built in caching technology, token based substitution, and works on the concept of one single HTML file as the template. The HTML template file can contain variable information making it one small powerful tool for your developer tool kit. Visit the QuickSkin website at - http://quickskin.codeworxtech.com/.
    -
    -
  • -
  • QuickTabs. If you read about the projects above, you'll get the sense that we are minimalists and that's pretty accurate. We prefer using tools that are small, efficient, and effective. We have no use for software bloat. QuickTabs came to life in several of our projects where we needed to display complex information in a simplified manner to users. It had to function something like a "wizard" interface, but with more flexibility to float from one item to another. We looked at various Ajax-based solutions, but found one annoying problem with Ajax - page reloads if switching between items (with corresponding data loss if changed by the customer). QuickTabs is our solution to this by presenting complex data in a Javascript show/hide div set. It's not a complex architecture, but it works! Visit the QuickTabs website at http://quicktabs.codeworxtech.com/.
  • -
-

We're committed to PHP and to the Open Source community.

-

Opportunities with Codeworx Technologies:

-
    -
  • Resellers/Agents: We're always interested in talking with companies that -want to represent -Codeworx Technologies in their markets. We also have private label programs for our commercial products (in certain circumstances).
  • -
  • Programmers/Developers: We are usually fully staffed, however, if you would like to be considered for a career with -Codeworx Technologies, we would be pleased to hear from you.
    -A few things to note:
    -
      -
    • experience level does not matter: from fresh out of college to multi-year experience - it's your - creative mind and a positive attitude we want
    • -
    • if you contact us looking for employment, include a cover letter, indicate what type of work/career you are looking for and expected compensation
    • -
    • if you are representing someone else looking for work, do not contact us. We have an exclusive relationship with a recruiting partner already and not interested in altering the arrangement. We will not hire your candidate under any circumstances unless they wish to approach us individually.
    • -
    • any contact that ignores any of these points will be discarded
    • -
  • -
  • Affiliates/Partnerships: We are interested in partnering with other firms who are leaders in their field. We clearly understand that successful companies are built on successful relationships in all industries world-wide. We currently have innovative relationships throughout the world that are mutually beneficial. Drop us a line and let's talk.
  • -
-Regards,
-Andy Prevost (aka, codeworxtech)
-codeworxtech@users.sourceforge.net
-
-
-
- - + + + + + + +
+
+
+The http://phpmailer.codeworxtech.com/ website now carries a few +advertisements through the Google Adsense network to help offset +some of our costs.
+Thanks ....
+
+

My name is Andy Prevost, AKA "codeworxtech".
+www.codeworxtech.com for more information.
+

+

WHY USE OUR TOOLS & WHAT'S IN IT FOR YOU?

+

A valid question. We're developers too. We've been writing software, primarily for the internet, for more than 15 years. Along the way, there are two major things that had tremendous impact of our company: PHP and Open Source. PHP is without doubt the most popular platform for the internet. There has been more progress in this area of technology because of Open Source software than in any other IT segment. We have used many open source tools, some as learning tools, some as components in projects we were working on. To us, it's not about popularity ... we're committed to robust, stable, and efficient tools you can use to get your projects in your user's hands quickly. So the shorter answer: what's in it for you? rapid development and rapid deployment without fuss and with straight forward open source licensing.

+

Now, the introductions:

+

Our company, Worx International Inc., is the publisher of several Open Source applications and developer tools as well as several commercial PHP applications. The Open Source applications are ttCMS and DCP Portal. The Open Source developer tools include QuickComponents (QuickSkin and QuickCache) and now PHPMailer. +We have staff and offices in the United States, Caribbean, the Middle +East, and our primary development center in Canada. Our company is represented by +agents and resellers globally.

+

Worx International Inc. is at the forefront of developing PHP applications. Our staff are all Zend Certified university educated and experts at object oriented programming. While Worx International Inc. can handle any project from trouble shooting programs written by others all the way to finished mission-critical applications, we specialize in taking projects from inception all the way through to implementation - on budget, and on time. If you need help with your projects, we're the team to get it done right at a reasonable price.

+

Over the years, there have been a number of tools that have been constant favorites in all of our projects. We have become the project administrators for most of these tools.

+

Our developer tools are all Open Source. Here's a brief description:

+
    +
  • PHPMailer. Originally authored by Brent Matzelle, PHPMailer is the leading "email transfer class" for PHP. PHPMailer is downloaded more than 18000 times each and every month by developers looking for a stable, simple email solution. We used it ourselves for years as our favorite tool. It's always been small (the entire footprint is around 100 Kb), stable, and as complete a solution as you can find. Other tools are nowhere near as simple. And more importantly, most of our applications (including PHPMailer) is implemented in a smaller footprint than one competing email class. Our thanks to Brent Matzelle for this superb tool - our commitment is to keep it lean, keep it focused, and compliant with standards. Visit the PHPMailer website at + http://phpmailer.codeworxtech.com/.
    + Please note: all of our focus is now on the PHPMailer for PHP5.
    + PS. While you are at it, please visit our sponsor's sites, click on their ads. + It helps offset some of our costs.
    + Want to help? We're looking for progressive developers to join our team of volunteer professionals working on PHPMailer. Our entire focus is on PHPMailer for PHP5, and our next major task is to enhance our + exception/error handling with PHP 5's object oriented try/throw/catch mechanisms. If you are interested, let us know.
    +
    +
  • +
  • QuickCache. Originally authored by Jean Pierre Deckers as jpCache, QuickCache is an HTTP OpCode caching strategy that works on your entire site with only one line of code at the top of your script. The cached pages can be stored as files or as database objects. The benefits are absolutely astounding: bandwidth savings of up to 80% and screen display times increased by 8 - 10x. Visit the QuickCache website at + http://quickcache.codeworxtech.com/.
    +
    +
  • +
  • QuickSkin. Originally authored by Philipp v. Criegern and named "SmartTemplate". The project was taken over by Manuel 'EndelWar' Dalla Lana and now by "codeworxtech". QuickSkin is one of the truly outstanding templating engines available, but has always been confused with Smarty Templating Engine. QuickSkin is even more relevant today than when it was launched. It's a small footprint with big impact on your projects. It features a built in caching technology, token based substitution, and works on the concept of one single HTML file as the template. The HTML template file can contain variable information making it one small powerful tool for your developer tool kit. Visit the QuickSkin website at + http://quickskin.codeworxtech.com/.
    +
    +
  • +
+

We're committed to PHP and to the Open Source community.

+

Opportunities with Worx International Inc.:

+
    +
  • Resellers/Agents: We're always interested in talking with companies that +want to represent +Worx International Inc. in their markets. We also have private label programs for our commercial products (in certain circumstances).
  • +
  • Programmers/Developers: We are usually fully staffed, however, if you would like to be considered for a career with +Worx International Inc., we would be pleased to hear from you.
    +A few things to note:
    +
      +
    • experience level does not matter: from fresh out of college to multi-year experience - it's your + creative mind and a positive attitude we want
    • +
    • if you contact us looking for employment, include a cover letter, indicate what type of work/career you are looking for and expected compensation
    • +
    • if you are representing someone else looking for work, do not contact us. We have an exclusive relationship with a recruiting partner already and not interested in altering the arrangement. We will not hire your candidate under any circumstances unless they wish to approach us individually.
    • +
    • any contact that ignores any of these points will be discarded
    • +
  • +
  • Affiliates/Partnerships: We are interested in partnering with other firms who are leaders in their field. We clearly understand that successful companies are built on successful relationships in all industries world-wide. We currently have innovative relationships throughout the world that are mutually beneficial. Drop us a line and let's talk.
  • +
+Regards,
+Andy Prevost (aka, codeworxtech)
+codeworxtech@users.sourceforge.net
+
+We now also offer website design. hosting, and remote forms processing. Visit WorxStudio.com for more information.
+
+
+ + diff --git a/inc/phpmailer/docs/extending.html b/inc/phpmailer/docs/extending.html index 34f3720d34..f7c3200afc 100644 --- a/inc/phpmailer/docs/extending.html +++ b/inc/phpmailer/docs/extending.html @@ -1,148 +1,148 @@ - - -Examples using phpmailer - - - - -

Examples using phpmailer

- -

1. Advanced Example

-

- -This demonstrates sending out multiple email messages with binary attachments -from a MySQL database with multipart/alternative support.

- - - - -
-
-require("class.phpmailer.php");
-
-$mail = new phpmailer();
-
-$mail->From     = "list@example.com";
-$mail->FromName = "List manager";
-$mail->Host     = "smtp1.example.com;smtp2.example.com";
-$mail->Mailer   = "smtp";
-
-@MYSQL_CONNECT("localhost","root","password");
-@mysql_select_db("my_company");
-$query� =�"SELECT full_name, email,�photo�FROM employee�WHERE�id=$id";
-$result�=�@MYSQL_QUERY($query);
-
-while ($row = mysql_fetch_array ($result))
-{
-    // HTML body
-    $body  = "Hello <font size=\"4\">" . $row["full_name"] . "</font>, <p>";
-    $body .= "<i>Your</i> personal photograph to this message.<p>";
-    $body .= "Sincerely, <br>";
-    $body .= "phpmailer List manager";
-
-    // Plain text body (for mail clients that cannot read HTML)
-    $text_body  = "Hello " . $row["full_name"] . ", \n\n";
-    $text_body .= "Your personal photograph to this message.\n\n";
-    $text_body .= "Sincerely, \n";
-    $text_body .= "phpmailer List manager";
-
-    $mail->Body    = $body;
-    $mail->AltBody = $text_body;
-    $mail->AddAddress($row["email"], $row["full_name"]);
-    $mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");
-
-    if(!$mail->Send())
-        echo "There has been a mail error sending to " . $row["email"] . "<br>";
-
-    // Clear all addresses and attachments for next loop
-    $mail->ClearAddresses();
-    $mail->ClearAttachments();
-}
-
-
-

- -

2. Extending phpmailer

-

- -Extending classes with inheritance is one of the most -powerful features of object-oriented -programming. It allows you to make changes to the -original class for your -own personal use without hacking the original -classes. Plus, it is very -easy to do. I've provided an example: - -

-Here's a class that extends the phpmailer class and sets the defaults -for the particular site:
-PHP include file: mail.inc.php -

- - - - - -
-
-require("class.phpmailer.php");
-
-class my_phpmailer extends phpmailer {
-    // Set default variables for all new objects
-    var $From     = "from@example.com";
-    var $FromName = "Mailer";
-    var $Host     = "smtp1.example.com;smtp2.example.com";
-    var $Mailer   = "smtp";                         // Alternative to IsSMTP()
-    var $WordWrap = 75;
-
-    // Replace the default error_handler
-    function error_handler($msg) {
-        print("My Site Error");
-        print("Description:");
-        printf("%s", $msg);
-        exit;
-    }
-
-    // Create an additional function
-    function do_something($something) {
-        // Place your new code here
-    }
-}
-
-
- -Now here's a normal PHP page in the site, which will have all the defaults set -above:
-Normal PHP file: mail_test.php -

- - - - - -
-
-require("mail.inc.php");
-
-// Instantiate your new class
-$mail = new my_phpmailer;
-
-// Now you only need to add the necessary stuff
-$mail->AddAddress("josh@example.com", "Josh Adams");
-$mail->Subject = "Here is the subject";
-$mail->Body    = "This is the message body";
-$mail->AddAttachment("c:/temp/11-10-00.zip", "new_name.zip");  // optional name
-
-if(!$mail->Send())
-{
-   echo "There was an error sending the message";
-   exit;
-}
-
-echo "Message was sent successfully";
-
-
-

- - - + + +Examples using phpmailer + + + + +

Examples using phpmailer

+ +

1. Advanced Example

+

+ +This demonstrates sending out multiple email messages with binary attachments +from a MySQL database with multipart/alternative support.

+ + + + +
+
+require("class.phpmailer.php");
+
+$mail = new phpmailer();
+
+$mail->From     = "list@example.com";
+$mail->FromName = "List manager";
+$mail->Host     = "smtp1.example.com;smtp2.example.com";
+$mail->Mailer   = "smtp";
+
+@MYSQL_CONNECT("localhost","root","password");
+@mysql_select_db("my_company");
+$query  = "SELECT full_name, email, photo FROM employee WHERE id=$id";
+$result = @MYSQL_QUERY($query);
+
+while ($row = mysql_fetch_array ($result))
+{
+    // HTML body
+    $body  = "Hello <font size=\"4\">" . $row["full_name"] . "</font>, <p>";
+    $body .= "<i>Your</i> personal photograph to this message.<p>";
+    $body .= "Sincerely, <br>";
+    $body .= "phpmailer List manager";
+
+    // Plain text body (for mail clients that cannot read HTML)
+    $text_body  = "Hello " . $row["full_name"] . ", \n\n";
+    $text_body .= "Your personal photograph to this message.\n\n";
+    $text_body .= "Sincerely, \n";
+    $text_body .= "phpmailer List manager";
+
+    $mail->Body    = $body;
+    $mail->AltBody = $text_body;
+    $mail->AddAddress($row["email"], $row["full_name"]);
+    $mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");
+
+    if(!$mail->Send())
+        echo "There has been a mail error sending to " . $row["email"] . "<br>";
+
+    // Clear all addresses and attachments for next loop
+    $mail->ClearAddresses();
+    $mail->ClearAttachments();
+}
+
+
+

+ +

2. Extending phpmailer

+

+ +Extending classes with inheritance is one of the most +powerful features of object-oriented +programming. It allows you to make changes to the +original class for your +own personal use without hacking the original +classes. Plus, it is very +easy to do. I've provided an example: + +

+Here's a class that extends the phpmailer class and sets the defaults +for the particular site:
+PHP include file: mail.inc.php +

+ + + + + +
+
+require("class.phpmailer.php");
+
+class my_phpmailer extends phpmailer {
+    // Set default variables for all new objects
+    var $From     = "from@example.com";
+    var $FromName = "Mailer";
+    var $Host     = "smtp1.example.com;smtp2.example.com";
+    var $Mailer   = "smtp";                         // Alternative to IsSMTP()
+    var $WordWrap = 75;
+
+    // Replace the default error_handler
+    function error_handler($msg) {
+        print("My Site Error");
+        print("Description:");
+        printf("%s", $msg);
+        exit;
+    }
+
+    // Create an additional function
+    function do_something($something) {
+        // Place your new code here
+    }
+}
+
+
+ +Now here's a normal PHP page in the site, which will have all the defaults set +above:
+Normal PHP file: mail_test.php +

+ + + + + +
+
+require("mail.inc.php");
+
+// Instantiate your new class
+$mail = new my_phpmailer;
+
+// Now you only need to add the necessary stuff
+$mail->AddAddress("josh@example.com", "Josh Adams");
+$mail->Subject = "Here is the subject";
+$mail->Body    = "This is the message body";
+$mail->AddAttachment("c:/temp/11-10-00.zip", "new_name.zip");  // optional name
+
+if(!$mail->Send())
+{
+   echo "There was an error sending the message";
+   exit;
+}
+
+echo "Message was sent successfully";
+
+
+

+ + + diff --git a/inc/phpmailer/docs/pop3_article.txt b/inc/phpmailer/docs/pop3_article.txt index cc54f7c00a..379c44e89b 100644 --- a/inc/phpmailer/docs/pop3_article.txt +++ b/inc/phpmailer/docs/pop3_article.txt @@ -1,39 +1,39 @@ -This is built for PHP Mailer 1.72 and was not tested with any previous version. It was developed under PHP 4.3.11 (E_ALL). It works under PHP 5 and 5.1 with E_ALL, but not in Strict mode due to var deprecation (but then neither does PHP Mailer either!). It follows the RFC 1939 standard explicitly and is fully commented. - -With that noted, here is how to implement it: -Install the class file - -I didn't want to modify the PHP Mailer classes at all, so you will have to include/require this class along with the base one. It can sit quite happily in the phpmailer-1.72 directory: -[geshi lang=php] require 'phpmailer-1.72/class.phpmailer.php'; require 'phpmailer-1.72/class.pop3.php'; [/geshi] -When you need it, create your POP3 object - -Right before I invoke PHP Mailer I activate the POP3 authorisation. POP3 before SMTP is a process whereby you login to your web hosts POP3 mail server BEFORE sending out any emails via SMTP. The POP3 logon 'verifies' your ability to send email by SMTP, which typically otherwise blocks you. On my web host (Pair Networks) a single POP3 logon is enough to 'verify' you for 90 minutes. Here is some sample PHP code that activates the POP3 logon and then sends an email via PHP Mailer: -[geshi lang=php] Authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1); $mail = new PHPMailer(); $mail->SMTPDebug = 2; $mail->IsSMTP(); $mail->IsHTML(false); $mail->Host = 'relay.example.com'; $mail->From = 'mailer@example.com'; $mail->FromName = 'Example Mailer'; $mail->Subject = 'My subject'; $mail->Body = 'Hello world'; $mail->AddAddress('rich@corephp.co.uk', 'Richard Davey'); if (!$mail->Send()) { echo $mail->ErrorInfo; } ?> [/geshi] - -The PHP Mailer parts of this code should be obvious to anyone who has used PHP Mailer before. One thing to note - you almost certainly will not need to use SMTP Authentication *and* POP3 before SMTP together. The Authorisation method is a proxy method to all of the others within that class. There are Connect, Logon and Disconnect methods available, but I wrapped them in the single Authorisation one to make things easier. -The Parameters - -The Authorise parameters are as follows: -[geshi lang=php]$pop->Authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1);[/geshi] - - 1. pop3.example.com - The POP3 Mail Server Name (hostname or IP address) - 2. 110 - The POP3 Port on which to connect (default is usually 110, but check with your host) - 3. 30 - A connection time-out value (in seconds) - 4. mailer - The POP3 Username required to logon - 5. password - The POP3 Password required to logon - 6. 1 - The class debug level (0 = off, 1+ = debug output is echoed to the browser) - -Final Comments + the Download - -1) This class does not support APOP connections. This is only because I did not have an APOP server to test with, but if you'd like to see that added just contact me. - -2) Opening and closing lots of POP3 connections can be quite a resource/network drain. If you need to send a whole batch of emails then just perform the authentication once at the start, and then loop through your mail sending script. Providing this process doesn't take longer than the verification period lasts on your POP3 server, you should be fine. With my host that period is 90 minutes, i.e. plenty of time. - -3) If you have heavy requirements for this script (i.e. send a LOT of email on a frequent basis) then I would advise seeking out an alternative sending method (direct SMTP ideally). If this isn't possible then you could modify this class so the 'last authorised' date is recorded somewhere (MySQL, Flat file, etc) meaning you only open a new connection if the old one has expired, saving you precious overhead. - -4) There are lots of other POP3 classes for PHP available. However most of them implement the full POP3 command set, where-as this one is purely for authentication, and much lighter as a result. However using any of the other POP3 classes to just logon to your server would have the same net result. At the end of the day, use whatever method you feel most comfortable with. -Download - -Here is the full class file plus my test script: POP_before_SMTP_PHPMailer.zip (4 KB) - Please note that it does not include PHPMailer itself. - -My thanks to Chris Ryan for the inspiration (even if indirectly, via his SMTP class) +This is built for PHP Mailer 1.72 and was not tested with any previous version. It was developed under PHP 4.3.11 (E_ALL). It works under PHP 5 and 5.1 with E_ALL, but not in Strict mode due to var deprecation (but then neither does PHP Mailer either!). It follows the RFC 1939 standard explicitly and is fully commented. + +With that noted, here is how to implement it: +Install the class file + +I didn't want to modify the PHP Mailer classes at all, so you will have to include/require this class along with the base one. It can sit quite happily in the phpmailer-1.72 directory: +[geshi lang=php] require 'phpmailer-1.72/class.phpmailer.php'; require 'phpmailer-1.72/class.pop3.php'; [/geshi] +When you need it, create your POP3 object + +Right before I invoke PHP Mailer I activate the POP3 authorisation. POP3 before SMTP is a process whereby you login to your web hosts POP3 mail server BEFORE sending out any emails via SMTP. The POP3 logon 'verifies' your ability to send email by SMTP, which typically otherwise blocks you. On my web host (Pair Networks) a single POP3 logon is enough to 'verify' you for 90 minutes. Here is some sample PHP code that activates the POP3 logon and then sends an email via PHP Mailer: +[geshi lang=php] Authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1); $mail = new PHPMailer(); $mail->SMTPDebug = 2; $mail->IsSMTP(); $mail->IsHTML(false); $mail->Host = 'relay.example.com'; $mail->From = 'mailer@example.com'; $mail->FromName = 'Example Mailer'; $mail->Subject = 'My subject'; $mail->Body = 'Hello world'; $mail->AddAddress('rich@corephp.co.uk', 'Richard Davey'); if (!$mail->Send()) { echo $mail->ErrorInfo; } ?> [/geshi] + +The PHP Mailer parts of this code should be obvious to anyone who has used PHP Mailer before. One thing to note - you almost certainly will not need to use SMTP Authentication *and* POP3 before SMTP together. The Authorisation method is a proxy method to all of the others within that class. There are Connect, Logon and Disconnect methods available, but I wrapped them in the single Authorisation one to make things easier. +The Parameters + +The Authorise parameters are as follows: +[geshi lang=php]$pop->Authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1);[/geshi] + + 1. pop3.example.com - The POP3 Mail Server Name (hostname or IP address) + 2. 110 - The POP3 Port on which to connect (default is usually 110, but check with your host) + 3. 30 - A connection time-out value (in seconds) + 4. mailer - The POP3 Username required to logon + 5. password - The POP3 Password required to logon + 6. 1 - The class debug level (0 = off, 1+ = debug output is echoed to the browser) + +Final Comments + the Download + +1) This class does not support APOP connections. This is only because I did not have an APOP server to test with, but if you'd like to see that added just contact me. + +2) Opening and closing lots of POP3 connections can be quite a resource/network drain. If you need to send a whole batch of emails then just perform the authentication once at the start, and then loop through your mail sending script. Providing this process doesn't take longer than the verification period lasts on your POP3 server, you should be fine. With my host that period is 90 minutes, i.e. plenty of time. + +3) If you have heavy requirements for this script (i.e. send a LOT of email on a frequent basis) then I would advise seeking out an alternative sending method (direct SMTP ideally). If this isn't possible then you could modify this class so the 'last authorised' date is recorded somewhere (MySQL, Flat file, etc) meaning you only open a new connection if the old one has expired, saving you precious overhead. + +4) There are lots of other POP3 classes for PHP available. However most of them implement the full POP3 command set, where-as this one is purely for authentication, and much lighter as a result. However using any of the other POP3 classes to just logon to your server would have the same net result. At the end of the day, use whatever method you feel most comfortable with. +Download + +Here is the full class file plus my test script: POP_before_SMTP_PHPMailer.zip (4 KB) - Please note that it does not include PHPMailer itself. + +My thanks to Chris Ryan for the inspiration (even if indirectly, via his SMTP class) diff --git a/inc/phpmailer/examples/contents.html b/inc/phpmailer/examples/contents.html index 3efbda27da..70c7e30704 100644 --- a/inc/phpmailer/examples/contents.html +++ b/inc/phpmailer/examples/contents.html @@ -1,12 +1,12 @@ - -
-

-
- This is a test of PHPMailer v2.0.0 rc1.
-
-This particular example uses HTML, with a <div> tag and inline
-styles.
-
-Also note the use of the PHPMailer at the top with no specific code to handle -including it in the body of the email.
- + +
+

+
+ This is a test of PHPMailer v2.0.0 rc1.
+
+This particular example uses HTML, with a <div> tag and inline
+styles.
+
+Also note the use of the PHPMailer at the top with no specific code to handle +including it in the body of the email.
+ diff --git a/inc/phpmailer/examples/pop3_before_smtp_test.php b/inc/phpmailer/examples/pop3_before_smtp_test.php index b10b5e151d..794b2a2674 100644 --- a/inc/phpmailer/examples/pop3_before_smtp_test.php +++ b/inc/phpmailer/examples/pop3_before_smtp_test.php @@ -1,39 +1,39 @@ - - -POP before SMTP Test - - - - -
-Authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1);
-
-  $mail = new PHPMailer();
-
-  $mail->IsSMTP();
-  $mail->SMTPDebug = 2;
-  $mail->IsHTML(false);
-
-  $mail->Host     = 'relay.example.com';
-
-  $mail->From     = 'mailer@example.com';
-  $mail->FromName = 'Example Mailer';
-
-  $mail->Subject  =  'My subject';
-  $mail->Body     =  'Hello world';
-  $mail->AddAddress('name@anydomain.com', 'First Last');
-
-  if (!$mail->Send())
-  {
-    echo $mail->ErrorInfo;
-  }
-?>
-
- - - + + +POP before SMTP Test + + + + +
+Authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1);
+
+  $mail = new PHPMailer();
+
+  $mail->IsSMTP();
+  $mail->SMTPDebug = 2;
+  $mail->IsHTML(false);
+
+  $mail->Host     = 'relay.example.com';
+
+  $mail->From     = 'mailer@example.com';
+  $mail->FromName = 'Example Mailer';
+
+  $mail->Subject  =  'My subject';
+  $mail->Body     =  'Hello world';
+  $mail->AddAddress('name@anydomain.com', 'First Last');
+
+  if (!$mail->Send())
+  {
+    echo $mail->ErrorInfo;
+  }
+?>
+
+ + + diff --git a/inc/phpmailer/language/phpmailer.lang-br.php b/inc/phpmailer/language/phpmailer.lang-br.php index 601d3b8101..abb2fed08f 100644 --- a/inc/phpmailer/language/phpmailer.lang-br.php +++ b/inc/phpmailer/language/phpmailer.lang-br.php @@ -20,5 +20,4 @@ $PHPMAILER_LANG["file_open"] = 'Erro de Arquivo: Não foi possível a $PHPMAILER_LANG["encoding"] = 'Codificação desconhecida: '; $PHPMAILER_LANG["signing"] = 'Signing Error: '; -?> - +?> \ No newline at end of file diff --git a/inc/phpmailer/language/phpmailer.lang-ca.php b/inc/phpmailer/language/phpmailer.lang-ca.php index dbb22985ac..c5ca72b9cf 100644 --- a/inc/phpmailer/language/phpmailer.lang-ca.php +++ b/inc/phpmailer/language/phpmailer.lang-ca.php @@ -21,4 +21,4 @@ $PHPMAILER_LANG["file_open"] = 'Error d\'Arxiu: No es pot obrir l\'ar $PHPMAILER_LANG["encoding"] = 'Codificació desconeguda: '; $PHPMAILER_LANG["signing"] = 'Signing Error: '; -?> +?> \ No newline at end of file diff --git a/inc/phpmailer/language/phpmailer.lang-cz.php b/inc/phpmailer/language/phpmailer.lang-cz.php index ae82d2d040..48e4669e25 100644 --- a/inc/phpmailer/language/phpmailer.lang-cz.php +++ b/inc/phpmailer/language/phpmailer.lang-cz.php @@ -23,4 +23,4 @@ $PHPMAILER_LANG["file_open"] = 'File Error: Nelze otevøít soubor pr $PHPMAILER_LANG["encoding"] = 'Neznámé kódování: '; $PHPMAILER_LANG["signing"] = 'Signing Error: '; -?> +?> \ No newline at end of file diff --git a/inc/phpmailer/language/phpmailer.lang-de.php b/inc/phpmailer/language/phpmailer.lang-de.php index 53c20e13c1..843971b965 100644 --- a/inc/phpmailer/language/phpmailer.lang-de.php +++ b/inc/phpmailer/language/phpmailer.lang-de.php @@ -2,6 +2,7 @@ /** * PHPMailer language file. * German Version + * Thanks to Yann-Patrick Schlame for the latest update! */ $PHPMAILER_LANG = array(); @@ -20,7 +21,6 @@ $PHPMAILER_LANG["connect_host"] = 'SMTP Fehler: Konnte keine Verbindung $PHPMAILER_LANG["file_access"] = 'Zugriff auf folgende Datei fehlgeschlagen: '; $PHPMAILER_LANG["file_open"] = 'Datei Fehler: konnte folgende Datei nicht öffnen: '; $PHPMAILER_LANG["encoding"] = 'Unbekanntes Encoding-Format: '; -$PHPMAILER_LANG["signing"] = 'Signing Error: '; - -?> +$PHPMAILER_LANG["signing"] = 'Fehler beim Signieren: '; +?> \ No newline at end of file diff --git a/inc/phpmailer/language/phpmailer.lang-de.zip b/inc/phpmailer/language/phpmailer.lang-de.zip new file mode 100644 index 0000000000..0cd50dfcb1 Binary files /dev/null and b/inc/phpmailer/language/phpmailer.lang-de.zip differ diff --git a/inc/phpmailer/language/phpmailer.lang-dk.php b/inc/phpmailer/language/phpmailer.lang-dk.php index fe60f314b1..8c1f595431 100644 --- a/inc/phpmailer/language/phpmailer.lang-dk.php +++ b/inc/phpmailer/language/phpmailer.lang-dk.php @@ -2,8 +2,7 @@ /** * PHPMailer language file. * Danish Version - * Author: Mikael Stokkebro - */ + * Author: Mikael Stokkebro */ $PHPMAILER_LANG = array(); @@ -23,4 +22,4 @@ $PHPMAILER_LANG["file_open"] = 'Fil fejl: Kunne ikke Ã¥bne filen: '; $PHPMAILER_LANG["encoding"] = 'Ukendt encode-format: '; $PHPMAILER_LANG["signing"] = 'Signing Error: '; -?> +?> \ No newline at end of file diff --git a/inc/phpmailer/language/phpmailer.lang-en.php b/inc/phpmailer/language/phpmailer.lang-en.php index f7d4286d07..f0e7be3fa6 100644 --- a/inc/phpmailer/language/phpmailer.lang-en.php +++ b/inc/phpmailer/language/phpmailer.lang-en.php @@ -22,4 +22,4 @@ $PHPMAILER_LANG["file_open"] = 'File Error: Could not open file: '; $PHPMAILER_LANG["encoding"] = 'Unknown encoding: '; $PHPMAILER_LANG["signing"] = 'Signing Error: '; -?> +?> \ No newline at end of file diff --git a/inc/phpmailer/language/phpmailer.lang-es.php b/inc/phpmailer/language/phpmailer.lang-es.php index bebf632f02..493e9b414d 100644 --- a/inc/phpmailer/language/phpmailer.lang-es.php +++ b/inc/phpmailer/language/phpmailer.lang-es.php @@ -22,4 +22,4 @@ $PHPMAILER_LANG["file_open"] = 'Error de Archivo: No puede abrir el a $PHPMAILER_LANG["encoding"] = 'Codificación desconocida: '; $PHPMAILER_LANG["signing"] = 'Error al firmar: '; -?> +?> \ No newline at end of file diff --git a/inc/phpmailer/language/phpmailer.lang-et.php b/inc/phpmailer/language/phpmailer.lang-et.php index 3fd55953be..40cfc62237 100644 --- a/inc/phpmailer/language/phpmailer.lang-et.php +++ b/inc/phpmailer/language/phpmailer.lang-et.php @@ -21,4 +21,4 @@ $PHPMAILER_LANG["file_open"] = 'Faili Viga: Faili avamine ebaõ $PHPMAILER_LANG["encoding"] = 'Tundmatu Unknown kodeering: '; $PHPMAILER_LANG["signing"] = 'Signing Error: '; -?> +?> \ No newline at end of file diff --git a/inc/phpmailer/language/phpmailer.lang-fi.php b/inc/phpmailer/language/phpmailer.lang-fi.php index e2bb497a2f..1c4feace2d 100644 --- a/inc/phpmailer/language/phpmailer.lang-fi.php +++ b/inc/phpmailer/language/phpmailer.lang-fi.php @@ -22,4 +22,4 @@ $PHPMAILER_LANG["file_open"] = 'Tiedostovirhe: Ei voida avata tiedost $PHPMAILER_LANG["encoding"] = 'Tuntematon koodaustyyppi: '; $PHPMAILER_LANG["signing"] = 'Signing Error: '; -?> +?> \ No newline at end of file diff --git a/inc/phpmailer/language/phpmailer.lang-fo.php b/inc/phpmailer/language/phpmailer.lang-fo.php index 13b136fc76..5cb24ced2a 100644 --- a/inc/phpmailer/language/phpmailer.lang-fo.php +++ b/inc/phpmailer/language/phpmailer.lang-fo.php @@ -24,4 +24,4 @@ $PHPMAILER_LANG["file_open"] = 'Fílu feilur: Kundi ikki opna fílu: $PHPMAILER_LANG["encoding"] = 'Ókend encoding: '; $PHPMAILER_LANG["signing"] = 'Signing Error: '; -?> +?> \ No newline at end of file diff --git a/inc/phpmailer/language/phpmailer.lang-fr.php b/inc/phpmailer/language/phpmailer.lang-fr.php index 8ef292a52c..e00dac7098 100644 --- a/inc/phpmailer/language/phpmailer.lang-fr.php +++ b/inc/phpmailer/language/phpmailer.lang-fr.php @@ -22,5 +22,4 @@ $PHPMAILER_LANG["file_open"] = 'Erreur Fichier : ouverture impossible $PHPMAILER_LANG["encoding"] = 'Encodage inconnu : '; $PHPMAILER_LANG["signing"] = 'Signing Error: '; -?> - +?> \ No newline at end of file diff --git a/inc/phpmailer/language/phpmailer.lang-hu.php b/inc/phpmailer/language/phpmailer.lang-hu.php index 8eafba7675..f97e0d9e49 100644 --- a/inc/phpmailer/language/phpmailer.lang-hu.php +++ b/inc/phpmailer/language/phpmailer.lang-hu.php @@ -22,4 +22,4 @@ $PHPMAILER_LANG["file_open"] = 'Fájl Hiba: Nem sikerült megnyitni a $PHPMAILER_LANG["encoding"] = 'Ismeretlen kódolás: '; $PHPMAILER_LANG["signing"] = 'Signing Error: '; -?> +?> \ No newline at end of file diff --git a/inc/phpmailer/language/phpmailer.lang-it.php b/inc/phpmailer/language/phpmailer.lang-it.php index 2fb6a5d255..4efb46a415 100644 --- a/inc/phpmailer/language/phpmailer.lang-it.php +++ b/inc/phpmailer/language/phpmailer.lang-it.php @@ -3,8 +3,7 @@ * PHPMailer language file. * Italian version * @package PHPMailer -* @author Ilias Bartolini -*/ +* @author Ilias Bartolini */ $PHPMAILER_LANG = array(); @@ -27,4 +26,4 @@ $PHPMAILER_LANG["file_open"] = 'File Error: Impossibile aprire il fil $PHPMAILER_LANG["encoding"] = 'Encoding set dei caratteri sconosciuto: '; $PHPMAILER_LANG["signing"] = 'Signing Error: '; -?> +?> \ No newline at end of file diff --git a/inc/phpmailer/language/phpmailer.lang-ja.php b/inc/phpmailer/language/phpmailer.lang-ja.php index 2e188eb6bd..92e2b66627 100644 Binary files a/inc/phpmailer/language/phpmailer.lang-ja.php and b/inc/phpmailer/language/phpmailer.lang-ja.php differ diff --git a/inc/phpmailer/language/phpmailer.lang-nl.php b/inc/phpmailer/language/phpmailer.lang-nl.php index 262b543a43..459de614ee 100644 --- a/inc/phpmailer/language/phpmailer.lang-nl.php +++ b/inc/phpmailer/language/phpmailer.lang-nl.php @@ -22,4 +22,4 @@ $PHPMAILER_LANG["file_open"] = 'Bestandsfout: Kon bestand niet openen $PHPMAILER_LANG["encoding"] = 'Onbekende codering: '; $PHPMAILER_LANG["signing"] = 'Signing Error: '; -?> +?> \ No newline at end of file diff --git a/inc/phpmailer/language/phpmailer.lang-no.php b/inc/phpmailer/language/phpmailer.lang-no.php index 9a2534151d..06d93107ac 100644 --- a/inc/phpmailer/language/phpmailer.lang-no.php +++ b/inc/phpmailer/language/phpmailer.lang-no.php @@ -22,4 +22,4 @@ $PHPMAILER_LANG["file_open"] = 'Fil feil: Kunne ikke Ã¥pne filen: '; $PHPMAILER_LANG["encoding"] = 'Ukjent encoding: '; $PHPMAILER_LANG["signing"] = 'Signing Error: '; -?> +?> \ No newline at end of file diff --git a/inc/phpmailer/language/phpmailer.lang-pl.php b/inc/phpmailer/language/phpmailer.lang-pl.php index e2f86ff195..2b342a3ae5 100644 --- a/inc/phpmailer/language/phpmailer.lang-pl.php +++ b/inc/phpmailer/language/phpmailer.lang-pl.php @@ -22,4 +22,4 @@ $PHPMAILER_LANG["file_open"] = 'Nie mo¿na otworzyæ pliku: '; $PHPMAILER_LANG["encoding"] = 'Nieznany sposób kodowania znaków: '; $PHPMAILER_LANG["signing"] = 'Signing Error: '; -?> +?> \ No newline at end of file diff --git a/inc/phpmailer/language/phpmailer.lang-ro.php b/inc/phpmailer/language/phpmailer.lang-ro.php index 335021719d..dbc4b38d13 100644 --- a/inc/phpmailer/language/phpmailer.lang-ro.php +++ b/inc/phpmailer/language/phpmailer.lang-ro.php @@ -3,8 +3,7 @@ * PHPMailer language file. * Romanian Version * @package PHPMailer - * @author Catalin Constantin - */ + * @author Catalin Constantin */ $PHPMAILER_LANG = array(); @@ -22,4 +21,4 @@ $PHPMAILER_LANG["file_open"] = 'Eroare de fisier: Nu pot deschide fis $PHPMAILER_LANG["encoding"] = 'Encodare necunoscuta: '; $PHPMAILER_LANG["signing"] = 'Signing Error: '; -?> +?> \ No newline at end of file diff --git a/inc/phpmailer/language/phpmailer.lang-ru.php b/inc/phpmailer/language/phpmailer.lang-ru.php index 2e1b14839b..996d1881e8 100644 --- a/inc/phpmailer/language/phpmailer.lang-ru.php +++ b/inc/phpmailer/language/phpmailer.lang-ru.php @@ -1,8 +1,7 @@ - */ + * Russian Version by Alexey Chumakov */ $PHPMAILER_LANG = array(); @@ -22,5 +21,4 @@ $PHPMAILER_LANG["file_open"] = ' $PHPMAILER_LANG["encoding"] = 'Íåèçâåñòíûé âèä êîäèðîâêè: '; $PHPMAILER_LANG["signing"] = 'Signing Error: '; -?> - +?> \ No newline at end of file diff --git a/inc/phpmailer/language/phpmailer.lang-se.php b/inc/phpmailer/language/phpmailer.lang-se.php index e61bbb127a..dea6e6417e 100644 --- a/inc/phpmailer/language/phpmailer.lang-se.php +++ b/inc/phpmailer/language/phpmailer.lang-se.php @@ -2,8 +2,7 @@ /** * PHPMailer language file. * Swedish Version - * Author: Johan Linnér - */ + * Author: Johan Linnér */ $PHPMAILER_LANG = array(); @@ -23,4 +22,4 @@ $PHPMAILER_LANG["file_open"] = 'Fil fel: Kunde inte $PHPMAILER_LANG["encoding"] = 'Okänt encode-format: '; $PHPMAILER_LANG["signing"] = 'Signing Error: '; -?> +?> \ No newline at end of file diff --git a/inc/phpmailer/language/phpmailer.lang-tr.php b/inc/phpmailer/language/phpmailer.lang-tr.php index c8f388eec0..4e3e675ce8 100644 --- a/inc/phpmailer/language/phpmailer.lang-tr.php +++ b/inc/phpmailer/language/phpmailer.lang-tr.php @@ -23,4 +23,4 @@ $PHPMAILER_LANG["file_open"] = 'Dosya Hatas $PHPMAILER_LANG["encoding"] = 'Bilinmeyen þifreleme: '; $PHPMAILER_LANG["signing"] = 'Signing Error: '; -?> +?> \ No newline at end of file diff --git a/inc/phpmailer/test/phpmailer_test.php b/inc/phpmailer/test/phpmailer_test.php index 63743ea8c2..22d6f42b8e 100644 --- a/inc/phpmailer/test/phpmailer_test.php +++ b/inc/phpmailer/test/phpmailer_test.php @@ -1,572 +1,572 @@ -TestCase( $name ); - } - - /** - * Run before each test is started. - */ - function setUp() { - global $global_vars; - global $INCLUDE_DIR; - - $this->Mail = new PHPMailer(); - - $this->Mail->Priority = 3; - $this->Mail->Encoding = "8bit"; - $this->Mail->CharSet = "iso-8859-1"; - $this->Mail->From = "unit_test@phpmailer.sf.net"; - $this->Mail->FromName = "Unit Tester"; - $this->Mail->Sender = ""; - $this->Mail->Subject = "Unit Test"; - $this->Mail->Body = ""; - $this->Mail->AltBody = ""; - $this->Mail->WordWrap = 0; - $this->Mail->Host = $global_vars["mail_host"]; - $this->Mail->Port = 25; - $this->Mail->Helo = "localhost.localdomain"; - $this->Mail->SMTPAuth = false; - $this->Mail->Username = ""; - $this->Mail->Password = ""; - $this->Mail->PluginDir = $INCLUDE_DIR; - $this->Mail->AddReplyTo("no_reply@phpmailer.sf.net", "Reply Guy"); - $this->Mail->Sender = "unit_test@phpmailer.sf.net"; - - if(strlen($this->Mail->Host) > 0) - $this->Mail->Mailer = "smtp"; - else - { - $this->Mail->Mailer = "mail"; - $this->Sender = "unit_test@phpmailer.sf.net"; - } - - global $global_vars; - $this->SetAddress($global_vars["mail_to"], "Test User"); - if(strlen($global_vars["mail_cc"]) > 0) - $this->SetAddress($global_vars["mail_cc"], "Carbon User", "cc"); - } - - /** - * Run after each test is completed. - */ - function tearDown() { - // Clean global variables - $this->Mail = NULL; - $this->ChangeLog = array(); - $this->NoteLog = array(); - } - - - /** - * Build the body of the message in the appropriate format. - * @private - * @returns void - */ - function BuildBody() { - $this->CheckChanges(); - - // Determine line endings for message - if($this->Mail->ContentType == "text/html" || strlen($this->Mail->AltBody) > 0) - { - $eol = "
"; - $bullet = "
  • "; - $bullet_start = "
      "; - $bullet_end = "
    "; - } - else - { - $eol = "\n"; - $bullet = " - "; - $bullet_start = ""; - $bullet_end = ""; - } - - $ReportBody = ""; - - $ReportBody .= "---------------------" . $eol; - $ReportBody .= "Unit Test Information" . $eol; - $ReportBody .= "---------------------" . $eol; - $ReportBody .= "phpmailer version: " . $this->Mail->Version . $eol; - $ReportBody .= "Content Type: " . $this->Mail->ContentType . $eol; - - if(strlen($this->Mail->Host) > 0) - $ReportBody .= "Host: " . $this->Mail->Host . $eol; - - // If attachments then create an attachment list - if(count($this->Mail->attachment) > 0) - { - $ReportBody .= "Attachments:" . $eol; - $ReportBody .= $bullet_start; - for($i = 0; $i < count($this->Mail->attachment); $i++) - { - $ReportBody .= $bullet . "Name: " . $this->Mail->attachment[$i][1] . ", "; - $ReportBody .= "Encoding: " . $this->Mail->attachment[$i][3] . ", "; - $ReportBody .= "Type: " . $this->Mail->attachment[$i][4] . $eol; - } - $ReportBody .= $bullet_end . $eol; - } - - // If there are changes then list them - if(count($this->ChangeLog) > 0) - { - $ReportBody .= "Changes" . $eol; - $ReportBody .= "-------" . $eol; - - $ReportBody .= $bullet_start; - for($i = 0; $i < count($this->ChangeLog); $i++) - { - $ReportBody .= $bullet . $this->ChangeLog[$i][0] . " was changed to [" . - $this->ChangeLog[$i][1] . "]" . $eol; - } - $ReportBody .= $bullet_end . $eol . $eol; - } - - // If there are notes then list them - if(count($this->NoteLog) > 0) - { - $ReportBody .= "Notes" . $eol; - $ReportBody .= "-----" . $eol; - - $ReportBody .= $bullet_start; - for($i = 0; $i < count($this->NoteLog); $i++) - { - $ReportBody .= $bullet . $this->NoteLog[$i] . $eol; - } - $ReportBody .= $bullet_end; - } - - // Re-attach the original body - $this->Mail->Body .= $eol . $eol . $ReportBody; - } - - /** - * Check which default settings have been changed for the report. - * @private - * @returns void - */ - function CheckChanges() { - if($this->Mail->Priority != 3) - $this->AddChange("Priority", $this->Mail->Priority); - if($this->Mail->Encoding != "8bit") - $this->AddChange("Encoding", $this->Mail->Encoding); - if($this->Mail->CharSet != "iso-8859-1") - $this->AddChange("CharSet", $this->Mail->CharSet); - if($this->Mail->Sender != '') - $this->AddChange("Sender", $this->Mail->Sender); - if($this->Mail->WordWrap != 0) - $this->AddChange("WordWrap", $this->Mail->WordWrap); - if($this->Mail->Mailer != "mail") - $this->AddChange("Mailer", $this->Mail->Mailer); - if($this->Mail->Port != 25) - $this->AddChange("Port", $this->Mail->Port); - if($this->Mail->Helo != "localhost.localdomain") - $this->AddChange("Helo", $this->Mail->Helo); - if($this->Mail->SMTPAuth) - $this->AddChange("SMTPAuth", "true"); - } - - /** - * Adds a change entry. - * @private - * @returns void - */ - function AddChange($sName, $sNewValue) { - $cur = count($this->ChangeLog); - $this->ChangeLog[$cur][0] = $sName; - $this->ChangeLog[$cur][1] = $sNewValue; - } - - /** - * Adds a simple note to the message. - * @public - * @returns void - */ - function AddNote($sValue) { - $this->NoteLog[] = $sValue; - } - - /** - * Adds all of the addresses - * @public - * @returns void - */ - function SetAddress($sAddress, $sName = "", $sType = "to") { - switch($sType) - { - case "to": - $this->Mail->AddAddress($sAddress, $sName); - break; - case "cc": - $this->Mail->AddCC($sAddress, $sName); - break; - case "bcc": - $this->Mail->AddBCC($sAddress, $sName); - break; - } - } - - ///////////////////////////////////////////////// - // UNIT TESTS - ///////////////////////////////////////////////// - - /** - * Try a plain message. - */ - function test_WordWrap() { - - $this->Mail->WordWrap = 40; - $my_body = "Here is the main body of this message. It should " . - "be quite a few lines. It should be wrapped at the " . - "40 characters. Make sure that it is."; - $nBodyLen = strlen($my_body); - $my_body .= "\n\nThis is the above body length: " . $nBodyLen; - - $this->Mail->Body = $my_body; - $this->Mail->Subject .= ": Wordwrap"; - - $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - } - - /** - * Try a plain message. - */ - function test_Low_Priority() { - - $this->Mail->Priority = 5; - $this->Mail->Body = "Here is the main body. There should be " . - "a reply to address in this message."; - $this->Mail->Subject .= ": Low Priority"; - $this->Mail->AddReplyTo("nobody@nobody.com", "Nobody (Unit Test)"); - - $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - } - - /** - * Simple plain file attachment test. - */ - function test_Multiple_Plain_FileAttachment() { - - $this->Mail->Body = "Here is the text body"; - $this->Mail->Subject .= ": Plain + Multiple FileAttachments"; - - if(!$this->Mail->AddAttachment("test.png")) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - if(!$this->Mail->AddAttachment("phpmailer_test.php", "test.txt")) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - } - - /** - * Simple plain string attachment test. - */ - function test_Plain_StringAttachment() { - - $this->Mail->Body = "Here is the text body"; - $this->Mail->Subject .= ": Plain + StringAttachment"; - - $sAttachment = "These characters are the content of the " . - "string attachment.\nThis might be taken from a ". - "database or some other such thing. "; - - $this->Mail->AddStringAttachment($sAttachment, "string_attach.txt"); - - $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - } - - /** - * Plain quoted-printable message. - */ - function test_Quoted_Printable() { - - $this->Mail->Body = "Here is the main body"; - $this->Mail->Subject .= ": Plain + Quoted-printable"; - $this->Mail->Encoding = "quoted-printable"; - - $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - } - - /** - * Try a plain message. - */ - function test_Html() { - - $this->Mail->IsHTML(true); - $this->Mail->Subject .= ": HTML only"; - - $this->Mail->Body = "This is a test message written in HTML.
    " . - "Go to " . - "http://phpmailer.sourceforge.net/ for new versions of " . - "phpmailer.

    Thank you!"; - - $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - } - - /** - * Simple HTML and attachment test - */ - function test_HTML_Attachment() { - - $this->Mail->Body = "This is the HTML part of the email."; - $this->Mail->Subject .= ": HTML + Attachment"; - $this->Mail->IsHTML(true); - - if(!$this->Mail->AddAttachment("phpmailer_test.php", "test_attach.txt")) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - } - - /** - * An embedded attachment test. - */ - function test_Embedded_Image() { - - $this->Mail->Body = "Embedded Image: \"phpmailer\"" . - "Here is an image!"; - $this->Mail->Subject .= ": Embedded Image"; - $this->Mail->IsHTML(true); - - if(!$this->Mail->AddEmbeddedImage("test.png", "my-attach", "test.png", - "base64", "image/png")) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - } - - /** - * An embedded attachment test. - */ - function test_Multi_Embedded_Image() { - - $this->Mail->Body = "Embedded Image: \"phpmailer\"" . - "Here is an image!"; - $this->Mail->Subject .= ": Embedded Image + Attachment"; - $this->Mail->IsHTML(true); - - if(!$this->Mail->AddEmbeddedImage("test.png", "my-attach", "test.png", - "base64", "image/png")) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - if(!$this->Mail->AddAttachment("phpmailer_test.php", "test.txt")) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - } - - /** - * Simple multipart/alternative test. - */ - function test_AltBody() { - - $this->Mail->Body = "This is the HTML part of the email."; - $this->Mail->AltBody = "Here is the text body of this message. " . - "It should be quite a few lines. It should be wrapped at the " . - "40 characters. Make sure that it is."; - $this->Mail->WordWrap = 40; - $this->AddNote("This is a mulipart alternative email"); - $this->Mail->Subject .= ": AltBody + Word Wrap"; - - $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - } - - /** - * Simple HTML and attachment test - */ - function test_AltBody_Attachment() { - - $this->Mail->Body = "This is the HTML part of the email."; - $this->Mail->AltBody = "This is the text part of the email."; - $this->Mail->Subject .= ": AltBody + Attachment"; - $this->Mail->IsHTML(true); - - if(!$this->Mail->AddAttachment("phpmailer_test.php", "test_attach.txt")) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - - $fp = fopen("message.txt", "w"); - fwrite($fp, $this->Mail->CreateHeader() . $this->Mail->CreateBody()); - fclose($fp); - } - - function test_MultipleSend() { - $this->Mail->Body = "Sending two messages without keepalive"; - $this->BuildBody(); - $subject = $this->Mail->Subject; - - $this->Mail->Subject = $subject . ": SMTP 1"; - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - - $this->Mail->Subject = $subject . ": SMTP 2"; - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - } - - function test_SmtpKeepAlive() { - $this->Mail->Body = "This was done using the SMTP keep-alive."; - $this->BuildBody(); - $subject = $this->Mail->Subject; - - $this->Mail->SMTPKeepAlive = true; - $this->Mail->Subject = $subject . ": SMTP keep-alive 1"; - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - - $this->Mail->Subject = $subject . ": SMTP keep-alive 2"; - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - $this->Mail->SmtpClose(); - } - - /** - * Tests this denial of service attack: - * http://www.cybsec.com/vuln/PHPMailer-DOS.pdf - */ - function test_DenialOfServiceAttack() { - $this->Mail->Body = "This should no longer cause a denial of service."; - $this->BuildBody(); - - $this->Mail->Subject = str_repeat("A", 998); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - } - - function test_Error() { - $this->Mail->Subject .= ": This should be sent"; - $this->BuildBody(); - $this->Mail->ClearAllRecipients(); // no addresses should cause an error - $this->assert($this->Mail->IsError() == false, "Error found"); - $this->assert($this->Mail->Send() == false, "Send succeeded"); - $this->assert($this->Mail->IsError(), "No error found"); - $this->assertEquals('You must provide at least one ' . - 'recipient email address.', $this->Mail->ErrorInfo); - $this->Mail->AddAddress(get("mail_to")); - $this->assert($this->Mail->Send(), "Send failed"); - } -} - -/** - * Create and run test instance. - */ - -if(isset($HTTP_GET_VARS)) - $global_vars = $HTTP_GET_VARS; -else - $global_vars = $_REQUEST; - -if(isset($global_vars["submitted"])) -{ - echo "Test results:
    "; - $suite = new TestSuite( "phpmailerTest" ); - - $testRunner = new TestRunner; - $testRunner->run($suite); - echo "


    "; -} - -function get($sName) { - global $global_vars; - if(isset($global_vars[$sName])) - return $global_vars[$sName]; - else - return ""; -} - -?> - - - -

    phpmailer Unit Test

    -By entering a SMTP hostname it will automatically perform tests with SMTP. - -
    - -To Address: "/> -
    -Cc Address: "/> -
    -SMTP Hostname: "/> -

    - - -

    - - +TestCase( $name ); + } + + /** + * Run before each test is started. + */ + function setUp() { + global $global_vars; + global $INCLUDE_DIR; + + $this->Mail = new PHPMailer(); + + $this->Mail->Priority = 3; + $this->Mail->Encoding = "8bit"; + $this->Mail->CharSet = "iso-8859-1"; + $this->Mail->From = "unit_test@phpmailer.sf.net"; + $this->Mail->FromName = "Unit Tester"; + $this->Mail->Sender = ""; + $this->Mail->Subject = "Unit Test"; + $this->Mail->Body = ""; + $this->Mail->AltBody = ""; + $this->Mail->WordWrap = 0; + $this->Mail->Host = $global_vars["mail_host"]; + $this->Mail->Port = 25; + $this->Mail->Helo = "localhost.localdomain"; + $this->Mail->SMTPAuth = false; + $this->Mail->Username = ""; + $this->Mail->Password = ""; + $this->Mail->PluginDir = $INCLUDE_DIR; + $this->Mail->AddReplyTo("no_reply@phpmailer.sf.net", "Reply Guy"); + $this->Mail->Sender = "unit_test@phpmailer.sf.net"; + + if(strlen($this->Mail->Host) > 0) + $this->Mail->Mailer = "smtp"; + else + { + $this->Mail->Mailer = "mail"; + $this->Sender = "unit_test@phpmailer.sf.net"; + } + + global $global_vars; + $this->SetAddress($global_vars["mail_to"], "Test User"); + if(strlen($global_vars["mail_cc"]) > 0) + $this->SetAddress($global_vars["mail_cc"], "Carbon User", "cc"); + } + + /** + * Run after each test is completed. + */ + function tearDown() { + // Clean global variables + $this->Mail = NULL; + $this->ChangeLog = array(); + $this->NoteLog = array(); + } + + + /** + * Build the body of the message in the appropriate format. + * @private + * @returns void + */ + function BuildBody() { + $this->CheckChanges(); + + // Determine line endings for message + if($this->Mail->ContentType == "text/html" || strlen($this->Mail->AltBody) > 0) + { + $eol = "
    "; + $bullet = "
  • "; + $bullet_start = "
      "; + $bullet_end = "
    "; + } + else + { + $eol = "\n"; + $bullet = " - "; + $bullet_start = ""; + $bullet_end = ""; + } + + $ReportBody = ""; + + $ReportBody .= "---------------------" . $eol; + $ReportBody .= "Unit Test Information" . $eol; + $ReportBody .= "---------------------" . $eol; + $ReportBody .= "phpmailer version: " . $this->Mail->Version . $eol; + $ReportBody .= "Content Type: " . $this->Mail->ContentType . $eol; + + if(strlen($this->Mail->Host) > 0) + $ReportBody .= "Host: " . $this->Mail->Host . $eol; + + // If attachments then create an attachment list + if(count($this->Mail->attachment) > 0) + { + $ReportBody .= "Attachments:" . $eol; + $ReportBody .= $bullet_start; + for($i = 0; $i < count($this->Mail->attachment); $i++) + { + $ReportBody .= $bullet . "Name: " . $this->Mail->attachment[$i][1] . ", "; + $ReportBody .= "Encoding: " . $this->Mail->attachment[$i][3] . ", "; + $ReportBody .= "Type: " . $this->Mail->attachment[$i][4] . $eol; + } + $ReportBody .= $bullet_end . $eol; + } + + // If there are changes then list them + if(count($this->ChangeLog) > 0) + { + $ReportBody .= "Changes" . $eol; + $ReportBody .= "-------" . $eol; + + $ReportBody .= $bullet_start; + for($i = 0; $i < count($this->ChangeLog); $i++) + { + $ReportBody .= $bullet . $this->ChangeLog[$i][0] . " was changed to [" . + $this->ChangeLog[$i][1] . "]" . $eol; + } + $ReportBody .= $bullet_end . $eol . $eol; + } + + // If there are notes then list them + if(count($this->NoteLog) > 0) + { + $ReportBody .= "Notes" . $eol; + $ReportBody .= "-----" . $eol; + + $ReportBody .= $bullet_start; + for($i = 0; $i < count($this->NoteLog); $i++) + { + $ReportBody .= $bullet . $this->NoteLog[$i] . $eol; + } + $ReportBody .= $bullet_end; + } + + // Re-attach the original body + $this->Mail->Body .= $eol . $eol . $ReportBody; + } + + /** + * Check which default settings have been changed for the report. + * @private + * @returns void + */ + function CheckChanges() { + if($this->Mail->Priority != 3) + $this->AddChange("Priority", $this->Mail->Priority); + if($this->Mail->Encoding != "8bit") + $this->AddChange("Encoding", $this->Mail->Encoding); + if($this->Mail->CharSet != "iso-8859-1") + $this->AddChange("CharSet", $this->Mail->CharSet); + if($this->Mail->Sender != "") + $this->AddChange("Sender", $this->Mail->Sender); + if($this->Mail->WordWrap != 0) + $this->AddChange("WordWrap", $this->Mail->WordWrap); + if($this->Mail->Mailer != "mail") + $this->AddChange("Mailer", $this->Mail->Mailer); + if($this->Mail->Port != 25) + $this->AddChange("Port", $this->Mail->Port); + if($this->Mail->Helo != "localhost.localdomain") + $this->AddChange("Helo", $this->Mail->Helo); + if($this->Mail->SMTPAuth) + $this->AddChange("SMTPAuth", "true"); + } + + /** + * Adds a change entry. + * @private + * @returns void + */ + function AddChange($sName, $sNewValue) { + $cur = count($this->ChangeLog); + $this->ChangeLog[$cur][0] = $sName; + $this->ChangeLog[$cur][1] = $sNewValue; + } + + /** + * Adds a simple note to the message. + * @public + * @returns void + */ + function AddNote($sValue) { + $this->NoteLog[] = $sValue; + } + + /** + * Adds all of the addresses + * @public + * @returns void + */ + function SetAddress($sAddress, $sName = "", $sType = "to") { + switch($sType) + { + case "to": + $this->Mail->AddAddress($sAddress, $sName); + break; + case "cc": + $this->Mail->AddCC($sAddress, $sName); + break; + case "bcc": + $this->Mail->AddBCC($sAddress, $sName); + break; + } + } + + ///////////////////////////////////////////////// + // UNIT TESTS + ///////////////////////////////////////////////// + + /** + * Try a plain message. + */ + function test_WordWrap() { + + $this->Mail->WordWrap = 40; + $my_body = "Here is the main body of this message. It should " . + "be quite a few lines. It should be wrapped at the " . + "40 characters. Make sure that it is."; + $nBodyLen = strlen($my_body); + $my_body .= "\n\nThis is the above body length: " . $nBodyLen; + + $this->Mail->Body = $my_body; + $this->Mail->Subject .= ": Wordwrap"; + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * Try a plain message. + */ + function test_Low_Priority() { + + $this->Mail->Priority = 5; + $this->Mail->Body = "Here is the main body. There should be " . + "a reply to address in this message."; + $this->Mail->Subject .= ": Low Priority"; + $this->Mail->AddReplyTo("nobody@nobody.com", "Nobody (Unit Test)"); + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * Simple plain file attachment test. + */ + function test_Multiple_Plain_FileAttachment() { + + $this->Mail->Body = "Here is the text body"; + $this->Mail->Subject .= ": Plain + Multiple FileAttachments"; + + if(!$this->Mail->AddAttachment("test.png")) + { + $this->assert(false, $this->Mail->ErrorInfo); + return; + } + + if(!$this->Mail->AddAttachment("phpmailer_test.php", "test.txt")) + { + $this->assert(false, $this->Mail->ErrorInfo); + return; + } + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * Simple plain string attachment test. + */ + function test_Plain_StringAttachment() { + + $this->Mail->Body = "Here is the text body"; + $this->Mail->Subject .= ": Plain + StringAttachment"; + + $sAttachment = "These characters are the content of the " . + "string attachment.\nThis might be taken from a ". + "database or some other such thing. "; + + $this->Mail->AddStringAttachment($sAttachment, "string_attach.txt"); + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * Plain quoted-printable message. + */ + function test_Quoted_Printable() { + + $this->Mail->Body = "Here is the main body"; + $this->Mail->Subject .= ": Plain + Quoted-printable"; + $this->Mail->Encoding = "quoted-printable"; + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * Try a plain message. + */ + function test_Html() { + + $this->Mail->IsHTML(true); + $this->Mail->Subject .= ": HTML only"; + + $this->Mail->Body = "This is a test message written in HTML.
    " . + "Go to " . + "http://phpmailer.sourceforge.net/ for new versions of " . + "phpmailer.

    Thank you!"; + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * Simple HTML and attachment test + */ + function test_HTML_Attachment() { + + $this->Mail->Body = "This is the HTML part of the email."; + $this->Mail->Subject .= ": HTML + Attachment"; + $this->Mail->IsHTML(true); + + if(!$this->Mail->AddAttachment("phpmailer_test.php", "test_attach.txt")) + { + $this->assert(false, $this->Mail->ErrorInfo); + return; + } + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * An embedded attachment test. + */ + function test_Embedded_Image() { + + $this->Mail->Body = "Embedded Image: \"phpmailer\"" . + "Here is an image!"; + $this->Mail->Subject .= ": Embedded Image"; + $this->Mail->IsHTML(true); + + if(!$this->Mail->AddEmbeddedImage("test.png", "my-attach", "test.png", + "base64", "image/png")) + { + $this->assert(false, $this->Mail->ErrorInfo); + return; + } + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * An embedded attachment test. + */ + function test_Multi_Embedded_Image() { + + $this->Mail->Body = "Embedded Image: \"phpmailer\"" . + "Here is an image!"; + $this->Mail->Subject .= ": Embedded Image + Attachment"; + $this->Mail->IsHTML(true); + + if(!$this->Mail->AddEmbeddedImage("test.png", "my-attach", "test.png", + "base64", "image/png")) + { + $this->assert(false, $this->Mail->ErrorInfo); + return; + } + + if(!$this->Mail->AddAttachment("phpmailer_test.php", "test.txt")) + { + $this->assert(false, $this->Mail->ErrorInfo); + return; + } + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * Simple multipart/alternative test. + */ + function test_AltBody() { + + $this->Mail->Body = "This is the HTML part of the email."; + $this->Mail->AltBody = "Here is the text body of this message. " . + "It should be quite a few lines. It should be wrapped at the " . + "40 characters. Make sure that it is."; + $this->Mail->WordWrap = 40; + $this->AddNote("This is a mulipart alternative email"); + $this->Mail->Subject .= ": AltBody + Word Wrap"; + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * Simple HTML and attachment test + */ + function test_AltBody_Attachment() { + + $this->Mail->Body = "This is the HTML part of the email."; + $this->Mail->AltBody = "This is the text part of the email."; + $this->Mail->Subject .= ": AltBody + Attachment"; + $this->Mail->IsHTML(true); + + if(!$this->Mail->AddAttachment("phpmailer_test.php", "test_attach.txt")) + { + $this->assert(false, $this->Mail->ErrorInfo); + return; + } + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + + $fp = fopen("message.txt", "w"); + fwrite($fp, $this->Mail->CreateHeader() . $this->Mail->CreateBody()); + fclose($fp); + } + + function test_MultipleSend() { + $this->Mail->Body = "Sending two messages without keepalive"; + $this->BuildBody(); + $subject = $this->Mail->Subject; + + $this->Mail->Subject = $subject . ": SMTP 1"; + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + + $this->Mail->Subject = $subject . ": SMTP 2"; + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + function test_SmtpKeepAlive() { + $this->Mail->Body = "This was done using the SMTP keep-alive."; + $this->BuildBody(); + $subject = $this->Mail->Subject; + + $this->Mail->SMTPKeepAlive = true; + $this->Mail->Subject = $subject . ": SMTP keep-alive 1"; + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + + $this->Mail->Subject = $subject . ": SMTP keep-alive 2"; + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + $this->Mail->SmtpClose(); + } + + /** + * Tests this denial of service attack: + * http://www.cybsec.com/vuln/PHPMailer-DOS.pdf + */ + function test_DenialOfServiceAttack() { + $this->Mail->Body = "This should no longer cause a denial of service."; + $this->BuildBody(); + + $this->Mail->Subject = str_repeat("A", 998); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + function test_Error() { + $this->Mail->Subject .= ": This should be sent"; + $this->BuildBody(); + $this->Mail->ClearAllRecipients(); // no addresses should cause an error + $this->assert($this->Mail->IsError() == false, "Error found"); + $this->assert($this->Mail->Send() == false, "Send succeeded"); + $this->assert($this->Mail->IsError(), "No error found"); + $this->assertEquals('You must provide at least one ' . + 'recipient email address.', $this->Mail->ErrorInfo); + $this->Mail->AddAddress(get("mail_to")); + $this->assert($this->Mail->Send(), "Send failed"); + } +} + +/** + * Create and run test instance. + */ + +if(isset($HTTP_GET_VARS)) + $global_vars = $HTTP_GET_VARS; +else + $global_vars = $_REQUEST; + +if(isset($global_vars["submitted"])) +{ + echo "Test results:
    "; + $suite = new TestSuite( "phpmailerTest" ); + + $testRunner = new TestRunner; + $testRunner->run($suite); + echo "


    "; +} + +function get($sName) { + global $global_vars; + if(isset($global_vars[$sName])) + return $global_vars[$sName]; + else + return ""; +} + +?> + + + +

    phpmailer Unit Test

    +By entering a SMTP hostname it will automatically perform tests with SMTP. + +
    + +To Address: "/> +
    +Cc Address: "/> +
    +SMTP Hostname: "/> +

    + + +

    + + diff --git a/inc/phpmailer/test/phpunit.php b/inc/phpmailer/test/phpunit.php index 33447690cb..1d508680cc 100644 --- a/inc/phpmailer/test/phpunit.php +++ b/inc/phpmailer/test/phpunit.php @@ -1,376 +1,376 @@ - -// OntoSys, Inc -// -// $Id: phpunit.php,v 1.1 2002/03/30 19:32:17 bmatzelle Exp $ - -// Copyright (c) 2000 Fred Yankowski - -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, copy, -// modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -// BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -// -error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE | - E_CORE_ERROR | E_CORE_WARNING); - -/* -interface Test { - function run(&$aTestResult); - function countTestCases(); -} -*/ - -function trace($msg) { - return; - print($msg); - flush(); -} - - -class Exception { - /* Emulate a Java exception, sort of... */ - var $message; - function Exception($message) { - $this->message = $message; - } - function getMessage() { - return $this->message; - } -} - -class Assert { - function assert($boolean, $message=0) { - if (! $boolean) - $this->fail($message); - } - - function assertEquals($expected, $actual, $message=0) { - if ($expected != $actual) { - $this->failNotEquals($expected, $actual, "expected", $message); - } - } - - function assertRegexp($regexp, $actual, $message=false) { - if (! preg_match($regexp, $actual)) { - $this->failNotEquals($regexp, $actual, "pattern", $message); - } - } - - function failNotEquals($expected, $actual, $expected_label, $message=0) { - // Private function for reporting failure to match. - $str = $message ? ($message . ' ') : ""; - $str .= "($expected_label/actual)
    "; - $htmlExpected = htmlspecialchars($expected); - $htmlActual = htmlspecialchars($actual); - $str .= sprintf("
    %s\n--------\n%s
    ", - $htmlExpected, $htmlActual); - $this->fail($str); - } -} - -class TestCase extends Assert /* implements Test */ { - /* Defines context for running tests. Specific context -- such as - instance variables, global variables, global state -- is defined - by creating a subclass that specializes the setUp() and - tearDown() methods. A specific test is defined by a subclass - that specializes the runTest() method. */ - var $fName; - var $fResult; - var $fExceptions = array(); - - function TestCase($name) { - $this->fName = $name; - } - - function run($testResult=0) { - /* Run this single test, by calling the run() method of the - TestResult object which will in turn call the runBare() method - of this object. That complication allows the TestResult object - to do various kinds of progress reporting as it invokes each - test. Create/obtain a TestResult object if none was passed in. - Note that if a TestResult object was passed in, it must be by - reference. */ - if (! $testResult) - $testResult = $this->_createResult(); - $this->fResult = $testResult; - $testResult->run(&$this); - $this->fResult = 0; - return $testResult; - } - - function countTestCases() { - return 1; - } - - function runTest() { - $name = $this->name(); - // Since isset($this->$name) is false, no way to run defensive checks - $this->$name(); - } - - function setUp() /* expect override */ { - //print("TestCase::setUp()
    \n"); - } - - function tearDown() /* possible override */ { - //print("TestCase::tearDown()
    \n"); - } - - //////////////////////////////////////////////////////////////// - - - function _createResult() /* protected */ { - /* override this to use specialized subclass of TestResult */ - return new TestResult; - } - - function fail($message=0) { - //printf("TestCase::fail(%s)
    \n", ($message) ? $message : ""); - /* JUnit throws AssertionFailedError here. We just record the - failure and carry on */ - $this->fExceptions[] = new Exception(&$message); - } - - function error($message) { - /* report error that requires correction in the test script - itself, or (heaven forbid) in this testing infrastructure */ - printf('ERROR: ' . $message . '
    '); - $this->fResult->stop(); - } - - function failed() { - return count($this->fExceptions); - } - - function getExceptions() { - return $this->fExceptions; - } - - function name() { - return $this->fName; - } - - function runBare() { - $this->setup(); - $this->runTest(); - $this->tearDown(); - } -} - - -class TestSuite /* implements Test */ { - /* Compose a set of Tests (instances of TestCase or TestSuite), and - run them all. */ - var $fTests = array(); - - function TestSuite($classname=false) { - if ($classname) { - // Find all methods of the given class whose name starts with - // "test" and add them to the test suite. We are just _barely_ - // able to do this with PHP's limited introspection... Note - // that PHP seems to store method names in lower case, and we - // have to avoid the constructor function for the TestCase class - // superclass. This will fail when $classname starts with - // "Test" since that will have a constructor method that will - // get matched below and then treated (incorrectly) as a test - // method. So don't name any TestCase subclasses as "Test..."! - if (floor(phpversion()) >= 4) { - // PHP4 introspection, submitted by Dylan Kuhn - $names = get_class_methods($classname); - while (list($key, $method) = each($names)) { - if (preg_match('/^test/', $method) && $method != "testcase") { - $this->addTest(new $classname($method)); - } - } - } - else { - $dummy = new $classname("dummy"); - $names = (array) $dummy; - while (list($key, $value) = each($names)) { - $type = gettype($value); - if ($type == "user function" && preg_match('/^test/', $key) - && $key != "testcase") { - $this->addTest(new $classname($key)); - } - } - } - } - } - - function addTest($test) { - /* Add TestCase or TestSuite to this TestSuite */ - $this->fTests[] = $test; - } - - function run(&$testResult) { - /* Run all TestCases and TestSuites comprising this TestSuite, - accumulating results in the given TestResult object. */ - reset($this->fTests); - while (list($na, $test) = each($this->fTests)) { - if ($testResult->shouldStop()) - break; - $test->run(&$testResult); - } - } - - function countTestCases() { - /* Number of TestCases comprising this TestSuite (including those - in any constituent TestSuites) */ - $count = 0; - reset($fTests); - while (list($na, $test_case) = each($this->fTests)) { - $count += $test_case->countTestCases(); - } - return $count; - } -} - - -class TestFailure { - /* Record failure of a single TestCase, associating it with the - exception(s) that occurred */ - var $fFailedTestName; - var $fExceptions; - - function TestFailure(&$test, &$exceptions) { - $this->fFailedTestName = $test->name(); - $this->fExceptions = $exceptions; - } - - function getExceptions() { - return $this->fExceptions; - } - function getTestName() { - return $this->fFailedTestName; - } -} - - -class TestResult { - /* Collect the results of running a set of TestCases. */ - var $fFailures = array(); - var $fRunTests = 0; - var $fStop = false; - - function TestResult() { } - - function _endTest($test) /* protected */ { - /* specialize this for end-of-test action, such as progress - reports */ - } - - function getFailures() { - return $this->fFailures; - } - - function run($test) { - /* Run a single TestCase in the context of this TestResult */ - $this->_startTest($test); - $this->fRunTests++; - - $test->runBare(); - - /* this is where JUnit would catch AssertionFailedError */ - $exceptions = $test->getExceptions(); - if ($exceptions) - $this->fFailures[] = new TestFailure(&$test, &$exceptions); - $this->_endTest($test); - } - - function countTests() { - return $this->fRunTests; - } - - function shouldStop() { - return $this->fStop; - } - - function _startTest($test) /* protected */ { - /* specialize this for start-of-test actions */ - } - - function stop() { - /* set indication that the test sequence should halt */ - $fStop = true; - } - - function countFailures() { - return count($this->fFailures); - } -} - - -class TextTestResult extends TestResult { - /* Specialize TestResult to produce text/html report */ - function TextTestResult() { - $this->TestResult(); // call superclass constructor - } - - function report() { - /* report result of test run */ - $nRun = $this->countTests(); - $nFailures = $this->countFailures(); - printf("

    %s test%s run
    ", $nRun, ($nRun == 1) ? "" : 's'); - printf("%s failure%s.
    \n", $nFailures, ($nFailures == 1) ? "" : 's'); - if ($nFailures == 0) - return; - - print("

      \n"); - $failures = $this->getFailures(); - while (list($i, $failure) = each($failures)) { - $failedTestName = $failure->getTestName(); - printf("
    1. %s\n", $failedTestName); - - $exceptions = $failure->getExceptions(); - print("
        "); - while (list($na, $exception) = each($exceptions)) - printf("
      • %s\n", $exception->getMessage()); - print("
      "); - } - print("
    \n"); - } - - function _startTest($test) { - printf("%s ", $test->name()); - flush(); - } - - function _endTest($test) { - $outcome = $test->failed() - ? "FAIL" - : "ok"; - printf("$outcome
    \n"); - flush(); - } -} - - -class TestRunner { - /* Run a suite of tests and report results. */ - function run($suite) { - $result = new TextTestResult; - $suite->run($result); - $result->report(); - } -} - -?> + +// OntoSys, Inc +// +// $Id: phpunit.php,v 1.1 2002/03/30 19:32:17 bmatzelle Exp $ + +// Copyright (c) 2000 Fred Yankowski + +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, copy, +// modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +// BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// +error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE | + E_CORE_ERROR | E_CORE_WARNING); + +/* +interface Test { + function run(&$aTestResult); + function countTestCases(); +} +*/ + +function trace($msg) { + return; + print($msg); + flush(); +} + + +class Exception { + /* Emulate a Java exception, sort of... */ + var $message; + function Exception($message) { + $this->message = $message; + } + function getMessage() { + return $this->message; + } +} + +class Assert { + function assert($boolean, $message=0) { + if (! $boolean) + $this->fail($message); + } + + function assertEquals($expected, $actual, $message=0) { + if ($expected != $actual) { + $this->failNotEquals($expected, $actual, "expected", $message); + } + } + + function assertRegexp($regexp, $actual, $message=false) { + if (! preg_match($regexp, $actual)) { + $this->failNotEquals($regexp, $actual, "pattern", $message); + } + } + + function failNotEquals($expected, $actual, $expected_label, $message=0) { + // Private function for reporting failure to match. + $str = $message ? ($message . ' ') : ''; + $str .= "($expected_label/actual)
    "; + $htmlExpected = htmlspecialchars($expected); + $htmlActual = htmlspecialchars($actual); + $str .= sprintf("
    %s\n--------\n%s
    ", + $htmlExpected, $htmlActual); + $this->fail($str); + } +} + +class TestCase extends Assert /* implements Test */ { + /* Defines context for running tests. Specific context -- such as + instance variables, global variables, global state -- is defined + by creating a subclass that specializes the setUp() and + tearDown() methods. A specific test is defined by a subclass + that specializes the runTest() method. */ + var $fName; + var $fResult; + var $fExceptions = array(); + + function TestCase($name) { + $this->fName = $name; + } + + function run($testResult=0) { + /* Run this single test, by calling the run() method of the + TestResult object which will in turn call the runBare() method + of this object. That complication allows the TestResult object + to do various kinds of progress reporting as it invokes each + test. Create/obtain a TestResult object if none was passed in. + Note that if a TestResult object was passed in, it must be by + reference. */ + if (! $testResult) + $testResult = $this->_createResult(); + $this->fResult = $testResult; + $testResult->run(&$this); + $this->fResult = 0; + return $testResult; + } + + function countTestCases() { + return 1; + } + + function runTest() { + $name = $this->name(); + // Since isset($this->$name) is false, no way to run defensive checks + $this->$name(); + } + + function setUp() /* expect override */ { + //print("TestCase::setUp()
    \n"); + } + + function tearDown() /* possible override */ { + //print("TestCase::tearDown()
    \n"); + } + + //////////////////////////////////////////////////////////////// + + + function _createResult() /* protected */ { + /* override this to use specialized subclass of TestResult */ + return new TestResult; + } + + function fail($message=0) { + //printf("TestCase::fail(%s)
    \n", ($message) ? $message : ''); + /* JUnit throws AssertionFailedError here. We just record the + failure and carry on */ + $this->fExceptions[] = new Exception(&$message); + } + + function error($message) { + /* report error that requires correction in the test script + itself, or (heaven forbid) in this testing infrastructure */ + printf('ERROR: ' . $message . '
    '); + $this->fResult->stop(); + } + + function failed() { + return count($this->fExceptions); + } + + function getExceptions() { + return $this->fExceptions; + } + + function name() { + return $this->fName; + } + + function runBare() { + $this->setup(); + $this->runTest(); + $this->tearDown(); + } +} + + +class TestSuite /* implements Test */ { + /* Compose a set of Tests (instances of TestCase or TestSuite), and + run them all. */ + var $fTests = array(); + + function TestSuite($classname=false) { + if ($classname) { + // Find all methods of the given class whose name starts with + // "test" and add them to the test suite. We are just _barely_ + // able to do this with PHP's limited introspection... Note + // that PHP seems to store method names in lower case, and we + // have to avoid the constructor function for the TestCase class + // superclass. This will fail when $classname starts with + // "Test" since that will have a constructor method that will + // get matched below and then treated (incorrectly) as a test + // method. So don't name any TestCase subclasses as "Test..."! + if (floor(phpversion()) >= 4) { + // PHP4 introspection, submitted by Dylan Kuhn + $names = get_class_methods($classname); + while (list($key, $method) = each($names)) { + if (preg_match('/^test/', $method) && $method != "testcase") { + $this->addTest(new $classname($method)); + } + } + } + else { + $dummy = new $classname("dummy"); + $names = (array) $dummy; + while (list($key, $value) = each($names)) { + $type = gettype($value); + if ($type == "user function" && preg_match('/^test/', $key) + && $key != "testcase") { + $this->addTest(new $classname($key)); + } + } + } + } + } + + function addTest($test) { + /* Add TestCase or TestSuite to this TestSuite */ + $this->fTests[] = $test; + } + + function run(&$testResult) { + /* Run all TestCases and TestSuites comprising this TestSuite, + accumulating results in the given TestResult object. */ + reset($this->fTests); + while (list($na, $test) = each($this->fTests)) { + if ($testResult->shouldStop()) + break; + $test->run(&$testResult); + } + } + + function countTestCases() { + /* Number of TestCases comprising this TestSuite (including those + in any constituent TestSuites) */ + $count = 0; + reset($fTests); + while (list($na, $test_case) = each($this->fTests)) { + $count += $test_case->countTestCases(); + } + return $count; + } +} + + +class TestFailure { + /* Record failure of a single TestCase, associating it with the + exception(s) that occurred */ + var $fFailedTestName; + var $fExceptions; + + function TestFailure(&$test, &$exceptions) { + $this->fFailedTestName = $test->name(); + $this->fExceptions = $exceptions; + } + + function getExceptions() { + return $this->fExceptions; + } + function getTestName() { + return $this->fFailedTestName; + } +} + + +class TestResult { + /* Collect the results of running a set of TestCases. */ + var $fFailures = array(); + var $fRunTests = 0; + var $fStop = false; + + function TestResult() { } + + function _endTest($test) /* protected */ { + /* specialize this for end-of-test action, such as progress + reports */ + } + + function getFailures() { + return $this->fFailures; + } + + function run($test) { + /* Run a single TestCase in the context of this TestResult */ + $this->_startTest($test); + $this->fRunTests++; + + $test->runBare(); + + /* this is where JUnit would catch AssertionFailedError */ + $exceptions = $test->getExceptions(); + if ($exceptions) + $this->fFailures[] = new TestFailure(&$test, &$exceptions); + $this->_endTest($test); + } + + function countTests() { + return $this->fRunTests; + } + + function shouldStop() { + return $this->fStop; + } + + function _startTest($test) /* protected */ { + /* specialize this for start-of-test actions */ + } + + function stop() { + /* set indication that the test sequence should halt */ + $fStop = true; + } + + function countFailures() { + return count($this->fFailures); + } +} + + +class TextTestResult extends TestResult { + /* Specialize TestResult to produce text/html report */ + function TextTestResult() { + $this->TestResult(); // call superclass constructor + } + + function report() { + /* report result of test run */ + $nRun = $this->countTests(); + $nFailures = $this->countFailures(); + printf("

    %s test%s run
    ", $nRun, ($nRun == 1) ? '' : 's'); + printf("%s failure%s.
    \n", $nFailures, ($nFailures == 1) ? '' : 's'); + if ($nFailures == 0) + return; + + print("

      \n"); + $failures = $this->getFailures(); + while (list($i, $failure) = each($failures)) { + $failedTestName = $failure->getTestName(); + printf("
    1. %s\n", $failedTestName); + + $exceptions = $failure->getExceptions(); + print("
        "); + while (list($na, $exception) = each($exceptions)) + printf("
      • %s\n", $exception->getMessage()); + print("
      "); + } + print("
    \n"); + } + + function _startTest($test) { + printf("%s ", $test->name()); + flush(); + } + + function _endTest($test) { + $outcome = $test->failed() + ? "FAIL" + : "ok"; + printf("$outcome
    \n"); + flush(); + } +} + + +class TestRunner { + /* Run a suite of tests and report results. */ + function run($suite) { + $result = new TextTestResult; + $suite->run($result); + $result->report(); + } +} + +?>