From 8d4fc6d507a5b640059bac757dc3f6966e46e3ca Mon Sep 17 00:00:00 2001
From: Marcus Bointon PHPMailer is the world's leading email transport class and downloaded an
+average of more than 26,000 each month. In March 2009, PHPMailer was downloaded
+more than 31,000 times -- that's an average of 1,000 downloads daily. Our thanks
+to our new users and loyal users. We understand you have many choices available
+to select from and we thank you for select our fast and stable tool for your
+website and projects. Credits: PHPMailer is used in many projects ranging from Open Source to commercial
+packages. Our LGPL licensing terms are very flexible and allow for including
+PHPMailer to enhance projects of all types. If you discover PHPMailer being used
+in a project, please let us know about it. 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, here's our team: www.codeworxtech.com for more information. 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: We're committed to PHP and to the Open Source community. Opportunities with Worx International Inc.: Marcus is the technical director of Synchromedia Limited, a UK-based company providing online business services. Synchromedia's main services are: In addition to our headline services, we also provide consulting, development, hosting and sysadmin services, so if you just need a simple web hosting package, we can do that too. Not surprisingly, we know rather a lot about email, so you can talk to us about that too. Please contact us if you'd like to know more. Marcus is a regular attendee at PHP London, and occasionally speaks on email at technical conferences. My name is Andy Prevost, AKA "codeworxtech". 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: We're committed to PHP and to the Open Source community. Opportunities with Worx International Inc.:
+The http://phpmailer.codeworxtech.com/ website now carries a few
+advertisements through the Google Adsense network to help offset
+some of our costs.
+Thanks ....
+
+
+PHPMailer's original founder is Brent Matzelle. The current team is:
+Project Administrator: Andy Prevost (codeworxtech),
+
+codeworxtech@users.sourceforge.net
+Author: Andy Prevost (codeworxtech) codeworxtech@users.sourceforge.net
+Author: Marcus Bointon (coolbru)
+coolbru@users.sourceforge.net
+
+
+
+ About Andy Prevost, AKA "codeworxtech".
+ About Marcus Bointon, AKA "coolbru".
+
+
+
+
+
+ Web design, web applications, forms: WorxStudio.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. If you are interested, let us know.
+
+
+
+
+
+
+
+ Regards,
+ A few things to note:
+
+
+ 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.
+
+
+ Smartmessages.net
+ ![]()
Smartmessages.net is Synchromedia's large-scale mailing list management system, providing email delivery services for a wide range of businesses, from sole traders to corporates.
+ We pride ourselves on personal service, and realise that every one of your subscribers is a precious asset to be handled with care.
+ We provide fast, reliable, high-volume delivery (some of our customers have lists of more than 1,000,000 subscribers) with fine-grained tracking while ensuring you stay fully compliant with UK, EC and US data protection laws. Smartmessages of course uses PHPMailer at its heart!info@hand
+ ![]()
Synchromedia is the official UK distributor of info@hand, a class-leading open-source web-based CRM system. We provide licenses, hosting, planning, support and training for this very fully-featured system at very competitive prices. info@hand also uses PHPMailer!How can we help you?
+
\n";
+ return $errorMsg;
+ }
+}
?>
\ No newline at end of file
diff --git a/class.pop3.php b/class.pop3.php
index 31c26ecd..021a068f 100644
--- a/class.pop3.php
+++ b/class.pop3.php
@@ -2,14 +2,16 @@
/*~ class.pop3.php
.---------------------------------------------------------------------------.
| Software: PHPMailer - PHP email class |
-| Version: 2.3 |
+| Version: 5.0.0 |
| Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
| Info: http://phpmailer.sourceforge.net |
| Support: http://sourceforge.net/projects/phpmailer/ |
| ------------------------------------------------------------------------- |
-| Author: Andy Prevost (project admininistrator) |
-| Author: Brent R. Matzelle (original founder) |
-| Copyright (c) 2004-2007, Andy Prevost. All Rights Reserved. |
+| Admin: Andy Prevost (project admininistrator) |
+| Authors: Andy Prevost (codeworxtech) codeworxtech@users.sourceforge.net |
+| : Marcus Bointon (coolbru) coolbru@users.sourceforge.net |
+| Founder: Brent R. Matzelle (original founder) |
+| Copyright (c) 2004-2009, Andy Prevost. All Rights Reserved. |
| Copyright (c) 2001-2003, Brent R. Matzelle |
| ------------------------------------------------------------------------- |
| License: Distributed under the Lesser General Public License (LGPL) |
@@ -30,24 +32,25 @@
* NOTE: Designed for use with PHP version 5 and up
* @package PHPMailer
* @author Andy Prevost
- * @copyright 2004 - 2008 Andy Prevost
+ * @author Marcus Bointon
+ * @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html Distributed under the Lesser General Public License (LGPL)
* @version $Id$
*/
/**
* POP Before SMTP Authentication Class
- * Version 2.3
+ * Version 5.0.0
*
* Author: Richard Davey (rich@corephp.co.uk)
* Modifications: Andy Prevost
* License: LGPL, see PHPMailer License
*
* Specifically for PHPMailer to allow POP before SMTP authentication.
- * Does not yet work with APOP - if you have an APOP account, contact me
+ * Does not yet work with APOP - if you have an APOP account, contact Richard Davey
* and we can test changes to this script.
*
- * This class is based on the structure of the SMTP class by Chris Ryan
+ * This class is based on the structure of the SMTP class originally authored by Chris Ryan
*
* This class is rfc 1939 compliant and implements all the commands
* required for POP3 connection, authentication and disconnection.
@@ -111,13 +114,13 @@ class POP3 {
*/
public $password;
- /**#@+
- * @access private
- */
+ /////////////////////////////////////////////////
+ // PROPERTIES, PRIVATE AND PROTECTED
+ /////////////////////////////////////////////////
+
private $pop_conn;
private $connected;
private $error; // Error log array
- /**#@-*/
/**
* Constructor, sets the initial values
diff --git a/class.smtp.php b/class.smtp.php
index a6e10ae3..f2bb4bdd 100644
--- a/class.smtp.php
+++ b/class.smtp.php
@@ -2,14 +2,16 @@
/*~ class.smtp.php
.---------------------------------------------------------------------------.
| Software: PHPMailer - PHP email class |
-| Version: 2.3 |
+| Version: 5.0.0 |
| Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
| Info: http://phpmailer.sourceforge.net |
| Support: http://sourceforge.net/projects/phpmailer/ |
| ------------------------------------------------------------------------- |
-| Author: Andy Prevost (project admininistrator) |
-| Author: Brent R. Matzelle (original founder) |
-| Copyright (c) 2004-2007, Andy Prevost. All Rights Reserved. |
+| Admin: Andy Prevost (project admininistrator) |
+| Authors: Andy Prevost (codeworxtech) codeworxtech@users.sourceforge.net |
+| : Marcus Bointon (coolbru) coolbru@users.sourceforge.net |
+| Founder: Brent R. Matzelle (original founder) |
+| Copyright (c) 2004-2009, Andy Prevost. All Rights Reserved. |
| Copyright (c) 2001-2003, Brent R. Matzelle |
| ------------------------------------------------------------------------- |
| License: Distributed under the Lesser General Public License (LGPL) |
@@ -30,6 +32,7 @@
* NOTE: Designed for use with PHP version 5 and up
* @package PHPMailer
* @author Andy Prevost
+ * @author Marcus Bointon
* @copyright 2004 - 2008 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html Distributed under the Lesser General Public License (LGPL)
* @version $Id$
@@ -40,8 +43,7 @@
* commands except TURN which will always return a not implemented
* error. SMTP also provides some utility methods for sending mail
* to an SMTP server.
- * @package PHPMailer
- * @author Chris Ryan
+ * original author: Chris Ryan
*/
class SMTP {
@@ -69,13 +71,13 @@ class SMTP {
*/
public $do_verp = false;
- /**#@+
- * @access private
- */
- private $smtp_conn; // the socket to the server
- private $error; // error if any on the last call
- private $helo_rply; // the reply the server sent to us for HELO
- /**#@-*/
+ /////////////////////////////////////////////////
+ // PROPERTIES, PRIVATE AND PROTECTED
+ /////////////////////////////////////////////////
+
+ private $smtp_conn; // the socket to the server
+ private $error; // error if any on the last call
+ private $helo_rply; // the reply the server sent to us for HELO
/**
* Initialize the class so that the data is in a known state.
@@ -90,9 +92,9 @@ class SMTP {
$this->do_debug = 0;
}
- /*************************************************************
- * CONNECTION FUNCTIONS *
- ***********************************************************/
+ /////////////////////////////////////////////////
+ // CONNECTION FUNCTIONS
+ /////////////////////////////////////////////////
/**
* Connect to the server specified on the port specified.
@@ -108,15 +110,12 @@ class SMTP {
* @return bool
*/
public function Connect($host, $port = 0, $tval = 30) {
- /* set the error val to null so there is no confusion */
+ // set the error val to null so there is no confusion
$this->error = null;
- /* make sure we are __not__ connected */
+ // make sure we are __not__ connected
if($this->connected()) {
- /* ok we are connected! what should we do?
- * for now we will just give an error saying we
- * are already connected
- */
+ // already connected, generate error
$this->error = array("error" => "Already connected to a server");
return false;
}
@@ -125,40 +124,33 @@ class SMTP {
$port = $this->SMTP_PORT;
}
- /* connect to the smtp server */
- $this->smtp_conn = fsockopen($host, // the host of the server
+ // connect to the smtp server
+ $this->smtp_conn = @fsockopen($host, // the host of the server
$port, // the port to use
$errno, // error number if any
$errstr, // error message if any
$tval); // give up after ? secs
- /* verify we connected properly */
+ // verify we connected properly
if(empty($this->smtp_conn)) {
$this->error = array("error" => "Failed to connect to server",
"errno" => $errno,
"errstr" => $errstr);
if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": $errstr ($errno)" . $this->CRLF;
+ echo "SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '
';
}
return false;
}
- /* sometimes the SMTP server takes a little longer to respond
- * so we will give it a longer timeout for the first read
- * - Windows still does not have support for this timeout function
- */
+ // SMTP server can take longer to respond, give longer timeout for first read
+ // Windows does not have support for this timeout function
if(substr(PHP_OS, 0, 3) != "WIN")
socket_set_timeout($this->smtp_conn, $tval, 0);
- /* get any announcement stuff */
+ // get any announcement
$announce = $this->get_lines();
- /* set the timeout of any socket functions at 1/10 of a second */
- //if(function_exists("socket_set_timeout"))
- // socket_set_timeout($this->smtp_conn, 0, 100000);
-
if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce;
+ echo "SMTP -> FROM SERVER:" . $announce . $this->CRLF . '
';
}
return true;
@@ -187,7 +179,7 @@ class SMTP {
$code = substr($rply,0,3);
if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
';
}
if($code != 220) {
@@ -196,12 +188,12 @@ class SMTP {
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF;
+ echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
';
}
return false;
}
- //Begin encrypted connection
+ // Begin encrypted connection
if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
return false;
}
@@ -228,8 +220,7 @@ class SMTP {
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
+ echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
';
}
return false;
}
@@ -246,8 +237,7 @@ class SMTP {
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
+ echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
';
}
return false;
}
@@ -264,8 +254,7 @@ class SMTP {
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
+ echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
';
}
return false;
}
@@ -282,11 +271,9 @@ class SMTP {
if(!empty($this->smtp_conn)) {
$sock_status = socket_get_status($this->smtp_conn);
if($sock_status["eof"]) {
- // hmm this is an odd situation... the socket is
- // valid but we are not connected anymore
+ // the socket is valid but we are not connected
if($this->do_debug >= 1) {
- echo "SMTP -> NOTICE:" . $this->CRLF .
- "EOF caught while checking if connected";
+ echo "SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected";
}
$this->Close();
return false;
@@ -313,9 +300,9 @@ class SMTP {
}
}
- /***************************************************************
- * SMTP COMMANDS *
- *************************************************************/
+ /////////////////////////////////////////////////
+ // SMTP COMMANDS
+ /////////////////////////////////////////////////
/**
* Issues a data command and sends the msg_data to the server
@@ -351,7 +338,7 @@ class SMTP {
$code = substr($rply,0,3);
if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
';
}
if($code != 354) {
@@ -360,8 +347,7 @@ class SMTP {
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
+ echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
';
}
return false;
}
@@ -374,7 +360,7 @@ class SMTP {
* each of those into smaller lines to fit within the limit.
* in addition we will be looking for lines that start with
* a period '.' and append and additional period '.' to that
- * line. NOTE: this does not count towards are limit.
+ * line. NOTE: this does not count towards limit.
*/
// normalize the line breaks so we know the explode works
@@ -390,6 +376,7 @@ class SMTP {
* and we can process all lines before a blank "" line as
* headers.
*/
+
$field = substr($lines[0],0,strpos($lines[0],":"));
$in_headers = false;
if(!empty($field) && !strstr($field," ")) {
@@ -417,8 +404,7 @@ class SMTP {
$line = substr($line,$pos + 1);
}
- /* if we are processing headers we need to
- * add a LWSP-char to the front of the new line
+ /* if processing headers add a LWSP-char to the front of new line
* rfc 822 on long msg headers
*/
if($in_headers) {
@@ -427,7 +413,7 @@ class SMTP {
}
$lines_out[] = $line;
- // now send the lines to the server
+ // send the lines to the server
while(list(,$line_out) = @each($lines_out)) {
if(strlen($line_out) > 0)
{
@@ -439,15 +425,14 @@ class SMTP {
}
}
- // ok all the message data has been sent so lets get this
- // over with aleady
+ // message data has been sent
fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);
$rply = $this->get_lines();
$code = substr($rply,0,3);
if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
';
}
if($code != 250) {
@@ -456,69 +441,13 @@ class SMTP {
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
+ echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
';
}
return false;
}
return true;
}
- /**
- * Expand takes the name and asks the server to list all the
- * people who are members of the _list_. Expand will return
- * back and array of the result or false if an error occurs.
- * Each value in the array returned has the format of:
- * [
';
}
if($code != 250) {
@@ -579,8 +506,7 @@ class SMTP {
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
+ echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
';
}
return false;
}
@@ -590,59 +516,6 @@ class SMTP {
return true;
}
- /**
- * Gets help information on the keyword specified. If the keyword
- * is not specified then returns generic help, ussually contianing
- * A list of keywords that help is available on. This function
- * returns the results back to the user. It is up to the user to
- * handle the returned data. If an error occurs then false is
- * returned with $this->error set appropiately.
- *
- * Implements rfc 821: HELP [
';
}
if($code != 250) {
@@ -682,50 +555,7 @@ class SMTP {
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
- }
-
- /**
- * Sends the command NOOP to the SMTP server.
- *
- * Implements from rfc 821: NOOP
';
}
return false;
}
@@ -759,7 +589,7 @@ class SMTP {
$byemsg = $this->get_lines();
if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg;
+ echo "SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '
';
}
$rval = true;
@@ -773,8 +603,7 @@ class SMTP {
"smtp_rply" => substr($byemsg,4));
$rval = false;
if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $e["error"] . ": " .
- $byemsg . $this->CRLF;
+ echo "SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF . '
';
}
}
@@ -812,7 +641,7 @@ class SMTP {
$code = substr($rply,0,3);
if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
';
}
if($code != 250 && $code != 251) {
@@ -821,8 +650,7 @@ class SMTP {
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
+ echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
';
}
return false;
}
@@ -856,7 +684,7 @@ class SMTP {
$code = substr($rply,0,3);
if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
';
}
if($code != 250) {
@@ -865,8 +693,7 @@ class SMTP {
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
+ echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
';
}
return false;
}
@@ -874,54 +701,6 @@ class SMTP {
return true;
}
- /**
- * Starts a mail transaction from the email address specified in
- * $from. Returns true if successful or false otherwise. If True
- * the mail transaction is started and then one or more Recipient
- * commands may be called followed by a Data command. This command
- * will send the message to the users terminal if they are logged
- * in.
- *
- * Implements rfc 821: SEND
';
}
if($code != 250) {
@@ -962,56 +741,7 @@ class SMTP {
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
- }
-
- /**
- * Starts a mail transaction from the email address specified in
- * $from. Returns true if successful or false otherwise. If True
- * the mail transaction is started and then one or more Recipient
- * commands may be called followed by a Data command. This command
- * will send the message to the users terminal if they are logged
- * in or mail it to them if they are not.
- *
- * Implements rfc 821: SOML
';
}
return false;
}
@@ -1035,56 +765,11 @@ class SMTP {
$this->error = array("error" => "This method, TURN, of the SMTP ".
"is not implemented");
if($this->do_debug >= 1) {
- echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF;
+ echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '
';
}
return false;
}
- /**
- * Verifies that the name is recognized by the server.
- * Returns false if the name could not be verified otherwise
- * the response from the server is returned.
- *
- * Implements rfc 821: VRFY
';
+ echo "SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '
';
}
$data .= $str;
if($this->do_debug >= 4) {
- echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF;
+ echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '
';
}
- // if the 4th character is a space then we are done reading
- // so just break the loop
+ // if 4th character is a space, we are done reading, break the loop
if(substr($str,3,1) == " ") { break; }
}
return $data;
diff --git a/codeworxtech.html b/codeworxtech.html
deleted file mode 100644
index 68ccaa93..00000000
--- a/codeworxtech.html
+++ /dev/null
@@ -1,121 +0,0 @@
-
-
-
-
-
-
-
-The http://phpmailer.codeworxtech.com/ website now carries a few
-advertisements through the Google Adsense network to help offset
-some of our costs.
-Thanks ....
-
-
-www.codeworxtech.com for more information.
-
-
-
- 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.
-
-
-
-
-
-
-
-Regards,
-A few things to note:
-
-
-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.
-
- This is a test of PHPMailer v2.0.0 rc1.
+ This is a test of PHPMailer.
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.
+Included are two attachments:
+phpmailer.gif is an attachment and used inline as a graphic (above)
+phpmailer_mini.gif is an attachment
+
+PHPMailer:
+Author: Andy Prevost (codeworxtech@users.sourceforge.net)
+Author: Marcus Bointon (coolbru@users.sourceforge.net)
+
diff --git a/examples/images/phpmailer.png b/examples/images/phpmailer.png
deleted file mode 100644
index abe0101f36b3f0b3aac2362b546255e5c79fc9d3..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 3506
zcmV;j4NdZiP)+r|4g+!558se!goWzzd+@}!)iw}v{2
z?MDt+IXk`Qpw_Jlbc7qQf`eZ?XHquG9YZbmgmq`B2Hbj3o2JR=D{9?p7WlJiOD5D=
zk>j|WXY3fN&~553;5tIJr*%;CO9b}lG{2Gwm5TVIvi
-<?php
-
-include_once('../class.phpmailer.php');
-
-$mail = new PHPMailer();
-
-$body = $mail->getFile('contents.html');
-
-$body = eregi_replace("[\]",'',$body);
-$subject = eregi_replace("[\]",'',$subject);
-
-$mail->From = "name@yourdomain.com";
-$mail->FromName = "First Last";
-
-$mail->Subject = "PHPMailer Test Subject";
-
-$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
-
-$mail->MsgHTML($body);
-
-$mail->AddAddress("whoto@otherdomain.com", "John Doe");
-
-if(!$mail->Send()) {
- echo 'Failed to send mail';
-} else {
- echo 'Mail sent';
-}
-
-?>
-
-
-<body background="images/bkgrnd.gif" style="margin: 0px;">
-<div style="width: 640px; font-family: Arial, Helvetica, sans-serif; font-size: 11px;">
-<div align="center"><img src="images/phpmailer.gif" style="height: 90px; width: 340px"></div><br>
-<br>
- This is a test of PHPMailer v2.0.0 rc1.<br>
-<br>
-This particular example uses <strong>HTML</strong>, with a <div> tag and inline<br>
-styles.<br>
-<br>
-Also note the use of the PHPMailer at the top with no specific code to handle
-including it in the body of the email.</div>
-</body>
-
-Of course, you can still use PHPMailer the same way you have in the past. -That provides full compatibility with all existing scripts, while new scripts -can take advantage of the new features.
-Modify test_mail.php now with your own email address and try it out.
-To see what the email SHOULD look like in your HTML compatible email viewer: click here
-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/examples/test1.php b/examples/test1.php
deleted file mode 100644
index 5e9a72fa..00000000
--- a/examples/test1.php
+++ /dev/null
@@ -1,29 +0,0 @@
-getFile('contents.html');
-
-$body = eregi_replace("[\]",'',$body);
-$subject = eregi_replace("[\]",'',$subject);
-
-$mail->From = "name@yourdomain.com";
-$mail->FromName = "First Last";
-
-$mail->Subject = "PHPMailer Test Subject";
-
-$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
-
-$mail->MsgHTML($body);
-
-$mail->AddAddress("whoto@otherdomain.com", "John Doe");
-
-if(!$mail->Send()) {
- echo 'Failed to send mail';
-} else {
- echo 'Mail sent';
-}
-
-?>
diff --git a/examples/test_db_smtp_basic.php b/examples/test_db_smtp_basic.php
new file mode 100644
index 00000000..85d01f8d
--- /dev/null
+++ b/examples/test_db_smtp_basic.php
@@ -0,0 +1,58 @@
+
+
+Here is a test HTML email
+ + diff --git a/test/phpmailer_test.php b/test/phpmailerTest.php similarity index 58% rename from test/phpmailer_test.php rename to test/phpmailerTest.php index 5ee74ec1..99581de1 100644 --- a/test/phpmailer_test.php +++ b/test/phpmailerTest.php @@ -1,20 +1,30 @@ TestCase( $name ); - } - /** * Run before each test is started. */ function setUp() { - global $global_vars; global $INCLUDE_DIR; + @include './testbootstrap.php'; //Overrides go in here + $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"; + if (array_key_exists('mail_from', $_REQUEST)) { + $this->Mail->From = $_REQUEST['mail_from']; + } else { + $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"]; + if (array_key_exists('mail_host', $_REQUEST)) { + $this->Mail->Host = $_REQUEST['mail_host']; + } else { + $this->Mail->Host = 'mail.example.com'; + } $this->Mail->Port = 25; $this->Mail->Helo = "localhost.localdomain"; $this->Mail->SMTPAuth = false; @@ -80,18 +91,19 @@ class phpmailerTest extends TestCase $this->Mail->AddReplyTo("no_reply@phpmailer.sf.net", "Reply Guy"); $this->Mail->Sender = "unit_test@phpmailer.sf.net"; - if(strlen($this->Mail->Host) > 0) + if(strlen($this->Mail->Host) > 0) { $this->Mail->Mailer = "smtp"; - else - { + } 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"); + if (array_key_exists('mail_to', $_REQUEST)) { + $this->SetAddress($_REQUEST['mail_to'], 'Test User', 'to'); + } + if (array_key_exists('mail_cc', $_REQUEST) and strlen($_REQUEST['mail_cc']) > 0) { + $this->SetAddress($_REQUEST['mail_cc'], 'Carbon User', 'cc'); + } } /** @@ -134,7 +146,7 @@ class phpmailerTest extends TestCase $ReportBody .= "---------------------" . $eol; $ReportBody .= "Unit Test Information" . $eol; $ReportBody .= "---------------------" . $eol; - $ReportBody .= "phpmailer version: " . $this->Mail->Version . $eol; + $ReportBody .= "phpmailer version: " . PHPMailer::VERSION . $eol; $ReportBody .= "Content Type: " . $this->Mail->ContentType . $eol; if(strlen($this->Mail->Host) > 0) @@ -146,11 +158,10 @@ class phpmailerTest extends TestCase { $ReportBody .= "Attachments:" . $eol; $ReportBody .= $bullet_start; - for($i = 0; $i < count($attachments); $i++) - { - $ReportBody .= $bullet . "Name: " . $attachments[$i][1] . ", "; - $ReportBody .= "Encoding: " . $attachments[$i][3] . ", "; - $ReportBody .= "Type: " . $attachments[$i][4] . $eol; + foreach($attachments as $attachment) { + $ReportBody .= $bullet . "Name: " . $attachment[1] . ", "; + $ReportBody .= "Encoding: " . $attachment[3] . ", "; + $ReportBody .= "Type: " . $attachment[4] . $eol; } $ReportBody .= $bullet_end . $eol; } @@ -271,7 +282,7 @@ class phpmailerTest extends TestCase $this->Mail->Subject .= ": Wordwrap"; $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo); } /** @@ -286,7 +297,7 @@ class phpmailerTest extends TestCase $this->Mail->AddReplyTo("nobody@nobody.com", "Nobody (Unit Test)"); $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo); } /** @@ -299,18 +310,18 @@ class phpmailerTest extends TestCase if(!$this->Mail->AddAttachment("test.png")) { - $this->assert(false, $this->Mail->ErrorInfo); + $this->assertTrue(false, $this->Mail->ErrorInfo); return; } - if(!$this->Mail->AddAttachment("phpmailer_test.php", "test.txt")) + if(!$this->Mail->AddAttachment(__FILE__, "test.txt")) { - $this->assert(false, $this->Mail->ErrorInfo); + $this->assertTrue(false, $this->Mail->ErrorInfo); return; } $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo); } /** @@ -328,7 +339,7 @@ class phpmailerTest extends TestCase $this->Mail->AddStringAttachment($sAttachment, "string_attach.txt"); $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo); } /** @@ -341,7 +352,13 @@ class phpmailerTest extends TestCase $this->Mail->Encoding = "quoted-printable"; $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo); + + //Check that a quoted printable encode and decode results in the same as went in + $t = substr(file_get_contents(__FILE__), 0, 1024); //Just pick a chunk of this file as test content + $this->assertEquals($t, quoted_printable_decode($this->Mail->EncodeQP($t)), 'QP encoding round-trip failed'); + //$this->assertEquals($t, quoted_printable_decode($this->Mail->EncodeQPphp($t)), 'Native PHP QP encoding round-trip failed'); //TODO the PHP qp encoder is quite broken + } /** @@ -358,7 +375,7 @@ class phpmailerTest extends TestCase "phpmailer. Thank you!"; $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo); } /** @@ -370,14 +387,14 @@ class phpmailerTest extends TestCase $this->Mail->Subject .= ": HTML + Attachment"; $this->Mail->IsHTML(true); - if(!$this->Mail->AddAttachment("phpmailer_test.php", "test_attach.txt")) + if(!$this->Mail->AddAttachment(__FILE__, "test_attach.txt")) { - $this->assert(false, $this->Mail->ErrorInfo); + $this->assertTrue(false, $this->Mail->ErrorInfo); return; } $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo); } /** @@ -393,12 +410,16 @@ class phpmailerTest extends TestCase if(!$this->Mail->AddEmbeddedImage("test.png", "my-attach", "test.png", "base64", "image/png")) { - $this->assert(false, $this->Mail->ErrorInfo); + $this->assertTrue(false, $this->Mail->ErrorInfo); return; } $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo); + //For code coverage + $this->Mail->AddEmbeddedImage('thisfiledoesntexist', 'xyz'); //Non-existent file + $this->Mail->AddEmbeddedImage(__FILE__, '123'); //Missing name + } /** @@ -414,18 +435,18 @@ class phpmailerTest extends TestCase if(!$this->Mail->AddEmbeddedImage("test.png", "my-attach", "test.png", "base64", "image/png")) { - $this->assert(false, $this->Mail->ErrorInfo); + $this->assertTrue(false, $this->Mail->ErrorInfo); return; } - if(!$this->Mail->AddAttachment("phpmailer_test.php", "test.txt")) + if(!$this->Mail->AddAttachment(__FILE__, "test.txt")) { - $this->assert(false, $this->Mail->ErrorInfo); + $this->assertTrue(false, $this->Mail->ErrorInfo); return; } $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo); } /** @@ -442,7 +463,7 @@ class phpmailerTest extends TestCase $this->Mail->Subject .= ": AltBody + Word Wrap"; $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo); } /** @@ -455,18 +476,18 @@ class phpmailerTest extends TestCase $this->Mail->Subject .= ": AltBody + Attachment"; $this->Mail->IsHTML(true); - if(!$this->Mail->AddAttachment("phpmailer_test.php", "test_attach.txt")) + if(!$this->Mail->AddAttachment(__FILE__, "test_attach.txt")) { - $this->assert(false, $this->Mail->ErrorInfo); + $this->assertTrue(false, $this->Mail->ErrorInfo); return; } $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo); if (is_writable('.')) { file_put_contents('message.txt', $this->Mail->CreateHeader() . $this->Mail->CreateBody()); } else { - $this->assert(false, 'Could not write local file - check permissions'); + $this->assertTrue(false, 'Could not write local file - check permissions'); } } @@ -476,10 +497,30 @@ class phpmailerTest extends TestCase $subject = $this->Mail->Subject; $this->Mail->Subject = $subject . ": SMTP 1"; - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo); $this->Mail->Subject = $subject . ": SMTP 2"; - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + function test_SendmailSend() { + $this->Mail->Body = "Sending via sendmail"; + $this->BuildBody(); + $subject = $this->Mail->Subject; + + $this->Mail->Subject = $subject . ": sendmail"; + $this->Mail->IsSendmail(); + $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + function test_MailSend() { + $this->Mail->Body = "Sending via mail()"; + $this->BuildBody(); + $subject = $this->Mail->Subject; + + $this->Mail->Subject = $subject . ": mail()"; + $this->Mail->IsMail(); + $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo); } function test_SmtpKeepAlive() { @@ -489,10 +530,10 @@ class phpmailerTest extends TestCase $this->Mail->SMTPKeepAlive = true; $this->Mail->Subject = $subject . ": SMTP keep-alive 1"; - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo); $this->Mail->Subject = $subject . ": SMTP keep-alive 2"; - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo); $this->Mail->SmtpClose(); } @@ -505,124 +546,114 @@ class phpmailerTest extends TestCase $this->BuildBody(); $this->Mail->Subject = str_repeat("A", 998); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + $this->assertTrue($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"); - //Note that this is language dependent - $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"); - } - - function test_Addressing() { - $this->assert($this->Mail->AddAddress('a@example.com'), 'Addressing failed'); - $this->assert(!$this->Mail->AddAddress('a@example.com'), 'Duplicate addressing failed'); - $this->assert($this->Mail->AddCC('b@example.com'), 'CC addressing failed'); - $this->assert(!$this->Mail->AddCC('b@example.com'), 'CC duplicate Addressing failed'); - $this->assert(!$this->Mail->AddCC('a@example.com'), 'CC duplicate Addressing failed (2)'); - $this->assert($this->Mail->AddBCC('c@example.com'), 'BCC addressing failed'); - $this->assert(!$this->Mail->AddBCC('c@example.com'), 'BCC duplicate addressing failed'); - $this->assert(!$this->Mail->AddBCC('a@example.com'), 'BCC duplicate Addressing failed (2)'); - $this->Mail->ClearAddresses(); - $this->assert($this->Mail->AddAddress('a@example.com'), 'Addressing after clear failed'); - $this->Mail->ClearCCs(); - $this->assert($this->Mail->AddAddress('b@example.com'), 'CC addressing after clear failed'); - $this->Mail->ClearBCCs(); - $this->assert($this->Mail->AddAddress('c@example.com'), 'BCC addressing after clear failed'); - $this->Mail->AddAddress('a@example.com'); - $this->Mail->AddCC('b@example.com'); - $this->Mail->AddBCC('c@example.com'); - $this->Mail->ClearAllRecipients(); //Not much of a test, but helps coverage - } - - // Check that we are not missing any translations in any langauges - function test_Translations() { - //Extend this array as new strings are added - $expectedtranslations = array( - 'provide_address', - 'mailer_not_supported', - 'execute', - 'instantiate', - 'authenticate', - 'from_failed', - 'recipients_failed', - 'data_not_accepted', - 'connect_host', - 'file_access', - 'file_open', - 'encoding', - 'signing', - 'smtp_error' - ); - try { - foreach (new DirectoryIterator('../language') as $langfile) { - if (!preg_match('/^phpmailer\.lang-/', $langfile)) continue; //Skip non-language files - $PHPMAILER_LANG = array(); - include '../language/'.$langfile; - foreach($expectedtranslations as $string) { - $this->assert(isset($PHPMAILER_LANG[$string]), 'Translation missing; \''.$string.'\' in '.$langfile); - } - } - } - catch(Exception $e) { - $this->assert(false, 'No language files found!'); - } - } - - //Check that getFile works - function test_getFile() { - $a = $this->Mail->getFile('../class.phpmailer.php'); //Point at any non-empty file - $this->assert(($a !== false), 'GetFile failed to read a file.'); - } -} -/** - * Create and run test instance. - */ + function test_Error() { + $this->Mail->Subject .= ": This should be sent"; + $this->BuildBody(); + $this->Mail->ClearAllRecipients(); // no addresses should cause an error + $this->assertTrue($this->Mail->IsError() == false, "Error found"); + $this->assertTrue($this->Mail->Send() == false, "Send succeeded"); + $this->assertTrue($this->Mail->IsError(), "No error found"); + $this->assertEquals('You must provide at least one recipient email address.', $this->Mail->ErrorInfo); + $this->Mail->AddAddress($_REQUEST['mail_to']); + $this->assertTrue($this->Mail->Send(), "Send failed"); + } + + function test_Addressing() { + $this->assertFalse($this->Mail->AddAddress('a@example..com'), 'Invalid address accepted'); + $this->assertTrue($this->Mail->AddAddress('a@example.com'), 'Addressing failed'); + $this->assertFalse($this->Mail->AddAddress('a@example.com'), 'Duplicate addressing failed'); + $this->assertTrue($this->Mail->AddCC('b@example.com'), 'CC addressing failed'); + $this->assertFalse($this->Mail->AddCC('b@example.com'), 'CC duplicate addressing failed'); + $this->assertFalse($this->Mail->AddCC('a@example.com'), 'CC duplicate addressing failed (2)'); + $this->assertTrue($this->Mail->AddBCC('c@example.com'), 'BCC addressing failed'); + $this->assertFalse($this->Mail->AddBCC('c@example.com'), 'BCC duplicate addressing failed'); + $this->assertFalse($this->Mail->AddBCC('a@example.com'), 'BCC duplicate addressing failed (2)'); + $this->assertTrue($this->Mail->AddReplyTo('a@example.com'), 'Replyto Addressing failed'); + $this->assertFalse($this->Mail->AddReplyTo('a@example..com'), 'Invalid Replyto address accepted'); + $this->Mail->ClearAddresses(); + $this->Mail->ClearCCs(); + $this->Mail->ClearBCCs(); + $this->Mail->ClearReplyTos(); + } + + /** + * Test language files for missing and excess translations + * All languages are compared with English + */ + function test_Translations() { + $this->Mail->SetLanguage('en'); + $definedStrings = $this->Mail->GetTranslations(); + foreach (new DirectoryIterator('../language') as $fileInfo) { + if($fileInfo->isDot()) continue; + $matches = array(); + //Only look at language files, ignore anything else in there + if (preg_match('/^phpmailer\.lang-([a-z_]{2,})\.php$/', $fileInfo->getFilename(), $matches)) { + $lang = $matches[1]; //Extract language code + $PHPMAILER_LANG = array(); //Language strings get put in here + include $fileInfo->getPathname(); //Get language strings + $missing = array_diff(array_keys($definedStrings), array_keys($PHPMAILER_LANG)); + $extra = array_diff(array_keys($PHPMAILER_LANG), array_keys($definedStrings)); + $this->assertTrue(empty($missing), "Missing translations in $lang: ". implode(', ', $missing)); + $this->assertTrue(empty($extra), "Extra translations in $lang: ". implode(', ', $extra)); + } + } + } + + /** + * Encoding tests + */ + function test_Encodings() { + $this->Mail->Charset = 'iso-8859-1'; + $this->assertEquals('=A1Hola!_Se=F1or!', $this->Mail->EncodeQ('¡Hola! Señor!', 'text'), 'Q Encoding (text) failed'); + $this->assertEquals('=A1Hola!_Se=F1or!', $this->Mail->EncodeQ('¡Hola! Señor!', 'comment'), 'Q Encoding (comment) failed'); + $this->assertEquals('=A1Hola!_Se=F1or!', $this->Mail->EncodeQ('¡Hola! Señor!', 'phrase'), 'Q Encoding (phrase) failed'); + } + + /** + * Signing tests + */ + function test_Signing() { + $this->Mail->Sign('certfile.txt', 'keyfile.txt', 'password'); //TODO this is not really testing signing, but at least helps coverage + } + + /** + * Miscellaneous calls to improve test coverage and some small tests + */ + function test_Miscellaneous() { + $this->assertEquals('application/pdf', PHPMailer::_mime_types('pdf') , 'MIME TYPE lookup failed'); + $this->Mail->AddCustomHeader('SomeHeader: Some Value'); + $this->Mail->ClearCustomHeaders(); + $this->Mail->ClearAttachments(); + $this->Mail->IsHTML(false); + $this->Mail->IsSMTP(); + $this->Mail->IsMail(); + $this->Mail->IsSendMail(); + $this->Mail->IsQmail(); + $this->Mail->SetLanguage('fr'); + $this->Mail->Sender = ''; + $this->Mail->CreateHeader(); + $this->assertFalse($this->Mail->set('x', 'y'), 'Invalid property set succeeded'); + $this->assertTrue($this->Mail->set('Timeout', 11), 'Valid property set failed'); + $this->Mail->getFile(__FILE__); + } +} -if(isset($HTTP_GET_VARS)) - $global_vars = $HTTP_GET_VARS; -else - $global_vars = $_REQUEST; - -if(isset($global_vars["submitted"])) -{ - echo "Test results: