[pLog-svn] r3693 - in plog/trunk/class: mail mail/phpmailer
mail/phpmailer/language test test/tests test/tests/mail
test/tests/mail/phpmailer
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Wed Jul 5 15:28:43 GMT 2006
Author: oscar
Date: 2006-07-05 15:28:43 +0000 (Wed, 05 Jul 2006)
New Revision: 3693
Added:
plog/trunk/class/test/tests/mail/
plog/trunk/class/test/tests/mail/emailservice_test.class.php
plog/trunk/class/test/tests/mail/phpmailer/
plog/trunk/class/test/tests/mail/phpmailer/message.txt
plog/trunk/class/test/tests/mail/phpmailer/phpmailer_test.class.php
plog/trunk/class/test/tests/mail/phpmailer/test.png
Modified:
plog/trunk/class/mail/emailservice.class.php
plog/trunk/class/mail/phpmailer/LICENSE
plog/trunk/class/mail/phpmailer/README
plog/trunk/class/mail/phpmailer/class.phpmailer.php
plog/trunk/class/mail/phpmailer/class.smtp.php
plog/trunk/class/mail/phpmailer/language/phpmailer.lang-en.php
plog/trunk/class/test/testrunner.class.php
Log:
updated phpmailer to the latest release, added tests for it and our own EmailService
Modified: plog/trunk/class/mail/emailservice.class.php
===================================================================
--- plog/trunk/class/mail/emailservice.class.php 2006-07-05 15:27:21 UTC (rev 3692)
+++ plog/trunk/class/mail/emailservice.class.php 2006-07-05 15:28:43 UTC (rev 3693)
@@ -66,15 +66,15 @@
{
var $_config;
+ var $_lastErrorMessage;
/**
* Constructor
*/
function EmailService()
{
-
-
$this->_config =& Config::getConfig();
+ $this->_lastErrorMessage = "";
}
/**
@@ -90,6 +90,8 @@
if( !$this->_config->getValue( "email_service_enabled" ))
return false;
+ $this->_lastErrorMessage = "";
+
// create a phpmailer object
$mail = new PHPMailer();
@@ -110,6 +112,9 @@
// set the character set of the message
$mail->CharSet = $message->getCharset();
+ // set the language for error reporting
+ $mail->SetLanguage( 'en', PLOG_CLASS_PATH."class/mail/phpmailer/language/" );
+
//
// phpmailer supports
// php built-in mail() function
@@ -177,7 +182,22 @@
}
// we have set up everything, send the mail
- return( $mail->Send());
+ $result = $mail->Send();
+
+ if( !$result )
+ $this->_lastErrorMessage = $mail->ErrorInfo;
+
+ return( $result );
}
+
+ /**
+ * Returns the last error message
+ *
+ * @return A string containing the last error message, if any
+ */
+ function getLastErrorMessage()
+ {
+ return( $this->_lastErrorMessage );
+ }
}
?>
Modified: plog/trunk/class/mail/phpmailer/LICENSE
===================================================================
--- plog/trunk/class/mail/phpmailer/LICENSE 2006-07-05 15:27:21 UTC (rev 3692)
+++ plog/trunk/class/mail/phpmailer/LICENSE 2006-07-05 15:28:43 UTC (rev 3693)
@@ -1,504 +1,504 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard. To achieve this, non-free programs must be
-allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
- <one line to give the library's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- <signature of Ty Coon>, 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
-
-
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
Modified: plog/trunk/class/mail/phpmailer/README
===================================================================
--- plog/trunk/class/mail/phpmailer/README 2006-07-05 15:27:21 UTC (rev 3692)
+++ plog/trunk/class/mail/phpmailer/README 2006-07-05 15:28:43 UTC (rev 3693)
@@ -50,7 +50,7 @@
the PHPMailer SetLanguage method like so:
// To load the Portuguese version
-$mail->SetLanguage("br", "/optional/path/to/language/directory");
+$mail->SetLanguage("br", "/optional/path/to/language/directory/");
That's it. You should now be ready to use PHPMailer!
@@ -64,9 +64,9 @@
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "smtp1.example.com;smtp2.example.com"; // specify main and backup server
-$mail->SMTPAuth = true // turn on SMTP authentication
-$mail->Username = "jswan" // SMTP username
-$mail->Password = "secret" // SMTP password
+$mail->SMTPAuth = true; // turn on SMTP authentication
+$mail->Username = "jswan"; // SMTP username
+$mail->Password = "secret"; // SMTP password
$mail->From = "from at example.com";
$mail->FromName = "Mailer";
Modified: plog/trunk/class/mail/phpmailer/class.phpmailer.php
===================================================================
--- plog/trunk/class/mail/phpmailer/class.phpmailer.php 2006-07-05 15:27:21 UTC (rev 3692)
+++ plog/trunk/class/mail/phpmailer/class.phpmailer.php 2006-07-05 15:28:43 UTC (rev 3693)
@@ -1,1531 +1,1499 @@
-<?php
-////////////////////////////////////////////////////
-// PHPMailer - PHP email class
-//
-// Class for sending email using either
-// sendmail, PHP mail(), or SMTP. Methods are
-// based upon the standard AspEmail(tm) classes.
-//
-// Copyright (C) 2001 - 2003 Brent R. Matzelle
-//
-// License: LGPL, see LICENSE
-////////////////////////////////////////////////////
-
-/**
- * PHPMailer - PHP email transport class
- * @package PHPMailer
- * @author Brent R. Matzelle
- * @copyright 2001 - 2003 Brent R. Matzelle
- * \ingroup Mail
- */
-class PHPMailer
-{
- /////////////////////////////////////////////////
- // PUBLIC VARIABLES
- /////////////////////////////////////////////////
-
- /**
- * Email priority (1 = High, 3 = Normal, 5 = low).
- * @var int
- */
- var $Priority = 3;
-
- /**
- * Sets the CharSet of the message.
- * @var string
- */
- var $CharSet = "iso-8859-1";
-
- /**
- * Sets the Content-type of the message.
- * @var string
- */
- var $ContentType = "text/plain";
-
- /**
- * Sets the Encoding of the message. Options for this are "8bit",
- * "7bit", "binary", "base64", and "quoted-printable".
- * @var string
- */
- var $Encoding = "8bit";
-
- /**
- * Holds the most recent mailer error message.
- * @var string
- */
- var $ErrorInfo = "";
-
- /**
- * Sets the From email address for the message.
- * @var string
- */
- var $From = "root at localhost";
-
- /**
- * Sets the From name of the message.
- * @var string
- */
- var $FromName = "Root User";
-
- /**
- * Sets the Sender email (Return-Path) of the message. If not empty,
- * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
- * @var string
- */
- var $Sender = "";
-
- /**
- * Sets the Subject of the message.
- * @var string
- */
- var $Subject = "";
-
- /**
- * Sets the Body of the message. This can be either an HTML or text body.
- * If HTML then run IsHTML(true).
- * @var string
- */
- var $Body = "";
-
- /**
- * Sets the text-only body of the message. This automatically sets the
- * email to multipart/alternative. This body can be read by mail
- * clients that do not have HTML email capability such as mutt. Clients
- * that can read HTML will view the normal Body.
- * @var string
- */
- var $AltBody = "";
-
- /**
- * Sets word wrapping on the body of the message to a given number of
- * characters.
- * @var int
- */
- var $WordWrap = 0;
-
- /**
- * Method to send mail: ("mail", "sendmail", or "smtp").
- * @var string
- */
- var $Mailer = "mail";
-
- /**
- * Sets the path of the sendmail program.
- * @var string
- */
- var $Sendmail = "/usr/sbin/sendmail";
-
- /**
- * Path to PHPMailer plugins. This is now only useful if the SMTP class
- * is in a different directory than the PHP include path.
- * @var string
- */
- var $PluginDir = "";
-
- /**
- * Holds PHPMailer version.
- * @var string
- */
- var $Version = "1.71";
-
- /**
- * Sets the email address that a reading confirmation will be sent.
- * @var string
- */
- var $ConfirmReadingTo = "";
-
- /**
- * Sets the hostname to use in Message-Id and Received headers
- * and as default HELO string. If empty, the value returned
- * by SERVER_NAME is used or 'localhost.localdomain'.
- * @var string
- */
- var $Hostname = "";
-
-
- /////////////////////////////////////////////////
- // SMTP VARIABLES
- /////////////////////////////////////////////////
-
- /**
- * Sets the SMTP hosts. All hosts must be separated by a
- * semicolon. You can also specify a different port
- * for each host by using this format: [hostname:port]
- * (e.g. "smtp1.example.com:25;smtp2.example.com").
- * Hosts will be tried in order.
- * @var string
- */
- var $Host = "localhost";
-
- /**
- * Sets the default SMTP server port.
- * @var int
- */
- var $Port = 25;
-
- /**
- * Sets the SMTP HELO of the message (Default is $Hostname).
- * @var string
- */
- var $Helo = "";
-
- /**
- * Sets SMTP authentication. Utilizes the Username and Password variables.
- * @var bool
- */
- var $SMTPAuth = false;
-
- /**
- * Sets SMTP username.
- * @var string
- */
- var $Username = "";
-
- /**
- * Sets SMTP password.
- * @var string
- */
- var $Password = "";
-
- /**
- * Sets the SMTP server timeout in seconds. This function will not
- * work with the win32 version.
- * @var int
- */
- var $Timeout = 10;
-
- /**
- * Sets SMTP class debugging on or off.
- * @var bool
- */
- var $SMTPDebug = false;
-
- /**
- * Prevents the SMTP connection from being closed after each mail
- * sending. If this is set to true then to close the connection
- * requires an explicit call to SmtpClose().
- * @var bool
- */
- var $SMTPKeepAlive = false;
-
- /**#@+
- * @access private
- */
- var $smtp = NULL;
- var $to = array();
- var $cc = array();
- var $bcc = array();
- var $ReplyTo = array();
- var $attachment = array();
- var $CustomHeader = array();
- var $message_type = "";
- var $boundary = array();
- var $language = array();
- var $error_count = 0;
- var $LE = "\n";
- /**#@-*/
-
- /////////////////////////////////////////////////
- // VARIABLE METHODS
- /////////////////////////////////////////////////
-
- /**
- * Sets message type to HTML.
- * @param bool $bool
- * @return void
- */
- function IsHTML($bool) {
- if($bool == true)
- $this->ContentType = "text/html";
- else
- $this->ContentType = "text/plain";
- }
-
- /**
- * Sets Mailer to send message using SMTP.
- * @return void
- */
- function IsSMTP() {
- $this->Mailer = "smtp";
- }
-
- /**
- * Sets Mailer to send message using PHP mail() function.
- * @return void
- */
- function IsMail() {
- $this->Mailer = "mail";
- }
-
- /**
- * Sets Mailer to send message using the $Sendmail program.
- * @return void
- */
- function IsSendmail() {
- $this->Mailer = "sendmail";
- }
-
- /**
- * Sets Mailer to send message using the qmail MTA.
- * @return void
- */
- function IsQmail() {
- $this->Sendmail = "/var/qmail/bin/sendmail";
- $this->Mailer = "sendmail";
- }
-
-
- /////////////////////////////////////////////////
- // RECIPIENT METHODS
- /////////////////////////////////////////////////
-
- /**
- * Adds a "To" address.
- * @param string $address
- * @param string $name
- * @return void
- */
- function AddAddress($address, $name = "") {
- $cur = count($this->to);
- $this->to[$cur][0] = trim($address);
- $this->to[$cur][1] = $name;
- }
-
- /**
- * Adds a "Cc" address. Note: this function works
- * with the SMTP mailer on win32, not with the "mail"
- * mailer.
- * @param string $address
- * @param string $name
- * @return void
- */
- function AddCC($address, $name = "") {
- $cur = count($this->cc);
- $this->cc[$cur][0] = trim($address);
- $this->cc[$cur][1] = $name;
- }
-
- /**
- * Adds a "Bcc" address. Note: this function works
- * with the SMTP mailer on win32, not with the "mail"
- * mailer.
- * @param string $address
- * @param string $name
- * @return void
- */
- function AddBCC($address, $name = "") {
- $cur = count($this->bcc);
- $this->bcc[$cur][0] = trim($address);
- $this->bcc[$cur][1] = $name;
- }
-
- /**
- * Adds a "Reply-to" address.
- * @param string $address
- * @param string $name
- * @return void
- */
- function AddReplyTo($address, $name = "") {
- $cur = count($this->ReplyTo);
- $this->ReplyTo[$cur][0] = trim($address);
- $this->ReplyTo[$cur][1] = $name;
- }
-
-
- /////////////////////////////////////////////////
- // MAIL SENDING METHODS
- /////////////////////////////////////////////////
-
- /**
- * Creates message and assigns Mailer. If the message is
- * not sent successfully then it returns false. Use the ErrorInfo
- * variable to view description of the error.
- * @return bool
- */
- function Send() {
- $header = "";
- $body = "";
-
- if((count($this->to) + count($this->cc) + count($this->bcc)) < 1)
- {
- $this->SetError($this->Lang("provide_address"));
- return false;
- }
-
- // Set whether the message is multipart/alternative
- if(!empty($this->AltBody))
- $this->ContentType = "multipart/alternative";
-
- $this->SetMessageType();
- $header .= $this->CreateHeader();
- $body = $this->CreateBody();
-
- if($body == "") { return false; }
-
- // Choose the mailer
- if($this->Mailer == "sendmail")
- {
- if(!$this->SendmailSend($header, $body))
- return false;
- }
- elseif($this->Mailer == "mail")
- {
- if(!$this->MailSend($header, $body))
- return false;
- }
- elseif($this->Mailer == "smtp")
- {
- if(!$this->SmtpSend($header, $body))
- return false;
- }
- else
- {
- $this->SetError($this->Mailer . $this->Lang("mailer_not_supported"));
- return false;
- }
-
- return true;
- }
-
- /**
- * Sends mail using the $Sendmail program.
- * @access private
- * @return bool
- */
- function SendmailSend($header, $body) {
- if ($this->Sender != "")
- $sendmail = sprintf("%s -oi -f %s -t", $this->Sendmail, $this->Sender);
- else
- $sendmail = sprintf("%s -oi -t", $this->Sendmail);
-
- if(!@$mail = popen($sendmail, "w"))
- {
- $this->SetError($this->Lang("execute") . $this->Sendmail);
- return false;
- }
-
- fputs($mail, $header);
- fputs($mail, $body);
-
- $result = pclose($mail) >> 8 & 0xFF;
- if($result != 0)
- {
- $this->SetError($this->Lang("execute") . $this->Sendmail);
- return false;
- }
-
- return true;
- }
-
- /**
- * Sends mail using the PHP mail() function.
- * @access private
- * @return bool
- */
- function MailSend($header, $body) {
- $to = "";
- for($i = 0; $i < count($this->to); $i++)
- {
- if($i != 0) { $to .= ", "; }
- $to .= $this->to[$i][0];
- }
-
- if ($this->Sender != "" && strlen(ini_get("safe_mode"))< 1)
- {
- $old_from = ini_get("sendmail_from");
- ini_set("sendmail_from", $this->Sender);
- $params = sprintf("-oi -f %s", $this->Sender);
- $rt = @mail($to, $this->EncodeHeader($this->Subject), $body,
- $header, $params);
- }
- else
- $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $header);
-
- if (isset($old_from))
- ini_set("sendmail_from", $old_from);
-
- if(!$rt)
- {
- $this->SetError($this->Lang("instantiate"));
- return false;
- }
-
- return true;
- }
-
- /**
- * Sends mail via SMTP using PhpSMTP (Author:
- * Chris Ryan). Returns bool. Returns false if there is a
- * bad MAIL FROM, RCPT, or DATA input.
- * @access private
- * @return bool
- */
- function SmtpSend($header, $body) {
- include_once($this->PluginDir . "class/mail/phpmailer/class.smtp.php");
- $error = "";
- $bad_rcpt = array();
-
- if(!$this->SmtpConnect())
- return false;
-
- $smtp_from = ($this->Sender == "") ? $this->From : $this->Sender;
- if(!$this->smtp->Mail($smtp_from))
- {
- $error = $this->Lang("from_failed") . $smtp_from;
- $this->SetError($error);
- $this->smtp->Reset();
- return false;
- }
-
- // Attempt to send attach all recipients
- for($i = 0; $i < count($this->to); $i++)
- {
- if(!$this->smtp->Recipient($this->to[$i][0]))
- $bad_rcpt[] = $this->to[$i][0];
- }
- for($i = 0; $i < count($this->cc); $i++)
- {
- if(!$this->smtp->Recipient($this->cc[$i][0]))
- $bad_rcpt[] = $this->cc[$i][0];
- }
- for($i = 0; $i < count($this->bcc); $i++)
- {
- if(!$this->smtp->Recipient($this->bcc[$i][0]))
- $bad_rcpt[] = $this->bcc[$i][0];
- }
-
- if(count($bad_rcpt) > 0) // Create error message
- {
- for($i = 0; $i < count($bad_rcpt); $i++)
- {
- if($i != 0) { $error .= ", "; }
- $error .= $bad_rcpt[$i];
- }
- $error = $this->Lang("recipients_failed") . $error;
- $this->SetError($error);
- $this->smtp->Reset();
- return false;
- }
-
- if(!$this->smtp->Data($header . $body))
- {
- $this->SetError($this->Lang("data_not_accepted"));
- $this->smtp->Reset();
- return false;
- }
- if($this->SMTPKeepAlive == true)
- $this->smtp->Reset();
- else
- $this->SmtpClose();
-
- return true;
- }
-
- /**
- * Initiates a connection to an SMTP server. Returns false if the
- * operation failed.
- * @access private
- * @return bool
- */
- function SmtpConnect() {
- if($this->smtp == NULL) { $this->smtp = new SMTP(); }
-
- $this->smtp->do_debug = $this->SMTPDebug;
- $hosts = explode(";", $this->Host);
- $index = 0;
- $connection = ($this->smtp->Connected());
-
- // Retry while there is no connection
- while($index < count($hosts) && $connection == false)
- {
- if(strstr($hosts[$index], ":"))
- list($host, $port) = explode(":", $hosts[$index]);
- else
- {
- $host = $hosts[$index];
- $port = $this->Port;
- }
-
- if($this->smtp->Connect($host, $port, $this->Timeout))
- {
- if ($this->Helo != '')
- $this->smtp->Hello($this->Helo);
- else
- $this->smtp->Hello($this->ServerHostname());
-
- if($this->SMTPAuth)
- {
- if(!$this->smtp->Authenticate($this->Username,
- $this->Password))
- {
- $this->SetError($this->Lang("authenticate"));
- $this->smtp->Reset();
- $connection = false;
- }
- }
- $connection = true;
- }
- $index++;
- }
- if(!$connection)
- $this->SetError($this->Lang("connect_host"));
-
- return $connection;
- }
-
- /**
- * Closes the active SMTP session if one exists.
- * @return void
- */
- function SmtpClose() {
- if($this->smtp != NULL)
- {
- if($this->smtp->Connected())
- {
- $this->smtp->Quit();
- $this->smtp->Close();
- }
- }
- }
-
- /**
- * Sets the language for all class error messages. Returns false
- * if it cannot load the language file. The default language type
- * is English.
- * @param string $lang_type Type of language (e.g. Portuguese: "br")
- * @param string $lang_path Path to the language file directory
- * @access public
- * @return bool
- */
- function SetLanguage($lang_type, $lang_path = "") {
- if(file_exists($lang_path.'phpmailer.lang-'.$lang_type.'.php'))
- include($lang_path.'phpmailer.lang-'.$lang_type.'.php');
- else if(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;
- }
- $this->language = $PHPMAILER_LANG;
-
- return true;
- }
-
- /////////////////////////////////////////////////
- // MESSAGE CREATION METHODS
- /////////////////////////////////////////////////
-
- /**
- * Creates recipient headers.
- * @access private
- * @return string
- */
- function AddrAppend($type, $addr) {
- $addr_str = $type . ": ";
- $addr_str .= $this->AddrFormat($addr[0]);
- if(count($addr) > 1)
- {
- for($i = 1; $i < count($addr); $i++)
- $addr_str .= ", " . $this->AddrFormat($addr[$i]);
- }
- $addr_str .= $this->LE;
-
- return $addr_str;
- }
-
- /**
- * Formats an address correctly.
- * @access private
- * @return string
- */
- function AddrFormat($addr) {
- if(empty($addr[1]))
- $formatted = $addr[0];
- else
- {
- $formatted = $this->EncodeHeader($addr[1], 'phrase') . " <" .
- $addr[0] . ">";
- }
-
- return $formatted;
- }
-
- /**
- * Wraps message for use with mailers that do not
- * automatically perform wrapping and for quoted-printable.
- * Original written by philippe.
- * @access private
- * @return string
- */
- function WrapText($message, $length, $qp_mode = false) {
- $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
-
- $message = $this->FixEOL($message);
- if (substr($message, -1) == $this->LE)
- $message = substr($message, 0, -1);
-
- $line = explode($this->LE, $message);
- $message = "";
- for ($i=0 ;$i < count($line); $i++)
- {
- $line_part = explode(" ", $line[$i]);
- $buf = "";
- for ($e = 0; $e<count($line_part); $e++)
- {
- $word = $line_part[$e];
- if ($qp_mode and (strlen($word) > $length))
- {
- $space_left = $length - strlen($buf) - 1;
- if ($e != 0)
- {
- if ($space_left > 20)
- {
- $len = $space_left;
- if (substr($word, $len - 1, 1) == "=")
- $len--;
- elseif (substr($word, $len - 2, 1) == "=")
- $len -= 2;
- $part = substr($word, 0, $len);
- $word = substr($word, $len);
- $buf .= " " . $part;
- $message .= $buf . sprintf("=%s", $this->LE);
- }
- else
- {
- $message .= $buf . $soft_break;
- }
- $buf = "";
- }
- while (strlen($word) > 0)
- {
- $len = $length;
- if (substr($word, $len - 1, 1) == "=")
- $len--;
- elseif (substr($word, $len - 2, 1) == "=")
- $len -= 2;
- $part = substr($word, 0, $len);
- $word = substr($word, $len);
-
- if (strlen($word) > 0)
- $message .= $part . sprintf("=%s", $this->LE);
- else
- $buf = $part;
- }
- }
- else
- {
- $buf_o = $buf;
- $buf .= ($e == 0) ? $word : (" " . $word);
-
- if (strlen($buf) > $length and $buf_o != "")
- {
- $message .= $buf_o . $soft_break;
- $buf = $word;
- }
- }
- }
- $message .= $buf . $this->LE;
- }
-
- return $message;
- }
-
- /**
- * Set the body wrapping.
- * @access private
- * @return void
- */
- function SetWordWrap() {
- if($this->WordWrap < 1)
- return;
-
- switch($this->message_type)
- {
- case "alt":
- // fall through
- case "alt_attachment":
- $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
- break;
- default:
- $this->Body = $this->WrapText($this->Body, $this->WordWrap);
- break;
- }
- }
-
- /**
- * Assembles message header.
- * @access private
- * @return string
- */
- function CreateHeader() {
- $result = "";
-
- // Set the boundaries
- $uniq_id = md5(uniqid(time()));
- $this->boundary[1] = "b1_" . $uniq_id;
- $this->boundary[2] = "b2_" . $uniq_id;
-
- $result .= $this->Received();
- $result .= $this->HeaderLine("Date", $this->RFCDate());
- if($this->Sender == "")
- $result .= $this->HeaderLine("Return-Path", trim($this->From));
- else
- $result .= $this->HeaderLine("Return-Path", trim($this->Sender));
-
- // To be created automatically by mail()
- if($this->Mailer != "mail")
- {
- if(count($this->to) > 0)
- $result .= $this->AddrAppend("To", $this->to);
- else if (count($this->cc) == 0)
- $result .= $this->HeaderLine("To", "undisclosed-recipients:;");
- if(count($this->cc) > 0)
- $result .= $this->AddrAppend("Cc", $this->cc);
- }
-
- $from = array();
- $from[0][0] = trim($this->From);
- $from[0][1] = $this->FromName;
- $result .= $this->AddrAppend("From", $from);
-
- // sendmail and mail() extract Bcc from the header before sending
- if((($this->Mailer == "sendmail") || ($this->Mailer == "mail")) && (count($this->bcc) > 0))
- $result .= $this->AddrAppend("Bcc", $this->bcc);
-
- if(count($this->ReplyTo) > 0)
- $result .= $this->AddrAppend("Reply-to", $this->ReplyTo);
-
- // mail() sets the subject itself
- if($this->Mailer != "mail")
- $result .= $this->HeaderLine("Subject", $this->EncodeHeader(trim($this->Subject)));
-
- $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
- $result .= $this->HeaderLine("X-Priority", $this->Priority);
- $result .= $this->HeaderLine("X-Mailer", "PHPMailer [version " . $this->Version . "]");
-
- if($this->ConfirmReadingTo != "")
- {
- $result .= $this->HeaderLine("Disposition-Notification-To",
- "<" . trim($this->ConfirmReadingTo) . ">");
- }
-
- // Add custom headers
- for($index = 0; $index < count($this->CustomHeader); $index++)
- {
- $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]),
- $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
- }
- $result .= $this->HeaderLine("MIME-Version", "1.0");
-
- switch($this->message_type)
- {
- case "plain":
- $result .= $this->HeaderLine("Content-Transfer-Encoding", $this->Encoding);
- $result .= sprintf("Content-Type: %s; charset=\"%s\"",
- $this->ContentType, $this->CharSet);
- break;
- case "attachments":
- // fall through
- case "alt_attachments":
- if($this->InlineImageExists())
- {
- $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s",
- "multipart/related", $this->LE, $this->LE,
- $this->boundary[1], $this->LE);
- }
- else
- {
- $result .= $this->HeaderLine("Content-Type", "multipart/mixed;");
- $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
- }
- break;
- case "alt":
- $result .= $this->HeaderLine("Content-Type", "multipart/alternative;");
- $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
- break;
- }
-
- if($this->Mailer != "mail")
- $result .= $this->LE.$this->LE;
-
- return $result;
- }
-
- /**
- * Assembles the message body. Returns an empty string on failure.
- * @access private
- * @return string
- */
- function CreateBody() {
- $result = "";
-
- $this->SetWordWrap();
-
- switch($this->message_type)
- {
- case "alt":
- $result .= $this->GetBoundary($this->boundary[1], "",
- "text/plain", "");
- $result .= $this->EncodeString($this->AltBody, $this->Encoding);
- $result .= $this->LE.$this->LE;
- $result .= $this->GetBoundary($this->boundary[1], "",
- "text/html", "");
-
- $result .= $this->EncodeString($this->Body, $this->Encoding);
- $result .= $this->LE.$this->LE;
-
- $result .= $this->EndBoundary($this->boundary[1]);
- break;
- case "plain":
- $result .= $this->EncodeString($this->Body, $this->Encoding);
- break;
- case "attachments":
- $result .= $this->GetBoundary($this->boundary[1], "", "", "");
- $result .= $this->EncodeString($this->Body, $this->Encoding);
- $result .= $this->LE;
-
- $result .= $this->AttachAll();
- break;
- case "alt_attachments":
- $result .= sprintf("--%s%s", $this->boundary[1], $this->LE);
- $result .= sprintf("Content-Type: %s;%s" .
- "\tboundary=\"%s\"%s",
- "multipart/alternative", $this->LE,
- $this->boundary[2], $this->LE.$this->LE);
-
- // Create text body
- $result .= $this->GetBoundary($this->boundary[2], "",
- "text/plain", "") . $this->LE;
-
- $result .= $this->EncodeString($this->AltBody, $this->Encoding);
- $result .= $this->LE.$this->LE;
-
- // Create the HTML body
- $result .= $this->GetBoundary($this->boundary[2], "",
- "text/html", "") . $this->LE;
-
- $result .= $this->EncodeString($this->Body, $this->Encoding);
- $result .= $this->LE.$this->LE;
-
- $result .= $this->EndBoundary($this->boundary[2]);
-
- $result .= $this->AttachAll();
- break;
- }
- if($this->IsError())
- $result = "";
-
- return $result;
- }
-
- /**
- * Returns the start of a message boundary.
- * @access private
- */
- function GetBoundary($boundary, $charSet, $contentType, $encoding) {
- $result = "";
- if($charSet == "") { $charSet = $this->CharSet; }
- if($contentType == "") { $contentType = $this->ContentType; }
- if($encoding == "") { $encoding = $this->Encoding; }
-
- $result .= $this->TextLine("--" . $boundary);
- $result .= sprintf("Content-Type: %s; charset = \"%s\"",
- $contentType, $charSet);
- $result .= $this->LE;
- $result .= $this->HeaderLine("Content-Transfer-Encoding", $encoding);
- $result .= $this->LE;
-
- return $result;
- }
-
- /**
- * Returns the end of a message boundary.
- * @access private
- */
- function EndBoundary($boundary) {
- return $this->LE . "--" . $boundary . "--" . $this->LE;
- }
-
- /**
- * Sets the message type.
- * @access private
- * @return void
- */
- function SetMessageType() {
- if(count($this->attachment) < 1 && strlen($this->AltBody) < 1)
- $this->message_type = "plain";
- else
- {
- if(count($this->attachment) > 0)
- $this->message_type = "attachments";
- if(strlen($this->AltBody) > 0 && count($this->attachment) < 1)
- $this->message_type = "alt";
- if(strlen($this->AltBody) > 0 && count($this->attachment) > 0)
- $this->message_type = "alt_attachments";
- }
- }
-
- /**
- * Returns a formatted header line.
- * @access private
- * @return string
- */
- function HeaderLine($name, $value) {
- return $name . ": " . $value . $this->LE;
- }
-
- /**
- * Returns a formatted mail line.
- * @access private
- * @return string
- */
- function TextLine($value) {
- return $value . $this->LE;
- }
-
- /////////////////////////////////////////////////
- // ATTACHMENT METHODS
- /////////////////////////////////////////////////
-
- /**
- * Adds an attachment from a path on the filesystem.
- * Returns false if the file could not be found
- * or accessed.
- * @param string $path Path to the attachment.
- * @param string $name Overrides the attachment name.
- * @param string $encoding File encoding (see $Encoding).
- * @param string $type File extension (MIME) type.
- * @return bool
- */
- function AddAttachment($path, $name = "", $encoding = "base64",
- $type = "application/octet-stream") {
- if(!@is_file($path))
- {
- $this->SetError($this->Lang("file_access") . $path);
- return false;
- }
-
- $filename = basename($path);
- if($name == "")
- $name = $filename;
-
- $cur = count($this->attachment);
- $this->attachment[$cur][0] = $path;
- $this->attachment[$cur][1] = $filename;
- $this->attachment[$cur][2] = $name;
- $this->attachment[$cur][3] = $encoding;
- $this->attachment[$cur][4] = $type;
- $this->attachment[$cur][5] = false; // isStringAttachment
- $this->attachment[$cur][6] = "attachment";
- $this->attachment[$cur][7] = 0;
-
- return true;
- }
-
- /**
- * Attaches all fs, string, and binary attachments to the message.
- * Returns an empty string on failure.
- * @access private
- * @return string
- */
- function AttachAll() {
- // Return text of body
- $mime = array();
-
- // Add all attachments
- for($i = 0; $i < count($this->attachment); $i++)
- {
- // Check for string attachment
- $bString = $this->attachment[$i][5];
- if ($bString)
- $string = $this->attachment[$i][0];
- else
- $path = $this->attachment[$i][0];
-
- $filename = $this->attachment[$i][1];
- $name = $this->attachment[$i][2];
- $encoding = $this->attachment[$i][3];
- $type = $this->attachment[$i][4];
- $disposition = $this->attachment[$i][6];
- $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-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);
-
- // Encode as string attachment
- if($bString)
- {
- $mime[] = $this->EncodeString($string, $encoding);
- if($this->IsError()) { return ""; }
- $mime[] = $this->LE.$this->LE;
- }
- else
- {
- $mime[] = $this->EncodeFile($path, $encoding);
- if($this->IsError()) { return ""; }
- $mime[] = $this->LE.$this->LE;
- }
- }
-
- $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE);
-
- return join("", $mime);
- }
-
- /**
- * Encodes attachment in requested format. Returns an
- * empty string on failure.
- * @access private
- * @return string
- */
- function EncodeFile ($path, $encoding = "base64") {
- if(!@$fd = fopen($path, "rb"))
- {
- $this->SetError($this->Lang("file_open") . $path);
- return "";
- }
- $file_buffer = fread($fd, filesize($path));
- $file_buffer = $this->EncodeString($file_buffer, $encoding);
- fclose($fd);
-
- return $file_buffer;
- }
-
- /**
- * Encodes string to requested format. Returns an
- * empty string on failure.
- * @access private
- * @return string
- */
- function EncodeString ($str, $encoding = "base64") {
- $encoded = "";
- switch(strtolower($encoding)) {
- case "base64":
- // chunk_split is found in PHP >= 3.0.6
- $encoded = chunk_split(base64_encode($str), 76, $this->LE);
- break;
- case "7bit":
- case "8bit":
- $encoded = $this->FixEOL($str);
- if (substr($encoded, -(strlen($this->LE))) != $this->LE)
- $encoded .= $this->LE;
- break;
- case "binary":
- $encoded = $str;
- break;
- case "quoted-printable":
- $encoded = $this->EncodeQP($str);
- break;
- default:
- $this->SetError($this->Lang("encoding") . $encoding);
- break;
- }
- return $encoded;
- }
-
- /**
- * Encode a header string to best of Q, B, quoted or none.
- * @access private
- * @return string
- */
- function EncodeHeader ($str, $position = 'text') {
- $x = 0;
-
- switch (strtolower($position)) {
- case 'phrase':
- if (!preg_match('/[\200-\377]/', $str)) {
- // Can't use addslashes as we don't know what value has magic_quotes_sybase.
- $encoded = addcslashes($str, "\0..\37\177\\\"");
-
- if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str))
- return ($encoded);
- else
- return ("\"$encoded\"");
- }
- $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
- break;
- case 'comment':
- $x = preg_match_all('/[()"]/', $str, $matches);
- // Fall-through
- case 'text':
- default:
- $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
- break;
- }
-
- if ($x == 0)
- return ($str);
-
- $maxlen = 75 - 7 - strlen($this->CharSet);
- // Try to select the encoding which should produce the shortest output
- if (strlen($str)/3 < $x) {
- $encoding = 'B';
- $encoded = base64_encode($str);
- $maxlen -= $maxlen % 4;
- $encoded = trim(chunk_split($encoded, $maxlen, "\n"));
- } else {
- $encoding = 'Q';
- $encoded = $this->EncodeQ($str, $position);
- $encoded = $this->WrapText($encoded, $maxlen, true);
- $encoded = str_replace("=".$this->LE, "\n", trim($encoded));
- }
-
- $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
- $encoded = trim(str_replace("\n", $this->LE, $encoded));
-
- return $encoded;
- }
-
- /**
- * Encode string to quoted-printable.
- * @access private
- * @return string
- */
- function EncodeQP ($str) {
- $encoded = $this->FixEOL($str);
- if (substr($encoded, -(strlen($this->LE))) != $this->LE)
- $encoded .= $this->LE;
-
- // Replace every high ascii, control and = characters
- $encoded = preg_replace('/([\000-\010\013\014\016-\037\075\177-\377])/e',
- "'='.sprintf('%02X', ord('\\1'))", $encoded);
- // Replace every spaces and tabs when it's the last character on a line
- $encoded = preg_replace("/([\011\040])".$this->LE."/e",
- "'='.sprintf('%02X', ord('\\1')).'".$this->LE."'", $encoded);
-
- // Maximum line length of 76 characters before CRLF (74 + space + '=')
- $encoded = $this->WrapText($encoded, 74, true);
-
- return $encoded;
- }
-
- /**
- * Encode string to q encoding.
- * @access private
- * @return string
- */
- function EncodeQ ($str, $position = "text") {
- // There should not be any EOL in the string
- $encoded = preg_replace("[\r\n]", "", $str);
-
- switch (strtolower($position)) {
- case "phrase":
- $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
- break;
- case "comment":
- $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
- case "text":
- default:
- // Replace every high ascii, control =, ? and _ characters
- $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
- "'='.sprintf('%02X', ord('\\1'))", $encoded);
- break;
- }
-
- // Replace every spaces to _ (more readable than =20)
- $encoded = str_replace(" ", "_", $encoded);
-
- return $encoded;
- }
-
- /**
- * Adds a string or binary attachment (non-filesystem) to the list.
- * This method can be used to attach ascii or binary data,
- * such as a BLOB record from a database.
- * @param string $string String attachment data.
- * @param string $filename Name of the attachment.
- * @param string $encoding File encoding (see $Encoding).
- * @param string $type File extension (MIME) type.
- * @return void
- */
- function AddStringAttachment($string, $filename, $encoding = "base64",
- $type = "application/octet-stream") {
- // Append to $attachment array
- $cur = count($this->attachment);
- $this->attachment[$cur][0] = $string;
- $this->attachment[$cur][1] = $filename;
- $this->attachment[$cur][2] = $filename;
- $this->attachment[$cur][3] = $encoding;
- $this->attachment[$cur][4] = $type;
- $this->attachment[$cur][5] = true; // isString
- $this->attachment[$cur][6] = "attachment";
- $this->attachment[$cur][7] = 0;
- }
-
- /**
- * Adds an embedded attachment. This can include images, sounds, and
- * just about any other document. Make sure to set the $type to an
- * image type. For JPEG images use "image/jpeg" and for GIF images
- * use "image/gif".
- * @param string $path Path to the attachment.
- * @param string $cid Content ID of the attachment. Use this to identify
- * the Id for accessing the image in an HTML form.
- * @param string $name Overrides the attachment name.
- * @param string $encoding File encoding (see $Encoding).
- * @param string $type File extension (MIME) type.
- * @return bool
- */
- function AddEmbeddedImage($path, $cid, $name = "", $encoding = "base64",
- $type = "application/octet-stream") {
-
- if(!@is_file($path))
- {
- $this->SetError($this->Lang("file_access") . $path);
- return false;
- }
-
- $filename = basename($path);
- if($name == "")
- $name = $filename;
-
- // Append to $attachment array
- $cur = count($this->attachment);
- $this->attachment[$cur][0] = $path;
- $this->attachment[$cur][1] = $filename;
- $this->attachment[$cur][2] = $name;
- $this->attachment[$cur][3] = $encoding;
- $this->attachment[$cur][4] = $type;
- $this->attachment[$cur][5] = false; // isStringAttachment
- $this->attachment[$cur][6] = "inline";
- $this->attachment[$cur][7] = $cid;
-
- return true;
- }
-
- /**
- * Returns true if an inline attachment is present.
- * @access private
- * @return bool
- */
- function InlineImageExists() {
- $result = false;
- for($i = 0; $i < count($this->attachment); $i++)
- {
- if($this->attachment[$i][6] == "inline")
- {
- $result = true;
- break;
- }
- }
-
- return $result;
- }
-
- /////////////////////////////////////////////////
- // MESSAGE RESET METHODS
- /////////////////////////////////////////////////
-
- /**
- * Clears all recipients assigned in the TO array. Returns void.
- * @return void
- */
- function ClearAddresses() {
- $this->to = array();
- }
-
- /**
- * Clears all recipients assigned in the CC array. Returns void.
- * @return void
- */
- function ClearCCs() {
- $this->cc = array();
- }
-
- /**
- * Clears all recipients assigned in the BCC array. Returns void.
- * @return void
- */
- function ClearBCCs() {
- $this->bcc = array();
- }
-
- /**
- * Clears all recipients assigned in the ReplyTo array. Returns void.
- * @return void
- */
- function ClearReplyTos() {
- $this->ReplyTo = array();
- }
-
- /**
- * Clears all recipients assigned in the TO, CC and BCC
- * array. Returns void.
- * @return void
- */
- function ClearAllRecipients() {
- $this->to = array();
- $this->cc = array();
- $this->bcc = array();
- }
-
- /**
- * Clears all previously set filesystem, string, and binary
- * attachments. Returns void.
- * @return void
- */
- function ClearAttachments() {
- $this->attachment = array();
- }
-
- /**
- * Clears all custom headers. Returns void.
- * @return void
- */
- function ClearCustomHeaders() {
- $this->CustomHeader = array();
- }
-
-
- /////////////////////////////////////////////////
- // MISCELLANEOUS METHODS
- /////////////////////////////////////////////////
-
- /**
- * Adds the error message to the error container.
- * Returns void.
- * @access private
- * @return void
- */
- function SetError($msg) {
- $this->error_count++;
- $this->ErrorInfo = $msg;
- }
-
- /**
- * Returns the proper RFC 822 formatted date.
- * @access private
- * @return string
- */
- function RFCDate() {
- $tz = date("Z");
- $tzs = ($tz < 0) ? "-" : "+";
- $tz = abs($tz);
- $tz = ($tz/3600)*100 + ($tz%3600)/60;
- $result = sprintf("%s %s%04d", date("D, j M Y H:i:s"), $tzs, $tz);
-
- return $result;
- }
-
- /**
- * Returns Received header for message tracing.
- * @access private
- * @return string
- */
- function Received() {
- if ($this->ServerVar('SERVER_NAME') != '')
- {
- $protocol = ($this->ServerVar('HTTPS') == 'on') ? 'HTTPS' : 'HTTP';
- $remote = $this->ServerVar('REMOTE_HOST');
- if($remote == "")
- $remote = 'phpmailer';
- $remote .= ' (['.$this->ServerVar('REMOTE_ADDR').'])';
- }
- else
- {
- $protocol = 'local';
- $remote = $this->ServerVar('USER');
- if($remote == '')
- $remote = 'phpmailer';
- }
-
- $result = sprintf("Received: from %s %s\tby %s " .
- "with %s (PHPMailer);%s\t%s%s", $remote, $this->LE,
- $this->ServerHostname(), $protocol, $this->LE,
- $this->RFCDate(), $this->LE);
-
- return $result;
- }
-
- /**
- * Returns the appropriate server variable. Should work with both
- * PHP 4.1.0+ as well as older versions. Returns an empty string
- * if nothing is found.
- * @access private
- * @return mixed
- */
- function ServerVar($varName) {
- global $HTTP_SERVER_VARS;
- global $HTTP_ENV_VARS;
-
- if(!isset($_SERVER))
- {
- $_SERVER = $HTTP_SERVER_VARS;
- if(!isset($_SERVER["REMOTE_ADDR"]))
- $_SERVER = $HTTP_ENV_VARS; // must be Apache
- }
-
- if(isset($_SERVER[$varName]))
- return $_SERVER[$varName];
- else
- return "";
- }
-
- /**
- * Returns the server hostname or 'localhost.localdomain' if unknown.
- * @access private
- * @return string
- */
- function ServerHostname() {
- if ($this->Hostname != "")
- $result = $this->Hostname;
- elseif ($this->ServerVar('SERVER_NAME') != "")
- $result = $this->ServerVar('SERVER_NAME');
- else
- $result = "localhost.localdomain";
-
- return $result;
- }
-
- /**
- * Returns a message in the appropriate language.
- * @access private
- * @return string
- */
- function Lang($key) {
- if(count($this->language) < 1)
- $this->SetLanguage("en"); // set the default language
-
- if(isset($this->language[$key]))
- return $this->language[$key];
- else
- return "Language string failed to load: " . $key;
- }
-
- /**
- * Returns true if an error occurred.
- * @return bool
- */
- function IsError() {
- return ($this->error_count > 0);
- }
-
- /**
- * Changes every end of line from CR or LF to CRLF.
- * @access private
- * @return string
- */
- function FixEOL($str) {
- $str = str_replace("\r\n", "\n", $str);
- $str = str_replace("\r", "\n", $str);
- $str = str_replace("\n", $this->LE, $str);
- return $str;
- }
-
- /**
- * Adds a custom header.
- * @return void
- */
- function AddCustomHeader($custom_header) {
- $this->CustomHeader[] = explode(":", $custom_header, 2);
- }
-}
-
-?>
+<?php
+////////////////////////////////////////////////////
+// PHPMailer - PHP email class
+//
+// Class for sending email using either
+// sendmail, PHP mail(), or SMTP. Methods are
+// based upon the standard AspEmail(tm) classes.
+//
+// Copyright (C) 2001 - 2003 Brent R. Matzelle
+//
+// License: LGPL, see LICENSE
+////////////////////////////////////////////////////
+
+/**
+ * PHPMailer - PHP email transport class
+ * @package PHPMailer
+ * @author Brent R. Matzelle
+ * @copyright 2001 - 2003 Brent R. Matzelle
+ */
+class PHPMailer
+{
+ /////////////////////////////////////////////////
+ // PUBLIC VARIABLES
+ /////////////////////////////////////////////////
+
+ /**
+ * Email priority (1 = High, 3 = Normal, 5 = low).
+ * @var int
+ */
+ var $Priority = 3;
+
+ /**
+ * Sets the CharSet of the message.
+ * @var string
+ */
+ var $CharSet = "iso-8859-1";
+
+ /**
+ * Sets the Content-type of the message.
+ * @var string
+ */
+ var $ContentType = "text/plain";
+
+ /**
+ * Sets the Encoding of the message. Options for this are "8bit",
+ * "7bit", "binary", "base64", and "quoted-printable".
+ * @var string
+ */
+ var $Encoding = "8bit";
+
+ /**
+ * Holds the most recent mailer error message.
+ * @var string
+ */
+ var $ErrorInfo = "";
+
+ /**
+ * Sets the From email address for the message.
+ * @var string
+ */
+ var $From = "root at localhost";
+
+ /**
+ * Sets the From name of the message.
+ * @var string
+ */
+ var $FromName = "Root User";
+
+ /**
+ * Sets the Sender email (Return-Path) of the message. If not empty,
+ * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
+ * @var string
+ */
+ var $Sender = "";
+
+ /**
+ * Sets the Subject of the message.
+ * @var string
+ */
+ var $Subject = "";
+
+ /**
+ * Sets the Body of the message. This can be either an HTML or text body.
+ * If HTML then run IsHTML(true).
+ * @var string
+ */
+ var $Body = "";
+
+ /**
+ * Sets the text-only body of the message. This automatically sets the
+ * email to multipart/alternative. This body can be read by mail
+ * clients that do not have HTML email capability such as mutt. Clients
+ * that can read HTML will view the normal Body.
+ * @var string
+ */
+ var $AltBody = "";
+
+ /**
+ * Sets word wrapping on the body of the message to a given number of
+ * characters.
+ * @var int
+ */
+ var $WordWrap = 0;
+
+ /**
+ * Method to send mail: ("mail", "sendmail", or "smtp").
+ * @var string
+ */
+ var $Mailer = "mail";
+
+ /**
+ * Sets the path of the sendmail program.
+ * @var string
+ */
+ var $Sendmail = "/usr/sbin/sendmail";
+
+ /**
+ * Path to PHPMailer plugins. This is now only useful if the SMTP class
+ * is in a different directory than the PHP include path.
+ * @var string
+ */
+ var $PluginDir = "";
+
+ /**
+ * Holds PHPMailer version.
+ * @var string
+ */
+ var $Version = "1.73";
+
+ /**
+ * Sets the email address that a reading confirmation will be sent.
+ * @var string
+ */
+ var $ConfirmReadingTo = "";
+
+ /**
+ * Sets the hostname to use in Message-Id and Received headers
+ * and as default HELO string. If empty, the value returned
+ * by SERVER_NAME is used or 'localhost.localdomain'.
+ * @var string
+ */
+ var $Hostname = "";
+
+ /////////////////////////////////////////////////
+ // SMTP VARIABLES
+ /////////////////////////////////////////////////
+
+ /**
+ * Sets the SMTP hosts. All hosts must be separated by a
+ * semicolon. You can also specify a different port
+ * for each host by using this format: [hostname:port]
+ * (e.g. "smtp1.example.com:25;smtp2.example.com").
+ * Hosts will be tried in order.
+ * @var string
+ */
+ var $Host = "localhost";
+
+ /**
+ * Sets the default SMTP server port.
+ * @var int
+ */
+ var $Port = 25;
+
+ /**
+ * Sets the SMTP HELO of the message (Default is $Hostname).
+ * @var string
+ */
+ var $Helo = "";
+
+ /**
+ * Sets SMTP authentication. Utilizes the Username and Password variables.
+ * @var bool
+ */
+ var $SMTPAuth = false;
+
+ /**
+ * Sets SMTP username.
+ * @var string
+ */
+ var $Username = "";
+
+ /**
+ * Sets SMTP password.
+ * @var string
+ */
+ var $Password = "";
+
+ /**
+ * Sets the SMTP server timeout in seconds. This function will not
+ * work with the win32 version.
+ * @var int
+ */
+ var $Timeout = 10;
+
+ /**
+ * Sets SMTP class debugging on or off.
+ * @var bool
+ */
+ var $SMTPDebug = false;
+
+ /**
+ * Prevents the SMTP connection from being closed after each mail
+ * sending. If this is set to true then to close the connection
+ * requires an explicit call to SmtpClose().
+ * @var bool
+ */
+ var $SMTPKeepAlive = false;
+
+ /**#@+
+ * @access private
+ */
+ var $smtp = NULL;
+ var $to = array();
+ var $cc = array();
+ var $bcc = array();
+ var $ReplyTo = array();
+ var $attachment = array();
+ var $CustomHeader = array();
+ var $message_type = "";
+ var $boundary = array();
+ var $language = array();
+ var $error_count = 0;
+ var $LE = "\n";
+ /**#@-*/
+
+ /////////////////////////////////////////////////
+ // VARIABLE METHODS
+ /////////////////////////////////////////////////
+
+ /**
+ * Sets message type to HTML.
+ * @param bool $bool
+ * @return void
+ */
+ function IsHTML($bool) {
+ if($bool == true)
+ $this->ContentType = "text/html";
+ else
+ $this->ContentType = "text/plain";
+ }
+
+ /**
+ * Sets Mailer to send message using SMTP.
+ * @return void
+ */
+ function IsSMTP() {
+ $this->Mailer = "smtp";
+ }
+
+ /**
+ * Sets Mailer to send message using PHP mail() function.
+ * @return void
+ */
+ function IsMail() {
+ $this->Mailer = "mail";
+ }
+
+ /**
+ * Sets Mailer to send message using the $Sendmail program.
+ * @return void
+ */
+ function IsSendmail() {
+ $this->Mailer = "sendmail";
+ }
+
+ /**
+ * Sets Mailer to send message using the qmail MTA.
+ * @return void
+ */
+ function IsQmail() {
+ $this->Sendmail = "/var/qmail/bin/sendmail";
+ $this->Mailer = "sendmail";
+ }
+
+
+ /////////////////////////////////////////////////
+ // RECIPIENT METHODS
+ /////////////////////////////////////////////////
+
+ /**
+ * Adds a "To" address.
+ * @param string $address
+ * @param string $name
+ * @return void
+ */
+ function AddAddress($address, $name = "") {
+ $cur = count($this->to);
+ $this->to[$cur][0] = trim($address);
+ $this->to[$cur][1] = $name;
+ }
+
+ /**
+ * Adds a "Cc" address. Note: this function works
+ * with the SMTP mailer on win32, not with the "mail"
+ * mailer.
+ * @param string $address
+ * @param string $name
+ * @return void
+ */
+ function AddCC($address, $name = "") {
+ $cur = count($this->cc);
+ $this->cc[$cur][0] = trim($address);
+ $this->cc[$cur][1] = $name;
+ }
+
+ /**
+ * Adds a "Bcc" address. Note: this function works
+ * with the SMTP mailer on win32, not with the "mail"
+ * mailer.
+ * @param string $address
+ * @param string $name
+ * @return void
+ */
+ function AddBCC($address, $name = "") {
+ $cur = count($this->bcc);
+ $this->bcc[$cur][0] = trim($address);
+ $this->bcc[$cur][1] = $name;
+ }
+
+ /**
+ * Adds a "Reply-to" address.
+ * @param string $address
+ * @param string $name
+ * @return void
+ */
+ function AddReplyTo($address, $name = "") {
+ $cur = count($this->ReplyTo);
+ $this->ReplyTo[$cur][0] = trim($address);
+ $this->ReplyTo[$cur][1] = $name;
+ }
+
+
+ /////////////////////////////////////////////////
+ // MAIL SENDING METHODS
+ /////////////////////////////////////////////////
+
+ /**
+ * Creates message and assigns Mailer. If the message is
+ * not sent successfully then it returns false. Use the ErrorInfo
+ * variable to view description of the error.
+ * @return bool
+ */
+ function Send() {
+ $header = "";
+ $body = "";
+ $result = true;
+
+ if((count($this->to) + count($this->cc) + count($this->bcc)) < 1)
+ {
+ $this->SetError($this->Lang("provide_address"));
+ return false;
+ }
+
+ // Set whether the message is multipart/alternative
+ if(!empty($this->AltBody))
+ $this->ContentType = "multipart/alternative";
+
+ $this->error_count = 0; // reset errors
+ $this->SetMessageType();
+ $header .= $this->CreateHeader();
+ $body = $this->CreateBody();
+
+ if($body == "") { return false; }
+
+ // Choose the mailer
+ switch($this->Mailer)
+ {
+ case "sendmail":
+ $result = $this->SendmailSend($header, $body);
+ break;
+ case "mail":
+ $result = $this->MailSend($header, $body);
+ break;
+ case "smtp":
+ $result = $this->SmtpSend($header, $body);
+ break;
+ default:
+ $this->SetError($this->Mailer . $this->Lang("mailer_not_supported"));
+ $result = false;
+ break;
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sends mail using the $Sendmail program.
+ * @access private
+ * @return bool
+ */
+ function SendmailSend($header, $body) {
+ if ($this->Sender != "")
+ $sendmail = sprintf("%s -oi -f %s -t", $this->Sendmail, $this->Sender);
+ else
+ $sendmail = sprintf("%s -oi -t", $this->Sendmail);
+
+ if(!@$mail = popen($sendmail, "w"))
+ {
+ $this->SetError($this->Lang("execute") . $this->Sendmail);
+ return false;
+ }
+
+ fputs($mail, $header);
+ fputs($mail, $body);
+
+ $result = pclose($mail) >> 8 & 0xFF;
+ if($result != 0)
+ {
+ $this->SetError($this->Lang("execute") . $this->Sendmail);
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Sends mail using the PHP mail() function.
+ * @access private
+ * @return bool
+ */
+ function MailSend($header, $body) {
+ $to = "";
+ for($i = 0; $i < count($this->to); $i++)
+ {
+ if($i != 0) { $to .= ", "; }
+ $to .= $this->to[$i][0];
+ }
+
+ if ($this->Sender != "" && strlen(ini_get("safe_mode"))< 1)
+ {
+ $old_from = ini_get("sendmail_from");
+ ini_set("sendmail_from", $this->Sender);
+ $params = sprintf("-oi -f %s", $this->Sender);
+ $rt = @mail($to, $this->EncodeHeader($this->Subject), $body,
+ $header, $params);
+ }
+ else
+ $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $header);
+
+ if (isset($old_from))
+ ini_set("sendmail_from", $old_from);
+
+ if(!$rt)
+ {
+ $this->SetError($this->Lang("instantiate"));
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Sends mail via SMTP using PhpSMTP (Author:
+ * Chris Ryan). Returns bool. Returns false if there is a
+ * bad MAIL FROM, RCPT, or DATA input.
+ * @access private
+ * @return bool
+ */
+ function SmtpSend($header, $body) {
+ include_once($this->PluginDir . "class.smtp.php");
+ $error = "";
+ $bad_rcpt = array();
+
+ if(!$this->SmtpConnect())
+ return false;
+
+ $smtp_from = ($this->Sender == "") ? $this->From : $this->Sender;
+ if(!$this->smtp->Mail($smtp_from))
+ {
+ $error = $this->Lang("from_failed") . $smtp_from;
+ $this->SetError($error);
+ $this->smtp->Reset();
+ return false;
+ }
+
+ // Attempt to send attach all recipients
+ for($i = 0; $i < count($this->to); $i++)
+ {
+ if(!$this->smtp->Recipient($this->to[$i][0]))
+ $bad_rcpt[] = $this->to[$i][0];
+ }
+ for($i = 0; $i < count($this->cc); $i++)
+ {
+ if(!$this->smtp->Recipient($this->cc[$i][0]))
+ $bad_rcpt[] = $this->cc[$i][0];
+ }
+ for($i = 0; $i < count($this->bcc); $i++)
+ {
+ if(!$this->smtp->Recipient($this->bcc[$i][0]))
+ $bad_rcpt[] = $this->bcc[$i][0];
+ }
+
+ if(count($bad_rcpt) > 0) // Create error message
+ {
+ for($i = 0; $i < count($bad_rcpt); $i++)
+ {
+ if($i != 0) { $error .= ", "; }
+ $error .= $bad_rcpt[$i];
+ }
+ $error = $this->Lang("recipients_failed") . $error;
+ $this->SetError($error);
+ $this->smtp->Reset();
+ return false;
+ }
+
+ if(!$this->smtp->Data($header . $body))
+ {
+ $this->SetError($this->Lang("data_not_accepted"));
+ $this->smtp->Reset();
+ return false;
+ }
+ if($this->SMTPKeepAlive == true)
+ $this->smtp->Reset();
+ else
+ $this->SmtpClose();
+
+ return true;
+ }
+
+ /**
+ * Initiates a connection to an SMTP server. Returns false if the
+ * operation failed.
+ * @access private
+ * @return bool
+ */
+ function SmtpConnect() {
+ if($this->smtp == NULL) { $this->smtp = new SMTP(); }
+
+ $this->smtp->do_debug = $this->SMTPDebug;
+ $hosts = explode(";", $this->Host);
+ $index = 0;
+ $connection = ($this->smtp->Connected());
+
+ // Retry while there is no connection
+ while($index < count($hosts) && $connection == false)
+ {
+ if(strstr($hosts[$index], ":"))
+ list($host, $port) = explode(":", $hosts[$index]);
+ else
+ {
+ $host = $hosts[$index];
+ $port = $this->Port;
+ }
+
+ if($this->smtp->Connect($host, $port, $this->Timeout))
+ {
+ if ($this->Helo != '')
+ $this->smtp->Hello($this->Helo);
+ else
+ $this->smtp->Hello($this->ServerHostname());
+
+ if($this->SMTPAuth)
+ {
+ if(!$this->smtp->Authenticate($this->Username,
+ $this->Password))
+ {
+ $this->SetError($this->Lang("authenticate"));
+ $this->smtp->Reset();
+ $connection = false;
+ }
+ }
+ $connection = true;
+ }
+ $index++;
+ }
+ if(!$connection)
+ $this->SetError($this->Lang("connect_host"));
+
+ return $connection;
+ }
+
+ /**
+ * Closes the active SMTP session if one exists.
+ * @return void
+ */
+ function SmtpClose() {
+ if($this->smtp != NULL)
+ {
+ if($this->smtp->Connected())
+ {
+ $this->smtp->Quit();
+ $this->smtp->Close();
+ }
+ }
+ }
+
+ /**
+ * Sets the language for all class error messages. Returns false
+ * if it cannot load the language file. The default language type
+ * is English.
+ * @param string $lang_type Type of language (e.g. Portuguese: "br")
+ * @param string $lang_path Path to the language file directory
+ * @access public
+ * @return bool
+ */
+ function SetLanguage($lang_type, $lang_path = "language/") {
+ if(file_exists($lang_path.'phpmailer.lang-'.$lang_type.'.php'))
+ include($lang_path.'phpmailer.lang-'.$lang_type.'.php');
+ else if(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;
+ }
+ $this->language = $PHPMAILER_LANG;
+
+ return true;
+ }
+
+ /////////////////////////////////////////////////
+ // MESSAGE CREATION METHODS
+ /////////////////////////////////////////////////
+
+ /**
+ * Creates recipient headers.
+ * @access private
+ * @return string
+ */
+ function AddrAppend($type, $addr) {
+ $addr_str = $type . ": ";
+ $addr_str .= $this->AddrFormat($addr[0]);
+ if(count($addr) > 1)
+ {
+ for($i = 1; $i < count($addr); $i++)
+ $addr_str .= ", " . $this->AddrFormat($addr[$i]);
+ }
+ $addr_str .= $this->LE;
+
+ return $addr_str;
+ }
+
+ /**
+ * Formats an address correctly.
+ * @access private
+ * @return string
+ */
+ function AddrFormat($addr) {
+ if(empty($addr[1]))
+ $formatted = $addr[0];
+ else
+ {
+ $formatted = $this->EncodeHeader($addr[1], 'phrase') . " <" .
+ $addr[0] . ">";
+ }
+
+ return $formatted;
+ }
+
+ /**
+ * Wraps message for use with mailers that do not
+ * automatically perform wrapping and for quoted-printable.
+ * Original written by philippe.
+ * @access private
+ * @return string
+ */
+ function WrapText($message, $length, $qp_mode = false) {
+ $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
+
+ $message = $this->FixEOL($message);
+ if (substr($message, -1) == $this->LE)
+ $message = substr($message, 0, -1);
+
+ $line = explode($this->LE, $message);
+ $message = "";
+ for ($i=0 ;$i < count($line); $i++)
+ {
+ $line_part = explode(" ", $line[$i]);
+ $buf = "";
+ for ($e = 0; $e<count($line_part); $e++)
+ {
+ $word = $line_part[$e];
+ if ($qp_mode and (strlen($word) > $length))
+ {
+ $space_left = $length - strlen($buf) - 1;
+ if ($e != 0)
+ {
+ if ($space_left > 20)
+ {
+ $len = $space_left;
+ if (substr($word, $len - 1, 1) == "=")
+ $len--;
+ elseif (substr($word, $len - 2, 1) == "=")
+ $len -= 2;
+ $part = substr($word, 0, $len);
+ $word = substr($word, $len);
+ $buf .= " " . $part;
+ $message .= $buf . sprintf("=%s", $this->LE);
+ }
+ else
+ {
+ $message .= $buf . $soft_break;
+ }
+ $buf = "";
+ }
+ while (strlen($word) > 0)
+ {
+ $len = $length;
+ if (substr($word, $len - 1, 1) == "=")
+ $len--;
+ elseif (substr($word, $len - 2, 1) == "=")
+ $len -= 2;
+ $part = substr($word, 0, $len);
+ $word = substr($word, $len);
+
+ if (strlen($word) > 0)
+ $message .= $part . sprintf("=%s", $this->LE);
+ else
+ $buf = $part;
+ }
+ }
+ else
+ {
+ $buf_o = $buf;
+ $buf .= ($e == 0) ? $word : (" " . $word);
+
+ if (strlen($buf) > $length and $buf_o != "")
+ {
+ $message .= $buf_o . $soft_break;
+ $buf = $word;
+ }
+ }
+ }
+ $message .= $buf . $this->LE;
+ }
+
+ return $message;
+ }
+
+ /**
+ * Set the body wrapping.
+ * @access private
+ * @return void
+ */
+ function SetWordWrap() {
+ if($this->WordWrap < 1)
+ return;
+
+ switch($this->message_type)
+ {
+ case "alt":
+ // fall through
+ case "alt_attachments":
+ $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
+ break;
+ default:
+ $this->Body = $this->WrapText($this->Body, $this->WordWrap);
+ break;
+ }
+ }
+
+ /**
+ * Assembles message header.
+ * @access private
+ * @return string
+ */
+ function CreateHeader() {
+ $result = "";
+
+ // Set the boundaries
+ $uniq_id = md5(uniqid(time()));
+ $this->boundary[1] = "b1_" . $uniq_id;
+ $this->boundary[2] = "b2_" . $uniq_id;
+
+ $result .= $this->HeaderLine("Date", $this->RFCDate());
+ if($this->Sender == "")
+ $result .= $this->HeaderLine("Return-Path", trim($this->From));
+ else
+ $result .= $this->HeaderLine("Return-Path", trim($this->Sender));
+
+ // To be created automatically by mail()
+ if($this->Mailer != "mail")
+ {
+ if(count($this->to) > 0)
+ $result .= $this->AddrAppend("To", $this->to);
+ else if (count($this->cc) == 0)
+ $result .= $this->HeaderLine("To", "undisclosed-recipients:;");
+ if(count($this->cc) > 0)
+ $result .= $this->AddrAppend("Cc", $this->cc);
+ }
+
+ $from = array();
+ $from[0][0] = trim($this->From);
+ $from[0][1] = $this->FromName;
+ $result .= $this->AddrAppend("From", $from);
+
+ // sendmail and mail() extract Bcc from the header before sending
+ if((($this->Mailer == "sendmail") || ($this->Mailer == "mail")) && (count($this->bcc) > 0))
+ $result .= $this->AddrAppend("Bcc", $this->bcc);
+
+ if(count($this->ReplyTo) > 0)
+ $result .= $this->AddrAppend("Reply-to", $this->ReplyTo);
+
+ // mail() sets the subject itself
+ if($this->Mailer != "mail")
+ $result .= $this->HeaderLine("Subject", $this->EncodeHeader(trim($this->Subject)));
+
+ $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
+ $result .= $this->HeaderLine("X-Priority", $this->Priority);
+ $result .= $this->HeaderLine("X-Mailer", "PHPMailer [version " . $this->Version . "]");
+
+ if($this->ConfirmReadingTo != "")
+ {
+ $result .= $this->HeaderLine("Disposition-Notification-To",
+ "<" . trim($this->ConfirmReadingTo) . ">");
+ }
+
+ // Add custom headers
+ for($index = 0; $index < count($this->CustomHeader); $index++)
+ {
+ $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]),
+ $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
+ }
+ $result .= $this->HeaderLine("MIME-Version", "1.0");
+
+ switch($this->message_type)
+ {
+ case "plain":
+ $result .= $this->HeaderLine("Content-Transfer-Encoding", $this->Encoding);
+ $result .= sprintf("Content-Type: %s; charset=\"%s\"",
+ $this->ContentType, $this->CharSet);
+ break;
+ case "attachments":
+ // fall through
+ case "alt_attachments":
+ if($this->InlineImageExists())
+ {
+ $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s",
+ "multipart/related", $this->LE, $this->LE,
+ $this->boundary[1], $this->LE);
+ }
+ else
+ {
+ $result .= $this->HeaderLine("Content-Type", "multipart/mixed;");
+ $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
+ }
+ break;
+ case "alt":
+ $result .= $this->HeaderLine("Content-Type", "multipart/alternative;");
+ $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
+ break;
+ }
+
+ if($this->Mailer != "mail")
+ $result .= $this->LE.$this->LE;
+
+ return $result;
+ }
+
+ /**
+ * Assembles the message body. Returns an empty string on failure.
+ * @access private
+ * @return string
+ */
+ function CreateBody() {
+ $result = "";
+
+ $this->SetWordWrap();
+
+ switch($this->message_type)
+ {
+ case "alt":
+ $result .= $this->GetBoundary($this->boundary[1], "",
+ "text/plain", "");
+ $result .= $this->EncodeString($this->AltBody, $this->Encoding);
+ $result .= $this->LE.$this->LE;
+ $result .= $this->GetBoundary($this->boundary[1], "",
+ "text/html", "");
+
+ $result .= $this->EncodeString($this->Body, $this->Encoding);
+ $result .= $this->LE.$this->LE;
+
+ $result .= $this->EndBoundary($this->boundary[1]);
+ break;
+ case "plain":
+ $result .= $this->EncodeString($this->Body, $this->Encoding);
+ break;
+ case "attachments":
+ $result .= $this->GetBoundary($this->boundary[1], "", "", "");
+ $result .= $this->EncodeString($this->Body, $this->Encoding);
+ $result .= $this->LE;
+
+ $result .= $this->AttachAll();
+ break;
+ case "alt_attachments":
+ $result .= sprintf("--%s%s", $this->boundary[1], $this->LE);
+ $result .= sprintf("Content-Type: %s;%s" .
+ "\tboundary=\"%s\"%s",
+ "multipart/alternative", $this->LE,
+ $this->boundary[2], $this->LE.$this->LE);
+
+ // Create text body
+ $result .= $this->GetBoundary($this->boundary[2], "",
+ "text/plain", "") . $this->LE;
+
+ $result .= $this->EncodeString($this->AltBody, $this->Encoding);
+ $result .= $this->LE.$this->LE;
+
+ // Create the HTML body
+ $result .= $this->GetBoundary($this->boundary[2], "",
+ "text/html", "") . $this->LE;
+
+ $result .= $this->EncodeString($this->Body, $this->Encoding);
+ $result .= $this->LE.$this->LE;
+
+ $result .= $this->EndBoundary($this->boundary[2]);
+
+ $result .= $this->AttachAll();
+ break;
+ }
+ if($this->IsError())
+ $result = "";
+
+ return $result;
+ }
+
+ /**
+ * Returns the start of a message boundary.
+ * @access private
+ */
+ function GetBoundary($boundary, $charSet, $contentType, $encoding) {
+ $result = "";
+ if($charSet == "") { $charSet = $this->CharSet; }
+ if($contentType == "") { $contentType = $this->ContentType; }
+ if($encoding == "") { $encoding = $this->Encoding; }
+
+ $result .= $this->TextLine("--" . $boundary);
+ $result .= sprintf("Content-Type: %s; charset = \"%s\"",
+ $contentType, $charSet);
+ $result .= $this->LE;
+ $result .= $this->HeaderLine("Content-Transfer-Encoding", $encoding);
+ $result .= $this->LE;
+
+ return $result;
+ }
+
+ /**
+ * Returns the end of a message boundary.
+ * @access private
+ */
+ function EndBoundary($boundary) {
+ return $this->LE . "--" . $boundary . "--" . $this->LE;
+ }
+
+ /**
+ * Sets the message type.
+ * @access private
+ * @return void
+ */
+ function SetMessageType() {
+ if(count($this->attachment) < 1 && strlen($this->AltBody) < 1)
+ $this->message_type = "plain";
+ else
+ {
+ if(count($this->attachment) > 0)
+ $this->message_type = "attachments";
+ if(strlen($this->AltBody) > 0 && count($this->attachment) < 1)
+ $this->message_type = "alt";
+ if(strlen($this->AltBody) > 0 && count($this->attachment) > 0)
+ $this->message_type = "alt_attachments";
+ }
+ }
+
+ /**
+ * Returns a formatted header line.
+ * @access private
+ * @return string
+ */
+ function HeaderLine($name, $value) {
+ return $name . ": " . $value . $this->LE;
+ }
+
+ /**
+ * Returns a formatted mail line.
+ * @access private
+ * @return string
+ */
+ function TextLine($value) {
+ return $value . $this->LE;
+ }
+
+ /////////////////////////////////////////////////
+ // ATTACHMENT METHODS
+ /////////////////////////////////////////////////
+
+ /**
+ * Adds an attachment from a path on the filesystem.
+ * Returns false if the file could not be found
+ * or accessed.
+ * @param string $path Path to the attachment.
+ * @param string $name Overrides the attachment name.
+ * @param string $encoding File encoding (see $Encoding).
+ * @param string $type File extension (MIME) type.
+ * @return bool
+ */
+ function AddAttachment($path, $name = "", $encoding = "base64",
+ $type = "application/octet-stream") {
+ if(!@is_file($path))
+ {
+ $this->SetError($this->Lang("file_access") . $path);
+ return false;
+ }
+
+ $filename = basename($path);
+ if($name == "")
+ $name = $filename;
+
+ $cur = count($this->attachment);
+ $this->attachment[$cur][0] = $path;
+ $this->attachment[$cur][1] = $filename;
+ $this->attachment[$cur][2] = $name;
+ $this->attachment[$cur][3] = $encoding;
+ $this->attachment[$cur][4] = $type;
+ $this->attachment[$cur][5] = false; // isStringAttachment
+ $this->attachment[$cur][6] = "attachment";
+ $this->attachment[$cur][7] = 0;
+
+ return true;
+ }
+
+ /**
+ * Attaches all fs, string, and binary attachments to the message.
+ * Returns an empty string on failure.
+ * @access private
+ * @return string
+ */
+ function AttachAll() {
+ // Return text of body
+ $mime = array();
+
+ // Add all attachments
+ for($i = 0; $i < count($this->attachment); $i++)
+ {
+ // Check for string attachment
+ $bString = $this->attachment[$i][5];
+ if ($bString)
+ $string = $this->attachment[$i][0];
+ else
+ $path = $this->attachment[$i][0];
+
+ $filename = $this->attachment[$i][1];
+ $name = $this->attachment[$i][2];
+ $encoding = $this->attachment[$i][3];
+ $type = $this->attachment[$i][4];
+ $disposition = $this->attachment[$i][6];
+ $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-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);
+
+ // Encode as string attachment
+ if($bString)
+ {
+ $mime[] = $this->EncodeString($string, $encoding);
+ if($this->IsError()) { return ""; }
+ $mime[] = $this->LE.$this->LE;
+ }
+ else
+ {
+ $mime[] = $this->EncodeFile($path, $encoding);
+ if($this->IsError()) { return ""; }
+ $mime[] = $this->LE.$this->LE;
+ }
+ }
+
+ $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE);
+
+ return join("", $mime);
+ }
+
+ /**
+ * Encodes attachment in requested format. Returns an
+ * empty string on failure.
+ * @access private
+ * @return string
+ */
+ function EncodeFile ($path, $encoding = "base64") {
+ if(!@$fd = fopen($path, "rb"))
+ {
+ $this->SetError($this->Lang("file_open") . $path);
+ return "";
+ }
+ $magic_quotes = get_magic_quotes_runtime();
+ set_magic_quotes_runtime(0);
+ $file_buffer = fread($fd, filesize($path));
+ $file_buffer = $this->EncodeString($file_buffer, $encoding);
+ fclose($fd);
+ set_magic_quotes_runtime($magic_quotes);
+
+ return $file_buffer;
+ }
+
+ /**
+ * Encodes string to requested format. Returns an
+ * empty string on failure.
+ * @access private
+ * @return string
+ */
+ function EncodeString ($str, $encoding = "base64") {
+ $encoded = "";
+ switch(strtolower($encoding)) {
+ case "base64":
+ // chunk_split is found in PHP >= 3.0.6
+ $encoded = chunk_split(base64_encode($str), 76, $this->LE);
+ break;
+ case "7bit":
+ case "8bit":
+ $encoded = $this->FixEOL($str);
+ if (substr($encoded, -(strlen($this->LE))) != $this->LE)
+ $encoded .= $this->LE;
+ break;
+ case "binary":
+ $encoded = $str;
+ break;
+ case "quoted-printable":
+ $encoded = $this->EncodeQP($str);
+ break;
+ default:
+ $this->SetError($this->Lang("encoding") . $encoding);
+ break;
+ }
+ return $encoded;
+ }
+
+ /**
+ * Encode a header string to best of Q, B, quoted or none.
+ * @access private
+ * @return string
+ */
+ function EncodeHeader ($str, $position = 'text') {
+ $x = 0;
+
+ switch (strtolower($position)) {
+ case 'phrase':
+ if (!preg_match('/[\200-\377]/', $str)) {
+ // Can't use addslashes as we don't know what value has magic_quotes_sybase.
+ $encoded = addcslashes($str, "\0..\37\177\\\"");
+
+ if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str))
+ return ($encoded);
+ else
+ return ("\"$encoded\"");
+ }
+ $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
+ break;
+ case 'comment':
+ $x = preg_match_all('/[()"]/', $str, $matches);
+ // Fall-through
+ case 'text':
+ default:
+ $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
+ break;
+ }
+
+ if ($x == 0)
+ return ($str);
+
+ $maxlen = 75 - 7 - strlen($this->CharSet);
+ // Try to select the encoding which should produce the shortest output
+ if (strlen($str)/3 < $x) {
+ $encoding = 'B';
+ $encoded = base64_encode($str);
+ $maxlen -= $maxlen % 4;
+ $encoded = trim(chunk_split($encoded, $maxlen, "\n"));
+ } else {
+ $encoding = 'Q';
+ $encoded = $this->EncodeQ($str, $position);
+ $encoded = $this->WrapText($encoded, $maxlen, true);
+ $encoded = str_replace("=".$this->LE, "\n", trim($encoded));
+ }
+
+ $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
+ $encoded = trim(str_replace("\n", $this->LE, $encoded));
+
+ return $encoded;
+ }
+
+ /**
+ * Encode string to quoted-printable.
+ * @access private
+ * @return string
+ */
+ function EncodeQP ($str) {
+ $encoded = $this->FixEOL($str);
+ if (substr($encoded, -(strlen($this->LE))) != $this->LE)
+ $encoded .= $this->LE;
+
+ // Replace every high ascii, control and = characters
+ $encoded = preg_replace('/([\000-\010\013\014\016-\037\075\177-\377])/e',
+ "'='.sprintf('%02X', ord('\\1'))", $encoded);
+ // Replace every spaces and tabs when it's the last character on a line
+ $encoded = preg_replace("/([\011\040])".$this->LE."/e",
+ "'='.sprintf('%02X', ord('\\1')).'".$this->LE."'", $encoded);
+
+ // Maximum line length of 76 characters before CRLF (74 + space + '=')
+ $encoded = $this->WrapText($encoded, 74, true);
+
+ return $encoded;
+ }
+
+ /**
+ * Encode string to q encoding.
+ * @access private
+ * @return string
+ */
+ function EncodeQ ($str, $position = "text") {
+ // There should not be any EOL in the string
+ $encoded = preg_replace("[\r\n]", "", $str);
+
+ switch (strtolower($position)) {
+ case "phrase":
+ $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
+ break;
+ case "comment":
+ $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
+ case "text":
+ default:
+ // Replace every high ascii, control =, ? and _ characters
+ $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
+ "'='.sprintf('%02X', ord('\\1'))", $encoded);
+ break;
+ }
+
+ // Replace every spaces to _ (more readable than =20)
+ $encoded = str_replace(" ", "_", $encoded);
+
+ return $encoded;
+ }
+
+ /**
+ * Adds a string or binary attachment (non-filesystem) to the list.
+ * This method can be used to attach ascii or binary data,
+ * such as a BLOB record from a database.
+ * @param string $string String attachment data.
+ * @param string $filename Name of the attachment.
+ * @param string $encoding File encoding (see $Encoding).
+ * @param string $type File extension (MIME) type.
+ * @return void
+ */
+ function AddStringAttachment($string, $filename, $encoding = "base64",
+ $type = "application/octet-stream") {
+ // Append to $attachment array
+ $cur = count($this->attachment);
+ $this->attachment[$cur][0] = $string;
+ $this->attachment[$cur][1] = $filename;
+ $this->attachment[$cur][2] = $filename;
+ $this->attachment[$cur][3] = $encoding;
+ $this->attachment[$cur][4] = $type;
+ $this->attachment[$cur][5] = true; // isString
+ $this->attachment[$cur][6] = "attachment";
+ $this->attachment[$cur][7] = 0;
+ }
+
+ /**
+ * Adds an embedded attachment. This can include images, sounds, and
+ * just about any other document. Make sure to set the $type to an
+ * image type. For JPEG images use "image/jpeg" and for GIF images
+ * use "image/gif".
+ * @param string $path Path to the attachment.
+ * @param string $cid Content ID of the attachment. Use this to identify
+ * the Id for accessing the image in an HTML form.
+ * @param string $name Overrides the attachment name.
+ * @param string $encoding File encoding (see $Encoding).
+ * @param string $type File extension (MIME) type.
+ * @return bool
+ */
+ function AddEmbeddedImage($path, $cid, $name = "", $encoding = "base64",
+ $type = "application/octet-stream") {
+
+ if(!@is_file($path))
+ {
+ $this->SetError($this->Lang("file_access") . $path);
+ return false;
+ }
+
+ $filename = basename($path);
+ if($name == "")
+ $name = $filename;
+
+ // Append to $attachment array
+ $cur = count($this->attachment);
+ $this->attachment[$cur][0] = $path;
+ $this->attachment[$cur][1] = $filename;
+ $this->attachment[$cur][2] = $name;
+ $this->attachment[$cur][3] = $encoding;
+ $this->attachment[$cur][4] = $type;
+ $this->attachment[$cur][5] = false; // isStringAttachment
+ $this->attachment[$cur][6] = "inline";
+ $this->attachment[$cur][7] = $cid;
+
+ return true;
+ }
+
+ /**
+ * Returns true if an inline attachment is present.
+ * @access private
+ * @return bool
+ */
+ function InlineImageExists() {
+ $result = false;
+ for($i = 0; $i < count($this->attachment); $i++)
+ {
+ if($this->attachment[$i][6] == "inline")
+ {
+ $result = true;
+ break;
+ }
+ }
+
+ return $result;
+ }
+
+ /////////////////////////////////////////////////
+ // MESSAGE RESET METHODS
+ /////////////////////////////////////////////////
+
+ /**
+ * Clears all recipients assigned in the TO array. Returns void.
+ * @return void
+ */
+ function ClearAddresses() {
+ $this->to = array();
+ }
+
+ /**
+ * Clears all recipients assigned in the CC array. Returns void.
+ * @return void
+ */
+ function ClearCCs() {
+ $this->cc = array();
+ }
+
+ /**
+ * Clears all recipients assigned in the BCC array. Returns void.
+ * @return void
+ */
+ function ClearBCCs() {
+ $this->bcc = array();
+ }
+
+ /**
+ * Clears all recipients assigned in the ReplyTo array. Returns void.
+ * @return void
+ */
+ function ClearReplyTos() {
+ $this->ReplyTo = array();
+ }
+
+ /**
+ * Clears all recipients assigned in the TO, CC and BCC
+ * array. Returns void.
+ * @return void
+ */
+ function ClearAllRecipients() {
+ $this->to = array();
+ $this->cc = array();
+ $this->bcc = array();
+ }
+
+ /**
+ * Clears all previously set filesystem, string, and binary
+ * attachments. Returns void.
+ * @return void
+ */
+ function ClearAttachments() {
+ $this->attachment = array();
+ }
+
+ /**
+ * Clears all custom headers. Returns void.
+ * @return void
+ */
+ function ClearCustomHeaders() {
+ $this->CustomHeader = array();
+ }
+
+
+ /////////////////////////////////////////////////
+ // MISCELLANEOUS METHODS
+ /////////////////////////////////////////////////
+
+ /**
+ * Adds the error message to the error container.
+ * Returns void.
+ * @access private
+ * @return void
+ */
+ function SetError($msg) {
+ $this->error_count++;
+ $this->ErrorInfo = $msg;
+ }
+
+ /**
+ * Returns the proper RFC 822 formatted date.
+ * @access private
+ * @return string
+ */
+ function RFCDate() {
+ $tz = date("Z");
+ $tzs = ($tz < 0) ? "-" : "+";
+ $tz = abs($tz);
+ $tz = ($tz/3600)*100 + ($tz%3600)/60;
+ $result = sprintf("%s %s%04d", date("D, j M Y H:i:s"), $tzs, $tz);
+
+ return $result;
+ }
+
+ /**
+ * Returns the appropriate server variable. Should work with both
+ * PHP 4.1.0+ as well as older versions. Returns an empty string
+ * if nothing is found.
+ * @access private
+ * @return mixed
+ */
+ function ServerVar($varName) {
+ global $HTTP_SERVER_VARS;
+ global $HTTP_ENV_VARS;
+
+ if(!isset($_SERVER))
+ {
+ $_SERVER = $HTTP_SERVER_VARS;
+ if(!isset($_SERVER["REMOTE_ADDR"]))
+ $_SERVER = $HTTP_ENV_VARS; // must be Apache
+ }
+
+ if(isset($_SERVER[$varName]))
+ return $_SERVER[$varName];
+ else
+ return "";
+ }
+
+ /**
+ * Returns the server hostname or 'localhost.localdomain' if unknown.
+ * @access private
+ * @return string
+ */
+ function ServerHostname() {
+ if ($this->Hostname != "")
+ $result = $this->Hostname;
+ elseif ($this->ServerVar('SERVER_NAME') != "")
+ $result = $this->ServerVar('SERVER_NAME');
+ else
+ $result = "localhost.localdomain";
+
+ return $result;
+ }
+
+ /**
+ * Returns a message in the appropriate language.
+ * @access private
+ * @return string
+ */
+ function Lang($key) {
+ if(count($this->language) < 1)
+ $this->SetLanguage("en"); // set the default language
+
+ if(isset($this->language[$key]))
+ return $this->language[$key];
+ else
+ return "Language string failed to load: " . $key;
+ }
+
+ /**
+ * Returns true if an error occurred.
+ * @return bool
+ */
+ function IsError() {
+ return ($this->error_count > 0);
+ }
+
+ /**
+ * Changes every end of line from CR or LF to CRLF.
+ * @access private
+ * @return string
+ */
+ function FixEOL($str) {
+ $str = str_replace("\r\n", "\n", $str);
+ $str = str_replace("\r", "\n", $str);
+ $str = str_replace("\n", $this->LE, $str);
+ return $str;
+ }
+
+ /**
+ * Adds a custom header.
+ * @return void
+ */
+ function AddCustomHeader($custom_header) {
+ $this->CustomHeader[] = explode(":", $custom_header, 2);
+ }
+}
+
+?>
\ No newline at end of file
Modified: plog/trunk/class/mail/phpmailer/class.smtp.php
===================================================================
--- plog/trunk/class/mail/phpmailer/class.smtp.php 2006-07-05 15:27:21 UTC (rev 3692)
+++ plog/trunk/class/mail/phpmailer/class.smtp.php 2006-07-05 15:28:43 UTC (rev 3693)
@@ -20,7 +20,6 @@
* to an SMTP server.
* @package PHPMailer
* @author Chris Ryan
- * \ingroup Mail
*/
class SMTP
{
@@ -333,6 +332,12 @@
# smaller lines
while(strlen($line) > $max_line_length) {
$pos = strrpos(substr($line,0,$max_line_length)," ");
+
+ # Patch to fix DOS attack
+ if(!$pos) {
+ $pos = $max_line_length - 1;
+ }
+
$lines_out[] = substr($line,0,$pos);
$line = substr($line,$pos + 1);
# if we are processing headers we need to
Modified: plog/trunk/class/mail/phpmailer/language/phpmailer.lang-en.php
===================================================================
--- plog/trunk/class/mail/phpmailer/language/phpmailer.lang-en.php 2006-07-05 15:27:21 UTC (rev 3692)
+++ plog/trunk/class/mail/phpmailer/language/phpmailer.lang-en.php 2006-07-05 15:28:43 UTC (rev 3693)
@@ -1,23 +1,23 @@
-<?php
-/**
- * PHPMailer language file.
- * English Version
- */
-
-$PHPMAILER_LANG = array();
-
-$PHPMAILER_LANG["provide_address"] = 'You must provide at least one ' .
- 'recipient email address.';
-$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 ' .
- 'recipients failed: ';
-$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: ';
-?>
+<?php
+/**
+ * PHPMailer language file.
+ * English Version
+ */
+
+$PHPMAILER_LANG = array();
+
+$PHPMAILER_LANG["provide_address"] = 'You must provide at least one ' .
+ 'recipient email address.';
+$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 ' .
+ 'recipients failed: ';
+$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: ';
+?>
Modified: plog/trunk/class/test/testrunner.class.php
===================================================================
--- plog/trunk/class/test/testrunner.class.php 2006-07-05 15:27:21 UTC (rev 3692)
+++ plog/trunk/class/test/testrunner.class.php 2006-07-05 15:28:43 UTC (rev 3693)
@@ -90,7 +90,7 @@
}
}
else {
- if ( File::isReadable( $file )) {
+ if ( File::isReadable( $file )) {
if( Glob::fnmatch( $pattern, $file )) {
// add the file only if it matched our pattern
$list[] = $file;
Added: plog/trunk/class/test/tests/mail/emailservice_test.class.php
===================================================================
--- plog/trunk/class/test/tests/mail/emailservice_test.class.php 2006-07-05 15:27:21 UTC (rev 3692)
+++ plog/trunk/class/test/tests/mail/emailservice_test.class.php 2006-07-05 15:28:43 UTC (rev 3693)
@@ -0,0 +1,31 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/test/PHPUnit.php" );
+ include_once( PLOG_CLASS_PATH."class/mail/emailservice.class.php" );
+
+ /**
+ * \ingroup Tests
+ *
+ * Test LifeType's email sending functionality
+ */
+ class EmailService_Test extends PHPUnit_TestCase
+ {
+ function setUp()
+ {
+ $this->service = new EmailService();
+ }
+
+ function testSend()
+ {
+ // build and email message and see that it is set correctly
+ $m = new EmailMessage();
+ $m->setFrom( "lifetype-test at lifetype.net" );
+ $m->setSubject( "Test message" );
+ $m->addTo( "please_set at please.set" );
+ $m->setBody( "This is a test message!" );
+ $m->setCharset( "iso-8859-1" );
+
+ $this->assertTrue( $this->service->sendMessage( $m ), $this->service->getLastErrorMessage());
+ }
+ }
+?>
\ No newline at end of file
Added: plog/trunk/class/test/tests/mail/phpmailer/message.txt
===================================================================
--- plog/trunk/class/test/tests/mail/phpmailer/message.txt 2006-07-05 15:27:21 UTC (rev 3692)
+++ plog/trunk/class/test/tests/mail/phpmailer/message.txt 2006-07-05 15:28:43 UTC (rev 3693)
@@ -0,0 +1,358 @@
+Date: Wed, 5 Jul 2006 17:58:40 +0200
+Return-Path: unit_test at phpmailer.sf.net
+To: Test User <please_set at please.set>
+From: Unit Tester <unit_test at phpmailer.sf.net>
+Reply-to: Reply Guy <no_reply at phpmailer.sf.net>
+Subject: Unit Test: AltBody + Attachment
+Message-ID: <45f870c912a0edda3764ab01d9db6d0f at caladan.local>
+X-Priority: 3
+X-Mailer: PHPMailer [version 1.73]
+MIME-Version: 1.0
+Content-Type: multipart/mixed;
+ boundary="b1_45f870c912a0edda3764ab01d9db6d0f"
+
+
+--b1_45f870c912a0edda3764ab01d9db6d0f
+Content-Type: multipart/alternative;
+ boundary="b2_45f870c912a0edda3764ab01d9db6d0f"
+
+--b2_45f870c912a0edda3764ab01d9db6d0f
+Content-Type: text/plain; charset = "iso-8859-1"
+Content-Transfer-Encoding: 8bit
+
+
+This is the text part of the email.
+
+
+--b2_45f870c912a0edda3764ab01d9db6d0f
+Content-Type: text/html; charset = "iso-8859-1"
+Content-Transfer-Encoding: 8bit
+
+
+This is the <b>HTML</b> part of the email.<br/><br/>---------------------<br/>Unit Test Information<br/>---------------------<br/>phpmailer version: 1.73<br/>Content Type: text/html<br/>Host: localhost<br/>Attachments:<br/><ul><li>Name: phpmailer_test.class.php, Encoding: base64, Type: application/octet-stream<br/></ul><br/>Changes<br/>-------<br/><ul><li>Sender was changed to [unit_test at phpmailer.sf.net]<br/><li>Mailer was changed to [smtp]<br/></ul><br/><br/>
+
+
+
+--b2_45f870c912a0edda3764ab01d9db6d0f--
+--b1_45f870c912a0edda3764ab01d9db6d0f
+Content-Type: application/octet-stream; name="test_attach.txt"
+Content-Transfer-Encoding: base64
+Content-Disposition: attachment; filename="test_attach.txt"
+
+PD9waHANCi8qKioqKioqKioqKioqKioqKioqDQogIFVuaXQgVGVzdA0KICBUeXBlOiBwaHBtYWls
+ZXIgY2xhc3MNCioqKioqKioqKioqKioqKioqKioqLw0KDQppbmNsdWRlX29uY2UoIFBMT0dfQ0xB
+U1NfUEFUSC4iY2xhc3MvdGVzdC9QSFBVbml0LnBocCIgKTsNCmluY2x1ZGVfb25jZSggUExPR19D
+TEFTU19QQVRILiJjbGFzcy9tYWlsL3BocG1haWxlci9jbGFzcy5waHBtYWlsZXIucGhwIiApOw0K
+DQovKioNCiAqIHRoZXNlIHdlcmUgbm90IHBhcnQgb2YgdGhlIG9yaWdpbmF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/phpmailer/phpmailer_test.class.php
===================================================================
--- plog/trunk/class/test/tests/mail/phpmailer/phpmailer_test.class.php 2006-07-05 15:27:21 UTC (rev 3692)
+++ plog/trunk/class/test/tests/mail/phpmailer/phpmailer_test.class.php 2006-07-05 15:28:43 UTC (rev 3693)
@@ -0,0 +1,530 @@
+<?php
+/*******************
+ Unit Test
+ Type: phpmailer class
+********************/
+
+include_once( PLOG_CLASS_PATH."class/test/PHPUnit.php" );
+include_once( PLOG_CLASS_PATH."class/mail/phpmailer/class.phpmailer.php" );
+
+/**
+ * these were not part of the original test suite but had to be added to avoid plenty of issues with files,
+ * folders, paths and mail servers. Please modify them to suit your needs
+ */
+define( "TEST_MAIL_HOST", "localhost" );
+define( "TEST_MAIL_USER", "please_set at please.set" );
+define( "PHPMAILER_TEST_BASE_FOLDER", PLOG_CLASS_PATH."class/test/tests/mail/phpmailer/" );
+
+/**
+ * Performs authentication tests
+ */
+class phpmailer_Test extends PHPUnit_TestCase
+{
+ /**
+ * Holds the default phpmailer instance.
+ * @private
+ * @type object
+ */
+ var $Mail = false;
+
+ /**
+ * Holds the SMTP mail host.
+ * @public
+ * @type string
+ */
+ var $Host = "";
+
+ /**
+ * Holds the change log.
+ * @private
+ * @type string array
+ */
+ var $ChangeLog = array();
+
+ /**
+ * Holds the note log.
+ * @private
+ * @type string array
+ */
+ var $NoteLog = array();
+
+ /**
+ * Class constuctor.
+ */
+ function phpmailerTest($name) {
+ /* must define this constructor */
+ $this->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 at 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 = TEST_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 at phpmailer.sf.net", "Reply Guy");
+ $this->Mail->Sender = "unit_test at phpmailer.sf.net";
+ // set the language or else we'll get silly errors
+ $this->Mail->SetLanguage( 'en', PLOG_CLASS_PATH."class/mail/phpmailer/language/" );
+
+ if(strlen($this->Mail->Host) > 0)
+ $this->Mail->Mailer = "smtp";
+ else
+ {
+ $this->Mail->Mailer = "mail";
+ $this->Sender = "unit_test at phpmailer.sf.net";
+ }
+
+ $this->SetAddress(TEST_MAIL_USER, "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 = "<br/>";
+ $bullet = "<li>";
+ $bullet_start = "<ul>";
+ $bullet_end = "</ul>";
+ }
+ 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->assertTrue($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 at nobody.com", "Nobody (Unit Test)");
+
+ $this->BuildBody();
+ $this->assertTrue($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( PHPMAILER_TEST_BASE_FOLDER."test.png"))
+ {
+ $this->assertTrue(false, $this->Mail->ErrorInfo);
+ return;
+ }
+
+ if(!$this->Mail->AddAttachment( PHPMAILER_TEST_BASE_FOLDER."phpmailer_test.class.php", "test.txt"))
+ {
+ $this->assertTrue(false, $this->Mail->ErrorInfo);
+ return;
+ }
+
+ $this->BuildBody();
+ $this->assertTrue($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->assertTrue($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->assertTrue($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 <b>test message</b> written in HTML. </br>" .
+ "Go to <a href=\"http://phpmailer.sourceforge.net/\">" .
+ "http://phpmailer.sourceforge.net/</a> for new versions of " .
+ "phpmailer. <p/> Thank you!";
+
+ $this->BuildBody();
+ $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
+ }
+
+ /**
+ * Simple HTML and attachment test
+ */
+ function test_HTML_Attachment() {
+
+ $this->Mail->Body = "This is the <b>HTML</b> part of the email.";
+ $this->Mail->Subject .= ": HTML + Attachment";
+ $this->Mail->IsHTML(true);
+
+ if(!$this->Mail->AddAttachment(PHPMAILER_TEST_BASE_FOLDER."phpmailer_test.class.php", "test_attach.txt"))
+ {
+ $this->assertTrue(false, $this->Mail->ErrorInfo);
+ return;
+ }
+
+ $this->BuildBody();
+ $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
+ }
+
+ /**
+ * An embedded attachment test.
+ */
+ function test_Embedded_Image() {
+
+ $this->Mail->Body = "Embedded Image: <img alt=\"phpmailer\" src=\"cid:my-attach\">" .
+ "Here is an image!</a>";
+ $this->Mail->Subject .= ": Embedded Image";
+ $this->Mail->IsHTML(true);
+
+ if(!$this->Mail->AddEmbeddedImage(PHPMAILER_TEST_BASE_FOLDER."test.png", "my-attach", "test.png",
+ "base64", "image/png"))
+ {
+ $this->assertTrue(false, $this->Mail->ErrorInfo);
+ return;
+ }
+
+ $this->BuildBody();
+ $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
+ }
+
+ /**
+ * An embedded attachment test.
+ */
+ function test_Multi_Embedded_Image() {
+
+ $this->Mail->Body = "Embedded Image: <img alt=\"phpmailer\" src=\"cid:my-attach\">" .
+ "Here is an image!</a>";
+ $this->Mail->Subject .= ": Embedded Image + Attachment";
+ $this->Mail->IsHTML(true);
+
+ if(!$this->Mail->AddEmbeddedImage(PHPMAILER_TEST_BASE_FOLDER."test.png", "my-attach", "test.png",
+ "base64", "image/png"))
+ {
+ $this->assertTrue(false, $this->Mail->ErrorInfo);
+ return;
+ }
+
+ if(!$this->Mail->AddAttachment(PHPMAILER_TEST_BASE_FOLDER."phpmailer_test.class.php", "test.txt"))
+ {
+ $this->assertTrue(false, $this->Mail->ErrorInfo);
+ return;
+ }
+
+ $this->BuildBody();
+ $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
+ }
+
+ /**
+ * Simple multipart/alternative test.
+ */
+ function test_AltBody() {
+
+ $this->Mail->Body = "This is the <b>HTML</b> 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->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
+ }
+
+ /**
+ * Simple HTML and attachment test
+ */
+ function test_AltBody_Attachment() {
+
+ $this->Mail->Body = "This is the <b>HTML</b> 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_BASE_FOLDER."phpmailer_test.class.php", "test_attach.txt"))
+ {
+ $this->assertTrue(false, $this->Mail->ErrorInfo);
+ return;
+ }
+
+ $this->BuildBody();
+ $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
+
+ $fp = fopen(PHPMAILER_TEST_BASE_FOLDER."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->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
+
+ $this->Mail->Subject = $subject . ": SMTP 2";
+ $this->assertTrue($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->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
+
+ $this->Mail->Subject = $subject . ": SMTP keep-alive 2";
+ $this->assertTrue($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->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->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(TEST_MAIL_USER);
+ $this->assertTrue($this->Mail->Send(), "Send failed");
+ }
+}
\ No newline at end of file
Property changes on: plog/trunk/class/test/tests/mail/phpmailer/phpmailer_test.class.php
___________________________________________________________________
Name: svn:executable
+ *
Added: plog/trunk/class/test/tests/mail/phpmailer/test.png
===================================================================
(Binary files differ)
Property changes on: plog/trunk/class/test/tests/mail/phpmailer/test.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
More information about the pLog-svn
mailing list