├── PHPMailer ├── .DS_Store ├── .gitignore ├── LICENSE ├── README.md ├── class.phpmailer.php ├── class.pop3.php ├── class.smtp.php ├── extras │ ├── class.html2text.inc │ ├── htmlfilter.php │ └── ntlm_sasl_client.php └── language │ ├── phpmailer.lang-ar.php │ ├── phpmailer.lang-br.php │ ├── phpmailer.lang-ca.php │ ├── phpmailer.lang-ch.php │ ├── phpmailer.lang-cz.php │ ├── phpmailer.lang-de.php │ ├── phpmailer.lang-dk.php │ ├── phpmailer.lang-es.php │ ├── phpmailer.lang-et.php │ ├── phpmailer.lang-fi.php │ ├── phpmailer.lang-fo.php │ ├── phpmailer.lang-fr.php │ ├── phpmailer.lang-hu.php │ ├── phpmailer.lang-it.php │ ├── phpmailer.lang-ja.php │ ├── phpmailer.lang-nl.php │ ├── phpmailer.lang-no.php │ ├── phpmailer.lang-pl.php │ ├── phpmailer.lang-ro.php │ ├── phpmailer.lang-ru.php │ ├── phpmailer.lang-se.php │ ├── phpmailer.lang-sk.php │ ├── phpmailer.lang-tr.php │ ├── phpmailer.lang-zh.php │ └── phpmailer.lang-zh_cn.php ├── config.php ├── cron.php └── template.html /PHPMailer/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dtbaker/php-gmail-auto-reply/a85be9acb690afd08a8f88e2bed07480a283890e/PHPMailer/.DS_Store -------------------------------------------------------------------------------- /PHPMailer/.gitignore: -------------------------------------------------------------------------------- 1 | docs/phpdoc/ 2 | test/message.txt 3 | test/testbootstrap.php 4 | -------------------------------------------------------------------------------- /PHPMailer/LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 2.1, February 1999 3 | 4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 5 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | [This is the first released version of the Lesser GPL. It also counts 10 | as the successor of the GNU Library Public License, version 2, hence 11 | the version number 2.1.] 12 | 13 | Preamble 14 | 15 | The licenses for most software are designed to take away your 16 | freedom to share and change it. By contrast, the GNU General Public 17 | Licenses are intended to guarantee your freedom to share and change 18 | free software--to make sure the software is free for all its users. 19 | 20 | This license, the Lesser General Public License, applies to some 21 | specially designated software packages--typically libraries--of the 22 | Free Software Foundation and other authors who decide to use it. You 23 | can use it too, but we suggest you first think carefully about whether 24 | this license or the ordinary General Public License is the better 25 | strategy to use in any particular case, based on the explanations below. 26 | 27 | When we speak of free software, we are referring to freedom of use, 28 | not price. Our General Public Licenses are designed to make sure that 29 | you have the freedom to distribute copies of free software (and charge 30 | for this service if you wish); that you receive source code or can get 31 | it if you want it; that you can change the software and use pieces of 32 | it in new free programs; and that you are informed that you can do 33 | these things. 34 | 35 | To protect your rights, we need to make restrictions that forbid 36 | distributors to deny you these rights or to ask you to surrender these 37 | rights. These restrictions translate to certain responsibilities for 38 | you if you distribute copies of the library or if you modify it. 39 | 40 | For example, if you distribute copies of the library, whether gratis 41 | or for a fee, you must give the recipients all the rights that we gave 42 | you. You must make sure that they, too, receive or can get the source 43 | code. If you link other code with the library, you must provide 44 | complete object files to the recipients, so that they can relink them 45 | with the library after making changes to the library and recompiling 46 | it. And you must show them these terms so they know their rights. 47 | 48 | We protect your rights with a two-step method: (1) we copyright the 49 | library, and (2) we offer you this license, which gives you legal 50 | permission to copy, distribute and/or modify the library. 51 | 52 | To protect each distributor, we want to make it very clear that 53 | there is no warranty for the free library. Also, if the library is 54 | modified by someone else and passed on, the recipients should know 55 | that what they have is not the original version, so that the original 56 | author's reputation will not be affected by problems that might be 57 | introduced by others. 58 | 59 | Finally, software patents pose a constant threat to the existence of 60 | any free program. We wish to make sure that a company cannot 61 | effectively restrict the users of a free program by obtaining a 62 | restrictive license from a patent holder. Therefore, we insist that 63 | any patent license obtained for a version of the library must be 64 | consistent with the full freedom of use specified in this license. 65 | 66 | Most GNU software, including some libraries, is covered by the 67 | ordinary GNU General Public License. This license, the GNU Lesser 68 | General Public License, applies to certain designated libraries, and 69 | is quite different from the ordinary General Public License. We use 70 | this license for certain libraries in order to permit linking those 71 | libraries into non-free programs. 72 | 73 | When a program is linked with a library, whether statically or using 74 | a shared library, the combination of the two is legally speaking a 75 | combined work, a derivative of the original library. The ordinary 76 | General Public License therefore permits such linking only if the 77 | entire combination fits its criteria of freedom. The Lesser General 78 | Public License permits more lax criteria for linking other code with 79 | the library. 80 | 81 | We call this license the "Lesser" General Public License because it 82 | does Less to protect the user's freedom than the ordinary General 83 | Public License. It also provides other free software developers Less 84 | of an advantage over competing non-free programs. These disadvantages 85 | are the reason we use the ordinary General Public License for many 86 | libraries. However, the Lesser license provides advantages in certain 87 | special circumstances. 88 | 89 | For example, on rare occasions, there may be a special need to 90 | encourage the widest possible use of a certain library, so that it becomes 91 | a de-facto standard. To achieve this, non-free programs must be 92 | allowed to use the library. A more frequent case is that a free 93 | library does the same job as widely used non-free libraries. In this 94 | case, there is little to gain by limiting the free library to free 95 | software only, so we use the Lesser General Public License. 96 | 97 | In other cases, permission to use a particular library in non-free 98 | programs enables a greater number of people to use a large body of 99 | free software. For example, permission to use the GNU C Library in 100 | non-free programs enables many more people to use the whole GNU 101 | operating system, as well as its variant, the GNU/Linux operating 102 | system. 103 | 104 | Although the Lesser General Public License is Less protective of the 105 | users' freedom, it does ensure that the user of a program that is 106 | linked with the Library has the freedom and the wherewithal to run 107 | that program using a modified version of the Library. 108 | 109 | The precise terms and conditions for copying, distribution and 110 | modification follow. Pay close attention to the difference between a 111 | "work based on the library" and a "work that uses the library". The 112 | former contains code derived from the library, whereas the latter must 113 | be combined with the library in order to run. 114 | 115 | GNU LESSER GENERAL PUBLIC LICENSE 116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 117 | 118 | 0. This License Agreement applies to any software library or other 119 | program which contains a notice placed by the copyright holder or 120 | other authorized party saying it may be distributed under the terms of 121 | this Lesser General Public License (also called "this License"). 122 | Each licensee is addressed as "you". 123 | 124 | A "library" means a collection of software functions and/or data 125 | prepared so as to be conveniently linked with application programs 126 | (which use some of those functions and data) to form executables. 127 | 128 | The "Library", below, refers to any such software library or work 129 | which has been distributed under these terms. A "work based on the 130 | Library" means either the Library or any derivative work under 131 | copyright law: that is to say, a work containing the Library or a 132 | portion of it, either verbatim or with modifications and/or translated 133 | straightforwardly into another language. (Hereinafter, translation is 134 | included without limitation in the term "modification".) 135 | 136 | "Source code" for a work means the preferred form of the work for 137 | making modifications to it. For a library, complete source code means 138 | all the source code for all modules it contains, plus any associated 139 | interface definition files, plus the scripts used to control compilation 140 | and installation of the library. 141 | 142 | Activities other than copying, distribution and modification are not 143 | covered by this License; they are outside its scope. The act of 144 | running a program using the Library is not restricted, and output from 145 | such a program is covered only if its contents constitute a work based 146 | on the Library (independent of the use of the Library in a tool for 147 | writing it). Whether that is true depends on what the Library does 148 | and what the program that uses the Library does. 149 | 150 | 1. You may copy and distribute verbatim copies of the Library's 151 | complete source code as you receive it, in any medium, provided that 152 | you conspicuously and appropriately publish on each copy an 153 | appropriate copyright notice and disclaimer of warranty; keep intact 154 | all the notices that refer to this License and to the absence of any 155 | warranty; and distribute a copy of this License along with the 156 | Library. 157 | 158 | You may charge a fee for the physical act of transferring a copy, 159 | and you may at your option offer warranty protection in exchange for a 160 | fee. 161 | 162 | 2. You may modify your copy or copies of the Library or any portion 163 | of it, thus forming a work based on the Library, and copy and 164 | distribute such modifications or work under the terms of Section 1 165 | above, provided that you also meet all of these conditions: 166 | 167 | a) The modified work must itself be a software library. 168 | 169 | b) You must cause the files modified to carry prominent notices 170 | stating that you changed the files and the date of any change. 171 | 172 | c) You must cause the whole of the work to be licensed at no 173 | charge to all third parties under the terms of this License. 174 | 175 | d) If a facility in the modified Library refers to a function or a 176 | table of data to be supplied by an application program that uses 177 | the facility, other than as an argument passed when the facility 178 | is invoked, then you must make a good faith effort to ensure that, 179 | in the event an application does not supply such function or 180 | table, the facility still operates, and performs whatever part of 181 | its purpose remains meaningful. 182 | 183 | (For example, a function in a library to compute square roots has 184 | a purpose that is entirely well-defined independent of the 185 | application. Therefore, Subsection 2d requires that any 186 | application-supplied function or table used by this function must 187 | be optional: if the application does not supply it, the square 188 | root function must still compute square roots.) 189 | 190 | These requirements apply to the modified work as a whole. If 191 | identifiable sections of that work are not derived from the Library, 192 | and can be reasonably considered independent and separate works in 193 | themselves, then this License, and its terms, do not apply to those 194 | sections when you distribute them as separate works. But when you 195 | distribute the same sections as part of a whole which is a work based 196 | on the Library, the distribution of the whole must be on the terms of 197 | this License, whose permissions for other licensees extend to the 198 | entire whole, and thus to each and every part regardless of who wrote 199 | it. 200 | 201 | Thus, it is not the intent of this section to claim rights or contest 202 | your rights to work written entirely by you; rather, the intent is to 203 | exercise the right to control the distribution of derivative or 204 | collective works based on the Library. 205 | 206 | In addition, mere aggregation of another work not based on the Library 207 | with the Library (or with a work based on the Library) on a volume of 208 | a storage or distribution medium does not bring the other work under 209 | the scope of this License. 210 | 211 | 3. You may opt to apply the terms of the ordinary GNU General Public 212 | License instead of this License to a given copy of the Library. To do 213 | this, you must alter all the notices that refer to this License, so 214 | that they refer to the ordinary GNU General Public License, version 2, 215 | instead of to this License. (If a newer version than version 2 of the 216 | ordinary GNU General Public License has appeared, then you can specify 217 | that version instead if you wish.) Do not make any other change in 218 | these notices. 219 | 220 | Once this change is made in a given copy, it is irreversible for 221 | that copy, so the ordinary GNU General Public License applies to all 222 | subsequent copies and derivative works made from that copy. 223 | 224 | This option is useful when you wish to copy part of the code of 225 | the Library into a program that is not a library. 226 | 227 | 4. You may copy and distribute the Library (or a portion or 228 | derivative of it, under Section 2) in object code or executable form 229 | under the terms of Sections 1 and 2 above provided that you accompany 230 | it with the complete corresponding machine-readable source code, which 231 | must be distributed under the terms of Sections 1 and 2 above on a 232 | medium customarily used for software interchange. 233 | 234 | If distribution of object code is made by offering access to copy 235 | from a designated place, then offering equivalent access to copy the 236 | source code from the same place satisfies the requirement to 237 | distribute the source code, even though third parties are not 238 | compelled to copy the source along with the object code. 239 | 240 | 5. A program that contains no derivative of any portion of the 241 | Library, but is designed to work with the Library by being compiled or 242 | linked with it, is called a "work that uses the Library". Such a 243 | work, in isolation, is not a derivative work of the Library, and 244 | therefore falls outside the scope of this License. 245 | 246 | However, linking a "work that uses the Library" with the Library 247 | creates an executable that is a derivative of the Library (because it 248 | contains portions of the Library), rather than a "work that uses the 249 | library". The executable is therefore covered by this License. 250 | Section 6 states terms for distribution of such executables. 251 | 252 | When a "work that uses the Library" uses material from a header file 253 | that is part of the Library, the object code for the work may be a 254 | derivative work of the Library even though the source code is not. 255 | Whether this is true is especially significant if the work can be 256 | linked without the Library, or if the work is itself a library. The 257 | threshold for this to be true is not precisely defined by law. 258 | 259 | If such an object file uses only numerical parameters, data 260 | structure layouts and accessors, and small macros and small inline 261 | functions (ten lines or less in length), then the use of the object 262 | file is unrestricted, regardless of whether it is legally a derivative 263 | work. (Executables containing this object code plus portions of the 264 | Library will still fall under Section 6.) 265 | 266 | Otherwise, if the work is a derivative of the Library, you may 267 | distribute the object code for the work under the terms of Section 6. 268 | Any executables containing that work also fall under Section 6, 269 | whether or not they are linked directly with the Library itself. 270 | 271 | 6. As an exception to the Sections above, you may also combine or 272 | link a "work that uses the Library" with the Library to produce a 273 | work containing portions of the Library, and distribute that work 274 | under terms of your choice, provided that the terms permit 275 | modification of the work for the customer's own use and reverse 276 | engineering for debugging such modifications. 277 | 278 | You must give prominent notice with each copy of the work that the 279 | Library is used in it and that the Library and its use are covered by 280 | this License. You must supply a copy of this License. If the work 281 | during execution displays copyright notices, you must include the 282 | copyright notice for the Library among them, as well as a reference 283 | directing the user to the copy of this License. Also, you must do one 284 | of these things: 285 | 286 | a) Accompany the work with the complete corresponding 287 | machine-readable source code for the Library including whatever 288 | changes were used in the work (which must be distributed under 289 | Sections 1 and 2 above); and, if the work is an executable linked 290 | with the Library, with the complete machine-readable "work that 291 | uses the Library", as object code and/or source code, so that the 292 | user can modify the Library and then relink to produce a modified 293 | executable containing the modified Library. (It is understood 294 | that the user who changes the contents of definitions files in the 295 | Library will not necessarily be able to recompile the application 296 | to use the modified definitions.) 297 | 298 | b) Use a suitable shared library mechanism for linking with the 299 | Library. A suitable mechanism is one that (1) uses at run time a 300 | copy of the library already present on the user's computer system, 301 | rather than copying library functions into the executable, and (2) 302 | will operate properly with a modified version of the library, if 303 | the user installs one, as long as the modified version is 304 | interface-compatible with the version that the work was made with. 305 | 306 | c) Accompany the work with a written offer, valid for at 307 | least three years, to give the same user the materials 308 | specified in Subsection 6a, above, for a charge no more 309 | than the cost of performing this distribution. 310 | 311 | d) If distribution of the work is made by offering access to copy 312 | from a designated place, offer equivalent access to copy the above 313 | specified materials from the same place. 314 | 315 | e) Verify that the user has already received a copy of these 316 | materials or that you have already sent this user a copy. 317 | 318 | For an executable, the required form of the "work that uses the 319 | Library" must include any data and utility programs needed for 320 | reproducing the executable from it. However, as a special exception, 321 | the materials to be distributed need not include anything that is 322 | normally distributed (in either source or binary form) with the major 323 | components (compiler, kernel, and so on) of the operating system on 324 | which the executable runs, unless that component itself accompanies 325 | the executable. 326 | 327 | It may happen that this requirement contradicts the license 328 | restrictions of other proprietary libraries that do not normally 329 | accompany the operating system. Such a contradiction means you cannot 330 | use both them and the Library together in an executable that you 331 | distribute. 332 | 333 | 7. You may place library facilities that are a work based on the 334 | Library side-by-side in a single library together with other library 335 | facilities not covered by this License, and distribute such a combined 336 | library, provided that the separate distribution of the work based on 337 | the Library and of the other library facilities is otherwise 338 | permitted, and provided that you do these two things: 339 | 340 | a) Accompany the combined library with a copy of the same work 341 | based on the Library, uncombined with any other library 342 | facilities. This must be distributed under the terms of the 343 | Sections above. 344 | 345 | b) Give prominent notice with the combined library of the fact 346 | that part of it is a work based on the Library, and explaining 347 | where to find the accompanying uncombined form of the same work. 348 | 349 | 8. You may not copy, modify, sublicense, link with, or distribute 350 | the Library except as expressly provided under this License. Any 351 | attempt otherwise to copy, modify, sublicense, link with, or 352 | distribute the Library is void, and will automatically terminate your 353 | rights under this License. However, parties who have received copies, 354 | or rights, from you under this License will not have their licenses 355 | terminated so long as such parties remain in full compliance. 356 | 357 | 9. You are not required to accept this License, since you have not 358 | signed it. However, nothing else grants you permission to modify or 359 | distribute the Library or its derivative works. These actions are 360 | prohibited by law if you do not accept this License. Therefore, by 361 | modifying or distributing the Library (or any work based on the 362 | Library), you indicate your acceptance of this License to do so, and 363 | all its terms and conditions for copying, distributing or modifying 364 | the Library or works based on it. 365 | 366 | 10. Each time you redistribute the Library (or any work based on the 367 | Library), the recipient automatically receives a license from the 368 | original licensor to copy, distribute, link with or modify the Library 369 | subject to these terms and conditions. You may not impose any further 370 | restrictions on the recipients' exercise of the rights granted herein. 371 | You are not responsible for enforcing compliance by third parties with 372 | this License. 373 | 374 | 11. If, as a consequence of a court judgment or allegation of patent 375 | infringement or for any other reason (not limited to patent issues), 376 | conditions are imposed on you (whether by court order, agreement or 377 | otherwise) that contradict the conditions of this License, they do not 378 | excuse you from the conditions of this License. If you cannot 379 | distribute so as to satisfy simultaneously your obligations under this 380 | License and any other pertinent obligations, then as a consequence you 381 | may not distribute the Library at all. For example, if a patent 382 | license would not permit royalty-free redistribution of the Library by 383 | all those who receive copies directly or indirectly through you, then 384 | the only way you could satisfy both it and this License would be to 385 | refrain entirely from distribution of the Library. 386 | 387 | If any portion of this section is held invalid or unenforceable under any 388 | particular circumstance, the balance of the section is intended to apply, 389 | and the section as a whole is intended to apply in other circumstances. 390 | 391 | It is not the purpose of this section to induce you to infringe any 392 | patents or other property right claims or to contest validity of any 393 | such claims; this section has the sole purpose of protecting the 394 | integrity of the free software distribution system which is 395 | implemented by public license practices. Many people have made 396 | generous contributions to the wide range of software distributed 397 | through that system in reliance on consistent application of that 398 | system; it is up to the author/donor to decide if he or she is willing 399 | to distribute software through any other system and a licensee cannot 400 | impose that choice. 401 | 402 | This section is intended to make thoroughly clear what is believed to 403 | be a consequence of the rest of this License. 404 | 405 | 12. If the distribution and/or use of the Library is restricted in 406 | certain countries either by patents or by copyrighted interfaces, the 407 | original copyright holder who places the Library under this License may add 408 | an explicit geographical distribution limitation excluding those countries, 409 | so that distribution is permitted only in or among countries not thus 410 | excluded. In such case, this License incorporates the limitation as if 411 | written in the body of this License. 412 | 413 | 13. The Free Software Foundation may publish revised and/or new 414 | versions of the Lesser General Public License from time to time. 415 | Such new versions will be similar in spirit to the present version, 416 | but may differ in detail to address new problems or concerns. 417 | 418 | Each version is given a distinguishing version number. If the Library 419 | specifies a version number of this License which applies to it and 420 | "any later version", you have the option of following the terms and 421 | conditions either of that version or of any later version published by 422 | the Free Software Foundation. If the Library does not specify a 423 | license version number, you may choose any version ever published by 424 | the Free Software Foundation. 425 | 426 | 14. If you wish to incorporate parts of the Library into other free 427 | programs whose distribution conditions are incompatible with these, 428 | write to the author to ask for permission. For software which is 429 | copyrighted by the Free Software Foundation, write to the Free 430 | Software Foundation; we sometimes make exceptions for this. Our 431 | decision will be guided by the two goals of preserving the free status 432 | of all derivatives of our free software and of promoting the sharing 433 | and reuse of software generally. 434 | 435 | NO WARRANTY 436 | 437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 446 | 447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 456 | DAMAGES. 457 | 458 | END OF TERMS AND CONDITIONS 459 | 460 | How to Apply These Terms to Your New Libraries 461 | 462 | If you develop a new library, and you want it to be of the greatest 463 | possible use to the public, we recommend making it free software that 464 | everyone can redistribute and change. You can do so by permitting 465 | redistribution under these terms (or, alternatively, under the terms of the 466 | ordinary General Public License). 467 | 468 | To apply these terms, attach the following notices to the library. It is 469 | safest to attach them to the start of each source file to most effectively 470 | convey the exclusion of warranty; and each file should have at least the 471 | "copyright" line and a pointer to where the full notice is found. 472 | 473 | 474 | Copyright (C) 475 | 476 | This library is free software; you can redistribute it and/or 477 | modify it under the terms of the GNU Lesser General Public 478 | License as published by the Free Software Foundation; either 479 | version 2.1 of the License, or (at your option) any later version. 480 | 481 | This library is distributed in the hope that it will be useful, 482 | but WITHOUT ANY WARRANTY; without even the implied warranty of 483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 484 | Lesser General Public License for more details. 485 | 486 | You should have received a copy of the GNU Lesser General Public 487 | License along with this library; if not, write to the Free Software 488 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 489 | 490 | Also add information on how to contact you by electronic and paper mail. 491 | 492 | You should also get your employer (if you work as a programmer) or your 493 | school, if any, to sign a "copyright disclaimer" for the library, if 494 | necessary. Here is a sample; alter the names: 495 | 496 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 497 | library `Frob' (a library for tweaking knobs) written by James Random Hacker. 498 | 499 | , 1 April 1990 500 | Ty Coon, President of Vice 501 | 502 | That's all there is to it! 503 | 504 | 505 | -------------------------------------------------------------------------------- /PHPMailer/README.md: -------------------------------------------------------------------------------- 1 | # PHPMailer - A full-featured email creation and transfer class for PHP 2 | 3 | ## Class Features 4 | 5 | - Probably the world's most popular code for sending email from PHP! 6 | - Used by many open-source projects: Drupal, SugarCRM, Yii, Joomla! and many more 7 | - Integrated SMTP support - send without a local mail server 8 | - Send emails with multiple TOs, CCs, BCCs and REPLY-TOs 9 | - Multipart/alternative emails for mail clients that do not read HTML email 10 | - Support for 8bit, base64, binary, and quoted-printable encoding 11 | - SMTP authentication with LOGIN, PLAIN, NTLM and CRAM-MD5 mechanisms 12 | - Native language support 13 | - Compatible with PHP 5.0 and later 14 | - Much more! 15 | 16 | ## Why you might need it 17 | 18 | Many PHP developers utilize email in their code. The only PHP function that supports this is the mail() function. However, it does not provide any assistance for making use of popular features such as HTML-based emails and attachments. 19 | 20 | Formatting email correctly is surprisingly difficult. There are myriad overlapping RFCs, requiring tight adherence to horribly complicated formatting and encoding rules - the vast majority of code that you'll find online that uses the mail() function directly is just plain wrong! 21 | *Please* don't be tempted to do it yourself - if you don't use PHPMailer, there are many other excellent libraries that you should look at before rolling your own - try SwiftMailer, Zend_Mail, eZcomponents etc. 22 | 23 | The PHP mail() function usually sends via a local mail server, typically fronted by a `sendmail` binary on Linux, BSD and OS X platforms, however, Windows usually doesn't include a local mail server; PHPMailer's integrated SMTP implementation allows email sending on Windows platforms without a local mail server. 24 | 25 | ## License 26 | 27 | This software is licenced under the [LGPL 2.1](http://www.gnu.org/licenses/lgpl-2.1.html). Please read LICENSE for information on the 28 | software availability and distribution. 29 | 30 | ## Installation 31 | 32 | PHPMailer is available via [Composer/Packagist](https://packagist.org/packages/phpmailer/phpmailer). Alternatively, just copy the contents of the PHPMailer folder into somewhere that's in your PHP `include_path` setting. 33 | 34 | 35 | ## A Simple Example 36 | 37 | ```php 38 | IsSMTP(); // Set mailer to use SMTP 44 | $mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup server 45 | $mail->SMTPAuth = true; // Enable SMTP authentication 46 | $mail->Username = 'jswan'; // SMTP username 47 | $mail->Password = 'secret'; // SMTP password 48 | $mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted 49 | 50 | $mail->From = 'from@example.com'; 51 | $mail->FromName = 'Mailer'; 52 | $mail->AddAddress('josh@example.net', 'Josh Adams'); // Add a recipient 53 | $mail->AddAddress('ellen@example.com'); // Name is optional 54 | $mail->AddReplyTo('info@example.com', 'Information'); 55 | $mail->AddCC('cc@example.com'); 56 | $mail->AddBCC('bcc@example.com'); 57 | 58 | $mail->WordWrap = 50; // Set word wrap to 50 characters 59 | $mail->AddAttachment('/var/tmp/file.tar.gz'); // Add attachments 60 | $mail->AddAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name 61 | $mail->IsHTML(true); // Set email format to HTML 62 | 63 | $mail->Subject = 'Here is the subject'; 64 | $mail->Body = 'This is the HTML message body in bold!'; 65 | $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; 66 | 67 | if(!$mail->Send()) { 68 | echo 'Message could not be sent.'; 69 | echo 'Mailer Error: ' . $mail->ErrorInfo; 70 | exit; 71 | } 72 | 73 | echo 'Message has been sent'; 74 | ``` 75 | 76 | You'll find plenty more to play with in the `examples` folder. 77 | 78 | That's it. You should now be ready to use PHPMailer! 79 | 80 | ## Localization 81 | PHPMailer defaults to English, but in the `languages` folder you'll find numerous translations for PHPMailer error messages that you may encounter. Their filenames contain [ISO 639-1](http://en.wikipedia.org/wiki/ISO_639-1) language code for the translations, for example `fr` for French. To specify a language, you need to tell PHPMailer which one to use, like this: 82 | 83 | ```php 84 | // To load the French version 85 | $mail->SetLanguage('fr', '/optional/path/to/language/directory/'); 86 | ``` 87 | 88 | ## Documentation 89 | 90 | You'll find some basic user-level docs in the docs folder, and you can generate complete API-level documentation using the `generatedocs.sh` shell script in the docs folder, though you'll need to install [PHPDocumentor](http://www.phpdoc.org) first. 91 | 92 | ## Tests 93 | 94 | You'll find a PHPUnit test script in the `test` folder. 95 | 96 | ## Contributing 97 | 98 | Please submit bug reports, suggestions and pull requests to the [Google Code tracker](https://code.google.com/a/apache-extras.org/p/phpmailer/issues/list) or the [GitHub issue tracker](https://github.com/Synchro/PHPMailer/issues). 99 | 100 | We're particularly interested in fixing edge-cases, expanding test coverage and updating translations. 101 | 102 | Please *don't* use the sourceforge project any more. 103 | 104 | ## Changelog 105 | 106 | See changelog.md 107 | 108 | ## History 109 | - PHPMailer was originally written in 2001 by Brent R. Matzelle as a [SourceForge project](http://sourceforge.net/projects/phpmailer/). 110 | - Marcus Bointon (coolbru on SF) and Andy Prevost (codeworxtech) took over the project in 2004. 111 | - The project became an [Apache incubator project on Google Code](https://code.google.com/a/apache-extras.org/p/phpmailer/) in 2010, managed by Jim Jagielski 112 | - Marcus maintains a [GitHub repository](https://github.com/Synchro/PHPMailer) that's kept in sync with the Google Code project as far as is practical. 113 | -------------------------------------------------------------------------------- /PHPMailer/class.pop3.php: -------------------------------------------------------------------------------- 1 | 55 | * @author Andy Prevost 56 | * @author Jim Jagielski 57 | */ 58 | 59 | class POP3 { 60 | /** 61 | * Default POP3 port 62 | * @var int 63 | */ 64 | public $POP3_PORT = 110; 65 | 66 | /** 67 | * Default Timeout 68 | * @var int 69 | */ 70 | public $POP3_TIMEOUT = 30; 71 | 72 | /** 73 | * POP3 Carriage Return + Line Feed 74 | * @var string 75 | */ 76 | public $CRLF = "\r\n"; 77 | 78 | /** 79 | * Displaying Debug warnings? (0 = now, 1+ = yes) 80 | * @var int 81 | */ 82 | public $do_debug = 2; 83 | 84 | /** 85 | * POP3 Mail Server 86 | * @var string 87 | */ 88 | public $host; 89 | 90 | /** 91 | * POP3 Port 92 | * @var int 93 | */ 94 | public $port; 95 | 96 | /** 97 | * POP3 Timeout Value 98 | * @var int 99 | */ 100 | public $tval; 101 | 102 | /** 103 | * POP3 Username 104 | * @var string 105 | */ 106 | public $username; 107 | 108 | /** 109 | * POP3 Password 110 | * @var string 111 | */ 112 | public $password; 113 | 114 | /** 115 | * Sets the POP3 PHPMailer Version number 116 | * @var string 117 | */ 118 | public $Version = '5.2.2'; 119 | 120 | ///////////////////////////////////////////////// 121 | // PROPERTIES, PRIVATE AND PROTECTED 122 | ///////////////////////////////////////////////// 123 | 124 | /** 125 | * @var resource Resource handle for the POP connection socket 126 | */ 127 | private $pop_conn; 128 | /** 129 | * @var boolean Are we connected? 130 | */ 131 | private $connected; 132 | /** 133 | * @var array Error container 134 | */ 135 | private $error; // Error log array 136 | 137 | /** 138 | * Constructor, sets the initial values 139 | * @access public 140 | * @return POP3 141 | */ 142 | public function __construct() { 143 | $this->pop_conn = 0; 144 | $this->connected = false; 145 | $this->error = null; 146 | } 147 | 148 | /** 149 | * Combination of public events - connect, login, disconnect 150 | * @access public 151 | * @param string $host 152 | * @param bool|int $port 153 | * @param bool|int $tval 154 | * @param string $username 155 | * @param string $password 156 | * @param int $debug_level 157 | * @return bool 158 | */ 159 | public function Authorise ($host, $port = false, $tval = false, $username, $password, $debug_level = 0) { 160 | $this->host = $host; 161 | 162 | // If no port value is passed, retrieve it 163 | if ($port == false) { 164 | $this->port = $this->POP3_PORT; 165 | } else { 166 | $this->port = $port; 167 | } 168 | 169 | // If no port value is passed, retrieve it 170 | if ($tval == false) { 171 | $this->tval = $this->POP3_TIMEOUT; 172 | } else { 173 | $this->tval = $tval; 174 | } 175 | 176 | $this->do_debug = $debug_level; 177 | $this->username = $username; 178 | $this->password = $password; 179 | 180 | // Refresh the error log 181 | $this->error = null; 182 | 183 | // Connect 184 | $result = $this->Connect($this->host, $this->port, $this->tval); 185 | 186 | if ($result) { 187 | $login_result = $this->Login($this->username, $this->password); 188 | 189 | if ($login_result) { 190 | $this->Disconnect(); 191 | 192 | return true; 193 | } 194 | 195 | } 196 | 197 | // We need to disconnect regardless if the login succeeded 198 | $this->Disconnect(); 199 | 200 | return false; 201 | } 202 | 203 | /** 204 | * Connect to the POP3 server 205 | * @access public 206 | * @param string $host 207 | * @param bool|int $port 208 | * @param integer $tval 209 | * @return boolean 210 | */ 211 | public function Connect ($host, $port = false, $tval = 30) { 212 | // Are we already connected? 213 | if ($this->connected) { 214 | return true; 215 | } 216 | 217 | /* 218 | On Windows this will raise a PHP Warning error if the hostname doesn't exist. 219 | Rather than supress it with @fsockopen, let's capture it cleanly instead 220 | */ 221 | 222 | set_error_handler(array(&$this, 'catchWarning')); 223 | 224 | // Connect to the POP3 server 225 | $this->pop_conn = fsockopen($host, // POP3 Host 226 | $port, // Port # 227 | $errno, // Error Number 228 | $errstr, // Error Message 229 | $tval); // Timeout (seconds) 230 | 231 | // Restore the error handler 232 | restore_error_handler(); 233 | 234 | // Does the Error Log now contain anything? 235 | if ($this->error && $this->do_debug >= 1) { 236 | $this->displayErrors(); 237 | } 238 | 239 | // Did we connect? 240 | if ($this->pop_conn == false) { 241 | // It would appear not... 242 | $this->error = array( 243 | 'error' => "Failed to connect to server $host on port $port", 244 | 'errno' => $errno, 245 | 'errstr' => $errstr 246 | ); 247 | 248 | if ($this->do_debug >= 1) { 249 | $this->displayErrors(); 250 | } 251 | 252 | return false; 253 | } 254 | 255 | // Increase the stream time-out 256 | 257 | // Check for PHP 4.3.0 or later 258 | if (version_compare(phpversion(), '5.0.0', 'ge')) { 259 | stream_set_timeout($this->pop_conn, $tval, 0); 260 | } else { 261 | // Does not work on Windows 262 | if (substr(PHP_OS, 0, 3) !== 'WIN') { 263 | socket_set_timeout($this->pop_conn, $tval, 0); 264 | } 265 | } 266 | 267 | // Get the POP3 server response 268 | $pop3_response = $this->getResponse(); 269 | 270 | // Check for the +OK 271 | if ($this->checkResponse($pop3_response)) { 272 | // The connection is established and the POP3 server is talking 273 | $this->connected = true; 274 | return true; 275 | } 276 | return false; 277 | } 278 | 279 | /** 280 | * Login to the POP3 server (does not support APOP yet) 281 | * @access public 282 | * @param string $username 283 | * @param string $password 284 | * @return boolean 285 | */ 286 | public function Login ($username = '', $password = '') { 287 | if ($this->connected == false) { 288 | $this->error = 'Not connected to POP3 server'; 289 | 290 | if ($this->do_debug >= 1) { 291 | $this->displayErrors(); 292 | } 293 | } 294 | 295 | if (empty($username)) { 296 | $username = $this->username; 297 | } 298 | 299 | if (empty($password)) { 300 | $password = $this->password; 301 | } 302 | 303 | $pop_username = "USER $username" . $this->CRLF; 304 | $pop_password = "PASS $password" . $this->CRLF; 305 | 306 | // Send the Username 307 | $this->sendString($pop_username); 308 | $pop3_response = $this->getResponse(); 309 | 310 | if ($this->checkResponse($pop3_response)) { 311 | // Send the Password 312 | $this->sendString($pop_password); 313 | $pop3_response = $this->getResponse(); 314 | 315 | if ($this->checkResponse($pop3_response)) { 316 | return true; 317 | } 318 | } 319 | return false; 320 | } 321 | 322 | /** 323 | * Disconnect from the POP3 server 324 | * @access public 325 | */ 326 | public function Disconnect () { 327 | $this->sendString('QUIT'); 328 | 329 | fclose($this->pop_conn); 330 | } 331 | 332 | ///////////////////////////////////////////////// 333 | // Private Methods 334 | ///////////////////////////////////////////////// 335 | 336 | /** 337 | * Get the socket response back. 338 | * $size is the maximum number of bytes to retrieve 339 | * @access private 340 | * @param integer $size 341 | * @return string 342 | */ 343 | private function getResponse ($size = 128) { 344 | $pop3_response = fgets($this->pop_conn, $size); 345 | 346 | return $pop3_response; 347 | } 348 | 349 | /** 350 | * Send a string down the open socket connection to the POP3 server 351 | * @access private 352 | * @param string $string 353 | * @return integer 354 | */ 355 | private function sendString ($string) { 356 | $bytes_sent = fwrite($this->pop_conn, $string, strlen($string)); 357 | 358 | return $bytes_sent; 359 | } 360 | 361 | /** 362 | * Checks the POP3 server response for +OK or -ERR 363 | * @access private 364 | * @param string $string 365 | * @return boolean 366 | */ 367 | private function checkResponse ($string) { 368 | if (substr($string, 0, 3) !== '+OK') { 369 | $this->error = array( 370 | 'error' => "Server reported an error: $string", 371 | 'errno' => 0, 372 | 'errstr' => '' 373 | ); 374 | 375 | if ($this->do_debug >= 1) { 376 | $this->displayErrors(); 377 | } 378 | 379 | return false; 380 | } else { 381 | return true; 382 | } 383 | 384 | } 385 | 386 | /** 387 | * If debug is enabled, display the error message array 388 | * @access private 389 | */ 390 | private function displayErrors () { 391 | echo '
';
392 | 
393 |     foreach ($this->error as $single_error) {
394 |       print_r($single_error);
395 |     }
396 | 
397 |     echo '
'; 398 | } 399 | 400 | /** 401 | * Takes over from PHP for the socket warning handler 402 | * @access private 403 | * @param integer $errno 404 | * @param string $errstr 405 | * @param string $errfile 406 | * @param integer $errline 407 | */ 408 | private function catchWarning ($errno, $errstr, $errfile, $errline) { 409 | $this->error[] = array( 410 | 'error' => "Connecting to the POP3 server raised a PHP warning: ", 411 | 'errno' => $errno, 412 | 'errstr' => $errstr 413 | ); 414 | } 415 | 416 | // End of class 417 | } 418 | -------------------------------------------------------------------------------- /PHPMailer/class.smtp.php: -------------------------------------------------------------------------------- 1 | Debugoutput == "error_log") { 119 | error_log($str); 120 | } else { 121 | echo $str; 122 | } 123 | } 124 | 125 | /** 126 | * Initialize the class so that the data is in a known state. 127 | * @access public 128 | * @return SMTP 129 | */ 130 | public function __construct() { 131 | $this->smtp_conn = 0; 132 | $this->error = null; 133 | $this->helo_rply = null; 134 | 135 | $this->do_debug = 0; 136 | } 137 | 138 | ///////////////////////////////////////////////// 139 | // CONNECTION FUNCTIONS 140 | ///////////////////////////////////////////////// 141 | 142 | /** 143 | * Connect to the server specified on the port specified. 144 | * If the port is not specified use the default SMTP_PORT. 145 | * If tval is specified then a connection will try and be 146 | * established with the server for that number of seconds. 147 | * If tval is not specified the default is 30 seconds to 148 | * try on the connection. 149 | * 150 | * SMTP CODE SUCCESS: 220 151 | * SMTP CODE FAILURE: 421 152 | * @access public 153 | * @param string $host 154 | * @param int $port 155 | * @param int $tval 156 | * @return bool 157 | */ 158 | public function Connect($host, $port = 0, $tval = 30) { 159 | // set the error val to null so there is no confusion 160 | $this->error = null; 161 | 162 | // make sure we are __not__ connected 163 | if($this->connected()) { 164 | // already connected, generate error 165 | $this->error = array("error" => "Already connected to a server"); 166 | return false; 167 | } 168 | 169 | if(empty($port)) { 170 | $port = $this->SMTP_PORT; 171 | } 172 | 173 | // connect to the smtp server 174 | $this->smtp_conn = @fsockopen($host, // the host of the server 175 | $port, // the port to use 176 | $errno, // error number if any 177 | $errstr, // error message if any 178 | $tval); // give up after ? secs 179 | // verify we connected properly 180 | if(empty($this->smtp_conn)) { 181 | $this->error = array("error" => "Failed to connect to server", 182 | "errno" => $errno, 183 | "errstr" => $errstr); 184 | if($this->do_debug >= 1) { 185 | $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '
'); 186 | } 187 | return false; 188 | } 189 | 190 | // SMTP server can take longer to respond, give longer timeout for first read 191 | // Windows does not have support for this timeout function 192 | if(substr(PHP_OS, 0, 3) != "WIN") { 193 | $max = ini_get('max_execution_time'); 194 | if ($max != 0 && $tval > $max) { // don't bother if unlimited 195 | @set_time_limit($tval); 196 | } 197 | stream_set_timeout($this->smtp_conn, $tval, 0); 198 | } 199 | 200 | // get any announcement 201 | $announce = $this->get_lines(); 202 | 203 | if($this->do_debug >= 2) { 204 | $this->edebug("SMTP -> FROM SERVER:" . $announce . $this->CRLF . '
'); 205 | } 206 | 207 | return true; 208 | } 209 | 210 | /** 211 | * Initiate a TLS communication with the server. 212 | * 213 | * SMTP CODE 220 Ready to start TLS 214 | * SMTP CODE 501 Syntax error (no parameters allowed) 215 | * SMTP CODE 454 TLS not available due to temporary reason 216 | * @access public 217 | * @return bool success 218 | */ 219 | public function StartTLS() { 220 | $this->error = null; # to avoid confusion 221 | 222 | if(!$this->connected()) { 223 | $this->error = array("error" => "Called StartTLS() without being connected"); 224 | return false; 225 | } 226 | 227 | fputs($this->smtp_conn,"STARTTLS" . $this->CRLF); 228 | 229 | $rply = $this->get_lines(); 230 | $code = substr($rply,0,3); 231 | 232 | if($this->do_debug >= 2) { 233 | $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
'); 234 | } 235 | 236 | if($code != 220) { 237 | $this->error = 238 | array("error" => "STARTTLS not accepted from server", 239 | "smtp_code" => $code, 240 | "smtp_msg" => substr($rply,4)); 241 | if($this->do_debug >= 1) { 242 | $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'); 243 | } 244 | return false; 245 | } 246 | 247 | // Begin encrypted connection 248 | if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { 249 | return false; 250 | } 251 | 252 | return true; 253 | } 254 | 255 | /** 256 | * Performs SMTP authentication. Must be run after running the 257 | * Hello() method. Returns true if successfully authenticated. 258 | * @access public 259 | * @param string $username 260 | * @param string $password 261 | * @param string $authtype 262 | * @param string $realm 263 | * @param string $workstation 264 | * @return bool 265 | */ 266 | public function Authenticate($username, $password, $authtype='LOGIN', $realm='', $workstation='') { 267 | if (empty($authtype)) { 268 | $authtype = 'LOGIN'; 269 | } 270 | 271 | switch ($authtype) { 272 | case 'PLAIN': 273 | // Start authentication 274 | fputs($this->smtp_conn,"AUTH PLAIN" . $this->CRLF); 275 | 276 | $rply = $this->get_lines(); 277 | $code = substr($rply,0,3); 278 | 279 | if($code != 334) { 280 | $this->error = 281 | array("error" => "AUTH not accepted from server", 282 | "smtp_code" => $code, 283 | "smtp_msg" => substr($rply,4)); 284 | if($this->do_debug >= 1) { 285 | $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'); 286 | } 287 | return false; 288 | } 289 | // Send encoded username and password 290 | fputs($this->smtp_conn, base64_encode("\0".$username."\0".$password) . $this->CRLF); 291 | 292 | $rply = $this->get_lines(); 293 | $code = substr($rply,0,3); 294 | 295 | if($code != 235) { 296 | $this->error = 297 | array("error" => "Authentication not accepted from server", 298 | "smtp_code" => $code, 299 | "smtp_msg" => substr($rply,4)); 300 | if($this->do_debug >= 1) { 301 | $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'); 302 | } 303 | return false; 304 | } 305 | break; 306 | case 'LOGIN': 307 | // Start authentication 308 | fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF); 309 | 310 | $rply = $this->get_lines(); 311 | $code = substr($rply,0,3); 312 | 313 | if($code != 334) { 314 | $this->error = 315 | array("error" => "AUTH not accepted from server", 316 | "smtp_code" => $code, 317 | "smtp_msg" => substr($rply,4)); 318 | if($this->do_debug >= 1) { 319 | $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'); 320 | } 321 | return false; 322 | } 323 | 324 | // Send encoded username 325 | fputs($this->smtp_conn, base64_encode($username) . $this->CRLF); 326 | 327 | $rply = $this->get_lines(); 328 | $code = substr($rply,0,3); 329 | 330 | if($code != 334) { 331 | $this->error = 332 | array("error" => "Username not accepted from server", 333 | "smtp_code" => $code, 334 | "smtp_msg" => substr($rply,4)); 335 | if($this->do_debug >= 1) { 336 | $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'); 337 | } 338 | return false; 339 | } 340 | 341 | // Send encoded password 342 | fputs($this->smtp_conn, base64_encode($password) . $this->CRLF); 343 | 344 | $rply = $this->get_lines(); 345 | $code = substr($rply,0,3); 346 | 347 | if($code != 235) { 348 | $this->error = 349 | array("error" => "Password not accepted from server", 350 | "smtp_code" => $code, 351 | "smtp_msg" => substr($rply,4)); 352 | if($this->do_debug >= 1) { 353 | $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'); 354 | } 355 | return false; 356 | } 357 | break; 358 | case 'NTLM': 359 | /* 360 | * ntlm_sasl_client.php 361 | ** Bundled with Permission 362 | ** 363 | ** How to telnet in windows: http://technet.microsoft.com/en-us/library/aa995718%28EXCHG.65%29.aspx 364 | ** PROTOCOL Documentation http://curl.haxx.se/rfc/ntlm.html#ntlmSmtpAuthentication 365 | */ 366 | require_once 'ntlm_sasl_client.php'; 367 | $temp = new stdClass(); 368 | $ntlm_client = new ntlm_sasl_client_class; 369 | if(! $ntlm_client->Initialize($temp)){//let's test if every function its available 370 | $this->error = array("error" => $temp->error); 371 | if($this->do_debug >= 1) { 372 | $this->edebug("You need to enable some modules in your php.ini file: " . $this->error["error"] . $this->CRLF); 373 | } 374 | return false; 375 | } 376 | $msg1 = $ntlm_client->TypeMsg1($realm, $workstation);//msg1 377 | 378 | fputs($this->smtp_conn,"AUTH NTLM " . base64_encode($msg1) . $this->CRLF); 379 | 380 | $rply = $this->get_lines(); 381 | $code = substr($rply,0,3); 382 | 383 | 384 | if($code != 334) { 385 | $this->error = 386 | array("error" => "AUTH not accepted from server", 387 | "smtp_code" => $code, 388 | "smtp_msg" => substr($rply,4)); 389 | if($this->do_debug >= 1) { 390 | $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF); 391 | } 392 | return false; 393 | } 394 | 395 | $challenge = substr($rply,3);//though 0 based, there is a white space after the 3 digit number....//msg2 396 | $challenge = base64_decode($challenge); 397 | $ntlm_res = $ntlm_client->NTLMResponse(substr($challenge,24,8),$password); 398 | $msg3 = $ntlm_client->TypeMsg3($ntlm_res,$username,$realm,$workstation);//msg3 399 | // Send encoded username 400 | fputs($this->smtp_conn, base64_encode($msg3) . $this->CRLF); 401 | 402 | $rply = $this->get_lines(); 403 | $code = substr($rply,0,3); 404 | 405 | if($code != 235) { 406 | $this->error = 407 | array("error" => "Could not authenticate", 408 | "smtp_code" => $code, 409 | "smtp_msg" => substr($rply,4)); 410 | if($this->do_debug >= 1) { 411 | $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF); 412 | } 413 | return false; 414 | } 415 | break; 416 | case 'CRAM-MD5': 417 | // Start authentication 418 | fputs($this->smtp_conn,"AUTH CRAM-MD5" . $this->CRLF); 419 | 420 | $rply = $this->get_lines(); 421 | $code = substr($rply,0,3); 422 | 423 | if($code != 334) { 424 | $this->error = 425 | array("error" => "AUTH not accepted from server", 426 | "smtp_code" => $code, 427 | "smtp_msg" => substr($rply,4)); 428 | if($this->do_debug >= 1) { 429 | $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'); 430 | } 431 | return false; 432 | } 433 | 434 | // Get the challenge 435 | $challenge = base64_decode(substr($rply,4)); 436 | 437 | // Build the response 438 | $response = $username . ' ' . $this->hmac($challenge, $password); 439 | 440 | // Send encoded credentials 441 | fputs($this->smtp_conn, base64_encode($response) . $this->CRLF); 442 | 443 | $rply = $this->get_lines(); 444 | $code = substr($rply,0,3); 445 | 446 | if($code != 334) { 447 | $this->error = 448 | array("error" => "Credentials not accepted from server", 449 | "smtp_code" => $code, 450 | "smtp_msg" => substr($rply,4)); 451 | if($this->do_debug >= 1) { 452 | $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'); 453 | } 454 | return false; 455 | } 456 | break; 457 | } 458 | return true; 459 | } 460 | 461 | /** 462 | * Works like hash_hmac('md5', $data, $key) in case that function is not available 463 | * @access private 464 | * @param string $data 465 | * @param string $key 466 | * @return string 467 | */ 468 | private function hmac($data, $key) { 469 | if (function_exists('hash_hmac')) { 470 | return hash_hmac('md5', $data, $key); 471 | } 472 | 473 | // The following borrowed from http://php.net/manual/en/function.mhash.php#27225 474 | 475 | // RFC 2104 HMAC implementation for php. 476 | // Creates an md5 HMAC. 477 | // Eliminates the need to install mhash to compute a HMAC 478 | // Hacked by Lance Rushing 479 | 480 | $b = 64; // byte length for md5 481 | if (strlen($key) > $b) { 482 | $key = pack("H*",md5($key)); 483 | } 484 | $key = str_pad($key, $b, chr(0x00)); 485 | $ipad = str_pad('', $b, chr(0x36)); 486 | $opad = str_pad('', $b, chr(0x5c)); 487 | $k_ipad = $key ^ $ipad ; 488 | $k_opad = $key ^ $opad; 489 | 490 | return md5($k_opad . pack("H*",md5($k_ipad . $data))); 491 | } 492 | 493 | /** 494 | * Returns true if connected to a server otherwise false 495 | * @access public 496 | * @return bool 497 | */ 498 | public function Connected() { 499 | if(!empty($this->smtp_conn)) { 500 | $sock_status = socket_get_status($this->smtp_conn); 501 | if($sock_status["eof"]) { 502 | // the socket is valid but we are not connected 503 | if($this->do_debug >= 1) { 504 | $this->edebug("SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected"); 505 | } 506 | $this->Close(); 507 | return false; 508 | } 509 | return true; // everything looks good 510 | } 511 | return false; 512 | } 513 | 514 | /** 515 | * Closes the socket and cleans up the state of the class. 516 | * It is not considered good to use this function without 517 | * first trying to use QUIT. 518 | * @access public 519 | * @return void 520 | */ 521 | public function Close() { 522 | $this->error = null; // so there is no confusion 523 | $this->helo_rply = null; 524 | if(!empty($this->smtp_conn)) { 525 | // close the connection and cleanup 526 | fclose($this->smtp_conn); 527 | $this->smtp_conn = 0; 528 | } 529 | } 530 | 531 | ///////////////////////////////////////////////// 532 | // SMTP COMMANDS 533 | ///////////////////////////////////////////////// 534 | 535 | /** 536 | * Issues a data command and sends the msg_data to the server 537 | * finializing the mail transaction. $msg_data is the message 538 | * that is to be send with the headers. Each header needs to be 539 | * on a single line followed by a with the message headers 540 | * and the message body being seperated by and additional . 541 | * 542 | * Implements rfc 821: DATA 543 | * 544 | * SMTP CODE INTERMEDIATE: 354 545 | * [data] 546 | * . 547 | * SMTP CODE SUCCESS: 250 548 | * SMTP CODE FAILURE: 552,554,451,452 549 | * SMTP CODE FAILURE: 451,554 550 | * SMTP CODE ERROR : 500,501,503,421 551 | * @access public 552 | * @param string $msg_data 553 | * @return bool 554 | */ 555 | public function Data($msg_data) { 556 | $this->error = null; // so no confusion is caused 557 | 558 | if(!$this->connected()) { 559 | $this->error = array( 560 | "error" => "Called Data() without being connected"); 561 | return false; 562 | } 563 | 564 | fputs($this->smtp_conn,"DATA" . $this->CRLF); 565 | 566 | $rply = $this->get_lines(); 567 | $code = substr($rply,0,3); 568 | 569 | if($this->do_debug >= 2) { 570 | $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
'); 571 | } 572 | 573 | if($code != 354) { 574 | $this->error = 575 | array("error" => "DATA command not accepted from server", 576 | "smtp_code" => $code, 577 | "smtp_msg" => substr($rply,4)); 578 | if($this->do_debug >= 1) { 579 | $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'); 580 | } 581 | return false; 582 | } 583 | 584 | /* the server is ready to accept data! 585 | * according to rfc 821 we should not send more than 1000 586 | * including the CRLF 587 | * characters on a single line so we will break the data up 588 | * into lines by \r and/or \n then if needed we will break 589 | * each of those into smaller lines to fit within the limit. 590 | * in addition we will be looking for lines that start with 591 | * a period '.' and append and additional period '.' to that 592 | * line. NOTE: this does not count towards limit. 593 | */ 594 | 595 | // normalize the line breaks so we know the explode works 596 | $msg_data = str_replace("\r\n","\n",$msg_data); 597 | $msg_data = str_replace("\r","\n",$msg_data); 598 | $lines = explode("\n",$msg_data); 599 | 600 | /* we need to find a good way to determine is headers are 601 | * in the msg_data or if it is a straight msg body 602 | * currently I am assuming rfc 822 definitions of msg headers 603 | * and if the first field of the first line (':' sperated) 604 | * does not contain a space then it _should_ be a header 605 | * and we can process all lines before a blank "" line as 606 | * headers. 607 | */ 608 | 609 | $field = substr($lines[0],0,strpos($lines[0],":")); 610 | $in_headers = false; 611 | if(!empty($field) && !strstr($field," ")) { 612 | $in_headers = true; 613 | } 614 | 615 | $max_line_length = 998; // used below; set here for ease in change 616 | 617 | while(list(,$line) = @each($lines)) { 618 | $lines_out = null; 619 | if($line == "" && $in_headers) { 620 | $in_headers = false; 621 | } 622 | // ok we need to break this line up into several smaller lines 623 | while(strlen($line) > $max_line_length) { 624 | $pos = strrpos(substr($line,0,$max_line_length)," "); 625 | 626 | // Patch to fix DOS attack 627 | if(!$pos) { 628 | $pos = $max_line_length - 1; 629 | $lines_out[] = substr($line,0,$pos); 630 | $line = substr($line,$pos); 631 | } else { 632 | $lines_out[] = substr($line,0,$pos); 633 | $line = substr($line,$pos + 1); 634 | } 635 | 636 | /* if processing headers add a LWSP-char to the front of new line 637 | * rfc 822 on long msg headers 638 | */ 639 | if($in_headers) { 640 | $line = "\t" . $line; 641 | } 642 | } 643 | $lines_out[] = $line; 644 | 645 | // send the lines to the server 646 | while(list(,$line_out) = @each($lines_out)) { 647 | if(strlen($line_out) > 0) 648 | { 649 | if(substr($line_out, 0, 1) == ".") { 650 | $line_out = "." . $line_out; 651 | } 652 | } 653 | fputs($this->smtp_conn,$line_out . $this->CRLF); 654 | } 655 | } 656 | 657 | // message data has been sent 658 | fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF); 659 | 660 | $rply = $this->get_lines(); 661 | $code = substr($rply,0,3); 662 | 663 | if($this->do_debug >= 2) { 664 | $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
'); 665 | } 666 | 667 | if($code != 250) { 668 | $this->error = 669 | array("error" => "DATA not accepted from server", 670 | "smtp_code" => $code, 671 | "smtp_msg" => substr($rply,4)); 672 | if($this->do_debug >= 1) { 673 | $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'); 674 | } 675 | return false; 676 | } 677 | return true; 678 | } 679 | 680 | /** 681 | * Sends the HELO command to the smtp server. 682 | * This makes sure that we and the server are in 683 | * the same known state. 684 | * 685 | * Implements from rfc 821: HELO 686 | * 687 | * SMTP CODE SUCCESS: 250 688 | * SMTP CODE ERROR : 500, 501, 504, 421 689 | * @access public 690 | * @param string $host 691 | * @return bool 692 | */ 693 | public function Hello($host = '') { 694 | $this->error = null; // so no confusion is caused 695 | 696 | if(!$this->connected()) { 697 | $this->error = array( 698 | "error" => "Called Hello() without being connected"); 699 | return false; 700 | } 701 | 702 | // if hostname for HELO was not specified send default 703 | if(empty($host)) { 704 | // determine appropriate default to send to server 705 | $host = "localhost"; 706 | } 707 | 708 | // Send extended hello first (RFC 2821) 709 | if(!$this->SendHello("EHLO", $host)) { 710 | if(!$this->SendHello("HELO", $host)) { 711 | return false; 712 | } 713 | } 714 | 715 | return true; 716 | } 717 | 718 | /** 719 | * Sends a HELO/EHLO command. 720 | * @access private 721 | * @param string $hello 722 | * @param string $host 723 | * @return bool 724 | */ 725 | private function SendHello($hello, $host) { 726 | fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF); 727 | 728 | $rply = $this->get_lines(); 729 | $code = substr($rply,0,3); 730 | 731 | if($this->do_debug >= 2) { 732 | $this->edebug("SMTP -> FROM SERVER: " . $rply . $this->CRLF . '
'); 733 | } 734 | 735 | if($code != 250) { 736 | $this->error = 737 | array("error" => $hello . " not accepted from server", 738 | "smtp_code" => $code, 739 | "smtp_msg" => substr($rply,4)); 740 | if($this->do_debug >= 1) { 741 | $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'); 742 | } 743 | return false; 744 | } 745 | 746 | $this->helo_rply = $rply; 747 | 748 | return true; 749 | } 750 | 751 | /** 752 | * Starts a mail transaction from the email address specified in 753 | * $from. Returns true if successful or false otherwise. If True 754 | * the mail transaction is started and then one or more Recipient 755 | * commands may be called followed by a Data command. 756 | * 757 | * Implements rfc 821: MAIL FROM: 758 | * 759 | * SMTP CODE SUCCESS: 250 760 | * SMTP CODE SUCCESS: 552,451,452 761 | * SMTP CODE SUCCESS: 500,501,421 762 | * @access public 763 | * @param string $from 764 | * @return bool 765 | */ 766 | public function Mail($from) { 767 | $this->error = null; // so no confusion is caused 768 | 769 | if(!$this->connected()) { 770 | $this->error = array( 771 | "error" => "Called Mail() without being connected"); 772 | return false; 773 | } 774 | 775 | $useVerp = ($this->do_verp ? " XVERP" : ""); 776 | fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF); 777 | 778 | $rply = $this->get_lines(); 779 | $code = substr($rply,0,3); 780 | 781 | if($this->do_debug >= 2) { 782 | $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
'); 783 | } 784 | 785 | if($code != 250) { 786 | $this->error = 787 | array("error" => "MAIL not accepted from server", 788 | "smtp_code" => $code, 789 | "smtp_msg" => substr($rply,4)); 790 | if($this->do_debug >= 1) { 791 | $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'); 792 | } 793 | return false; 794 | } 795 | return true; 796 | } 797 | 798 | /** 799 | * Sends the quit command to the server and then closes the socket 800 | * if there is no error or the $close_on_error argument is true. 801 | * 802 | * Implements from rfc 821: QUIT 803 | * 804 | * SMTP CODE SUCCESS: 221 805 | * SMTP CODE ERROR : 500 806 | * @access public 807 | * @param bool $close_on_error 808 | * @return bool 809 | */ 810 | public function Quit($close_on_error = true) { 811 | $this->error = null; // so there is no confusion 812 | 813 | if(!$this->connected()) { 814 | $this->error = array( 815 | "error" => "Called Quit() without being connected"); 816 | return false; 817 | } 818 | 819 | // send the quit command to the server 820 | fputs($this->smtp_conn,"quit" . $this->CRLF); 821 | 822 | // get any good-bye messages 823 | $byemsg = $this->get_lines(); 824 | 825 | if($this->do_debug >= 2) { 826 | $this->edebug("SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '
'); 827 | } 828 | 829 | $rval = true; 830 | $e = null; 831 | 832 | $code = substr($byemsg,0,3); 833 | if($code != 221) { 834 | // use e as a tmp var cause Close will overwrite $this->error 835 | $e = array("error" => "SMTP server rejected quit command", 836 | "smtp_code" => $code, 837 | "smtp_rply" => substr($byemsg,4)); 838 | $rval = false; 839 | if($this->do_debug >= 1) { 840 | $this->edebug("SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF . '
'); 841 | } 842 | } 843 | 844 | if(empty($e) || $close_on_error) { 845 | $this->Close(); 846 | } 847 | 848 | return $rval; 849 | } 850 | 851 | /** 852 | * Sends the command RCPT to the SMTP server with the TO: argument of $to. 853 | * Returns true if the recipient was accepted false if it was rejected. 854 | * 855 | * Implements from rfc 821: RCPT TO: 856 | * 857 | * SMTP CODE SUCCESS: 250,251 858 | * SMTP CODE FAILURE: 550,551,552,553,450,451,452 859 | * SMTP CODE ERROR : 500,501,503,421 860 | * @access public 861 | * @param string $to 862 | * @return bool 863 | */ 864 | public function Recipient($to) { 865 | $this->error = null; // so no confusion is caused 866 | 867 | if(!$this->connected()) { 868 | $this->error = array( 869 | "error" => "Called Recipient() without being connected"); 870 | return false; 871 | } 872 | 873 | fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF); 874 | 875 | $rply = $this->get_lines(); 876 | $code = substr($rply,0,3); 877 | 878 | if($this->do_debug >= 2) { 879 | $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
'); 880 | } 881 | 882 | if($code != 250 && $code != 251) { 883 | $this->error = 884 | array("error" => "RCPT not accepted from server", 885 | "smtp_code" => $code, 886 | "smtp_msg" => substr($rply,4)); 887 | if($this->do_debug >= 1) { 888 | $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'); 889 | } 890 | return false; 891 | } 892 | return true; 893 | } 894 | 895 | /** 896 | * Sends the RSET command to abort and transaction that is 897 | * currently in progress. Returns true if successful false 898 | * otherwise. 899 | * 900 | * Implements rfc 821: RSET 901 | * 902 | * SMTP CODE SUCCESS: 250 903 | * SMTP CODE ERROR : 500,501,504,421 904 | * @access public 905 | * @return bool 906 | */ 907 | public function Reset() { 908 | $this->error = null; // so no confusion is caused 909 | 910 | if(!$this->connected()) { 911 | $this->error = array( 912 | "error" => "Called Reset() without being connected"); 913 | return false; 914 | } 915 | 916 | fputs($this->smtp_conn,"RSET" . $this->CRLF); 917 | 918 | $rply = $this->get_lines(); 919 | $code = substr($rply,0,3); 920 | 921 | if($this->do_debug >= 2) { 922 | $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
'); 923 | } 924 | 925 | if($code != 250) { 926 | $this->error = 927 | array("error" => "RSET failed", 928 | "smtp_code" => $code, 929 | "smtp_msg" => substr($rply,4)); 930 | if($this->do_debug >= 1) { 931 | $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'); 932 | } 933 | return false; 934 | } 935 | 936 | return true; 937 | } 938 | 939 | /** 940 | * Starts a mail transaction from the email address specified in 941 | * $from. Returns true if successful or false otherwise. If True 942 | * the mail transaction is started and then one or more Recipient 943 | * commands may be called followed by a Data command. This command 944 | * will send the message to the users terminal if they are logged 945 | * in and send them an email. 946 | * 947 | * Implements rfc 821: SAML FROM: 948 | * 949 | * SMTP CODE SUCCESS: 250 950 | * SMTP CODE SUCCESS: 552,451,452 951 | * SMTP CODE SUCCESS: 500,501,502,421 952 | * @access public 953 | * @param string $from 954 | * @return bool 955 | */ 956 | public function SendAndMail($from) { 957 | $this->error = null; // so no confusion is caused 958 | 959 | if(!$this->connected()) { 960 | $this->error = array( 961 | "error" => "Called SendAndMail() without being connected"); 962 | return false; 963 | } 964 | 965 | fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF); 966 | 967 | $rply = $this->get_lines(); 968 | $code = substr($rply,0,3); 969 | 970 | if($this->do_debug >= 2) { 971 | $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
'); 972 | } 973 | 974 | if($code != 250) { 975 | $this->error = 976 | array("error" => "SAML not accepted from server", 977 | "smtp_code" => $code, 978 | "smtp_msg" => substr($rply,4)); 979 | if($this->do_debug >= 1) { 980 | $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'); 981 | } 982 | return false; 983 | } 984 | return true; 985 | } 986 | 987 | /** 988 | * This is an optional command for SMTP that this class does not 989 | * support. This method is here to make the RFC821 Definition 990 | * complete for this class and __may__ be implimented in the future 991 | * 992 | * Implements from rfc 821: TURN 993 | * 994 | * SMTP CODE SUCCESS: 250 995 | * SMTP CODE FAILURE: 502 996 | * SMTP CODE ERROR : 500, 503 997 | * @access public 998 | * @return bool 999 | */ 1000 | public function Turn() { 1001 | $this->error = array("error" => "This method, TURN, of the SMTP ". 1002 | "is not implemented"); 1003 | if($this->do_debug >= 1) { 1004 | $this->edebug("SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '
'); 1005 | } 1006 | return false; 1007 | } 1008 | 1009 | /** 1010 | * Get the current error 1011 | * @access public 1012 | * @return array 1013 | */ 1014 | public function getError() { 1015 | return $this->error; 1016 | } 1017 | 1018 | ///////////////////////////////////////////////// 1019 | // INTERNAL FUNCTIONS 1020 | ///////////////////////////////////////////////// 1021 | 1022 | /** 1023 | * Read in as many lines as possible 1024 | * either before eof or socket timeout occurs on the operation. 1025 | * With SMTP we can tell if we have more lines to read if the 1026 | * 4th character is '-' symbol. If it is a space then we don't 1027 | * need to read anything else. 1028 | * @access private 1029 | * @return string 1030 | */ 1031 | private function get_lines() { 1032 | $data = ""; 1033 | $endtime = 0; 1034 | /* If for some reason the fp is bad, don't inf loop */ 1035 | if (!is_resource($this->smtp_conn)) { 1036 | return $data; 1037 | } 1038 | stream_set_timeout($this->smtp_conn, $this->Timeout); 1039 | if ($this->Timelimit > 0) { 1040 | $endtime = time() + $this->Timelimit; 1041 | } 1042 | while(is_resource($this->smtp_conn) && !feof($this->smtp_conn)) { 1043 | $str = @fgets($this->smtp_conn,515); 1044 | if($this->do_debug >= 4) { 1045 | $this->edebug("SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF . '
'); 1046 | $this->edebug("SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '
'); 1047 | } 1048 | $data .= $str; 1049 | if($this->do_debug >= 4) { 1050 | $this->edebug("SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '
'); 1051 | } 1052 | // if 4th character is a space, we are done reading, break the loop 1053 | if(substr($str,3,1) == " ") { break; } 1054 | // Timed-out? Log and break 1055 | $info = stream_get_meta_data($this->smtp_conn); 1056 | if ($info['timed_out']) { 1057 | if($this->do_debug >= 4) { 1058 | $this->edebug("SMTP -> get_lines(): timed-out (" . $this->Timeout . " seconds)
"); 1059 | } 1060 | break; 1061 | } 1062 | // Now check if reads took too long 1063 | if ($endtime) { 1064 | if (time() > $endtime) { 1065 | if($this->do_debug >= 4) { 1066 | $this->edebug("SMTP -> get_lines(): timelimit reached (" . $this->Timelimit . " seconds)
"); 1067 | } 1068 | break; 1069 | } 1070 | } 1071 | } 1072 | return $data; 1073 | } 1074 | 1075 | } 1076 | -------------------------------------------------------------------------------- /PHPMailer/extras/class.html2text.inc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dtbaker/php-gmail-auto-reply/a85be9acb690afd08a8f88e2bed07480a283890e/PHPMailer/extras/class.html2text.inc -------------------------------------------------------------------------------- /PHPMailer/extras/htmlfilter.php: -------------------------------------------------------------------------------- 1 | 27 | * @Version 1.1 ($Date: 2011-07-04 14:02:23 -0400 (Mon, 04 Jul 2011) $) 28 | */ 29 | 30 | /** 31 | * @Author Jim Jagielski 32 | */ 33 | 34 | /** 35 | * This function returns the final tag out of the tag name, an array 36 | * of attributes, and the type of the tag. This function is called by 37 | * tln_sanitize internally. 38 | * 39 | * @param $tagname the name of the tag. 40 | * @param $attary the array of attributes and their values 41 | * @param $tagtype The type of the tag (see in comments). 42 | * @return a string with the final tag representation. 43 | */ 44 | function tln_tagprint($tagname, $attary, $tagtype){ 45 | $me = 'tln_tagprint'; 46 | if ($tagtype == 2){ 47 | $fulltag = ''; 48 | } else { 49 | $fulltag = '<' . $tagname; 50 | if (is_array($attary) && sizeof($attary)){ 51 | $atts = Array(); 52 | while (list($attname, $attvalue) = each($attary)){ 53 | array_push($atts, "$attname=$attvalue"); 54 | } 55 | $fulltag .= ' ' . join(' ', $atts); 56 | } 57 | if ($tagtype == 3){ 58 | $fulltag .= ' /'; 59 | } 60 | $fulltag .= '>'; 61 | } 62 | return $fulltag; 63 | } 64 | 65 | /** 66 | * A small helper function to use with array_walk. Modifies a by-ref 67 | * value and makes it lowercase. 68 | * 69 | * @param $val a value passed by-ref. 70 | * @return void since it modifies a by-ref value. 71 | */ 72 | function tln_casenormalize(&$val){ 73 | $val = strtolower($val); 74 | } 75 | 76 | /** 77 | * This function skips any whitespace from the current position within 78 | * a string and to the next non-whitespace value. 79 | * 80 | * @param $body the string 81 | * @param $offset the offset within the string where we should start 82 | * looking for the next non-whitespace character. 83 | * @return the location within the $body where the next 84 | * non-whitespace char is located. 85 | */ 86 | function tln_skipspace($body, $offset){ 87 | $me = 'tln_skipspace'; 88 | preg_match('/^(\s*)/s', substr($body, $offset), $matches); 89 | if (sizeof($matches[1])){ 90 | $count = strlen($matches[1]); 91 | $offset += $count; 92 | } 93 | return $offset; 94 | } 95 | 96 | /** 97 | * This function looks for the next character within a string. It's 98 | * really just a glorified "strpos", except it catches the failures 99 | * nicely. 100 | * 101 | * @param $body The string to look for needle in. 102 | * @param $offset Start looking from this position. 103 | * @param $needle The character/string to look for. 104 | * @return location of the next occurance of the needle, or 105 | * strlen($body) if needle wasn't found. 106 | */ 107 | function tln_findnxstr($body, $offset, $needle){ 108 | $me = 'tln_findnxstr'; 109 | $pos = strpos($body, $needle, $offset); 110 | if ($pos === FALSE){ 111 | $pos = strlen($body); 112 | } 113 | return $pos; 114 | } 115 | 116 | /** 117 | * This function takes a PCRE-style regexp and tries to match it 118 | * within the string. 119 | * 120 | * @param $body The string to look for needle in. 121 | * @param $offset Start looking from here. 122 | * @param $reg A PCRE-style regex to match. 123 | * @return Returns a false if no matches found, or an array 124 | * with the following members: 125 | * - integer with the location of the match within $body 126 | * - string with whatever content between offset and the match 127 | * - string with whatever it is we matched 128 | */ 129 | function tln_findnxreg($body, $offset, $reg){ 130 | $me = 'tln_findnxreg'; 131 | $matches = Array(); 132 | $retarr = Array(); 133 | $preg_rule = '%^(.*?)(' . $reg . ')%s'; 134 | preg_match($preg_rule, substr($body, $offset), $matches); 135 | if (!isset($matches[0])){ 136 | $retarr = false; 137 | } else { 138 | $retarr[0] = $offset + strlen($matches[1]); 139 | $retarr[1] = $matches[1]; 140 | $retarr[2] = $matches[2]; 141 | } 142 | return $retarr; 143 | } 144 | 145 | /** 146 | * This function looks for the next tag. 147 | * 148 | * @param $body String where to look for the next tag. 149 | * @param $offset Start looking from here. 150 | * @return false if no more tags exist in the body, or 151 | * an array with the following members: 152 | * - string with the name of the tag 153 | * - array with attributes and their values 154 | * - integer with tag type (1, 2, or 3) 155 | * - integer where the tag starts (starting "<") 156 | * - integer where the tag ends (ending ">") 157 | * first three members will be false, if the tag is invalid. 158 | */ 159 | function tln_getnxtag($body, $offset){ 160 | $me = 'tln_getnxtag'; 161 | if ($offset > strlen($body)){ 162 | return false; 163 | } 164 | $lt = tln_findnxstr($body, $offset, '<'); 165 | if ($lt == strlen($body)){ 166 | return false; 167 | } 168 | /** 169 | * We are here: 170 | * blah blah 171 | * \---------^ 172 | */ 173 | $pos = tln_skipspace($body, $lt + 1); 174 | if ($pos >= strlen($body)){ 175 | return Array(false, false, false, $lt, strlen($body)); 176 | } 177 | /** 178 | * There are 3 kinds of tags: 179 | * 1. Opening tag, e.g.: 180 | * 181 | * 2. Closing tag, e.g.: 182 | * 183 | * 3. XHTML-style content-less tag, e.g.: 184 | * 185 | */ 186 | $tagtype = false; 187 | switch (substr($body, $pos, 1)){ 188 | case '/': 189 | $tagtype = 2; 190 | $pos++; 191 | break; 192 | case '!': 193 | /** 194 | * A comment or an SGML declaration. 195 | */ 196 | if (substr($body, $pos+1, 2) == '--'){ 197 | $gt = strpos($body, '-->', $pos); 198 | if ($gt === false){ 199 | $gt = strlen($body); 200 | } else { 201 | $gt += 2; 202 | } 203 | return Array(false, false, false, $lt, $gt); 204 | } else { 205 | $gt = tln_findnxstr($body, $pos, '>'); 206 | return Array(false, false, false, $lt, $gt); 207 | } 208 | break; 209 | default: 210 | /** 211 | * Assume tagtype 1 for now. If it's type 3, we'll switch values 212 | * later. 213 | */ 214 | $tagtype = 1; 215 | break; 216 | } 217 | 218 | $tag_start = $pos; 219 | $tagname = ''; 220 | /** 221 | * Look for next [\W-_], which will indicate the end of the tag name. 222 | */ 223 | $regary = tln_findnxreg($body, $pos, '[^\w\-_]'); 224 | if ($regary == false){ 225 | return Array(false, false, false, $lt, strlen($body)); 226 | } 227 | list($pos, $tagname, $match) = $regary; 228 | $tagname = strtolower($tagname); 229 | 230 | /** 231 | * $match can be either of these: 232 | * '>' indicating the end of the tag entirely. 233 | * '\s' indicating the end of the tag name. 234 | * '/' indicating that this is type-3 xhtml tag. 235 | * 236 | * Whatever else we find there indicates an invalid tag. 237 | */ 238 | switch ($match){ 239 | case '/': 240 | /** 241 | * This is an xhtml-style tag with a closing / at the 242 | * end, like so: . Check if it's followed 243 | * by the closing bracket. If not, then this tag is invalid 244 | */ 245 | if (substr($body, $pos, 2) == '/>'){ 246 | $pos++; 247 | $tagtype = 3; 248 | } else { 249 | $gt = tln_findnxstr($body, $pos, '>'); 250 | $retary = Array(false, false, false, $lt, $gt); 251 | return $retary; 252 | } 253 | case '>': 254 | return Array($tagname, false, $tagtype, $lt, $pos); 255 | break; 256 | default: 257 | /** 258 | * Check if it's whitespace 259 | */ 260 | if (preg_match('/\s/', $match)){ 261 | } else { 262 | /** 263 | * This is an invalid tag! Look for the next closing ">". 264 | */ 265 | $gt = tln_findnxstr($body, $lt, '>'); 266 | return Array(false, false, false, $lt, $gt); 267 | } 268 | } 269 | 270 | /** 271 | * At this point we're here: 272 | * 273 | * \-------^ 274 | * 275 | * At this point we loop in order to find all attributes. 276 | */ 277 | $attname = ''; 278 | $atttype = false; 279 | $attary = Array(); 280 | 281 | while ($pos <= strlen($body)){ 282 | $pos = tln_skipspace($body, $pos); 283 | if ($pos == strlen($body)){ 284 | /** 285 | * Non-closed tag. 286 | */ 287 | return Array(false, false, false, $lt, $pos); 288 | } 289 | /** 290 | * See if we arrived at a ">" or "/>", which means that we reached 291 | * the end of the tag. 292 | */ 293 | $matches = Array(); 294 | preg_match('%^(\s*)(>|/>)%s', substr($body, $pos), $matches); 295 | if (isset($matches[0]) && $matches[0]){ 296 | /** 297 | * Yep. So we did. 298 | */ 299 | $pos += strlen($matches[1]); 300 | if ($matches[2] == '/>'){ 301 | $tagtype = 3; 302 | $pos++; 303 | } 304 | return Array($tagname, $attary, $tagtype, $lt, $pos); 305 | } 306 | 307 | /** 308 | * There are several types of attributes, with optional 309 | * [:space:] between members. 310 | * Type 1: 311 | * attrname[:space:]=[:space:]'CDATA' 312 | * Type 2: 313 | * attrname[:space:]=[:space:]"CDATA" 314 | * Type 3: 315 | * attr[:space:]=[:space:]CDATA 316 | * Type 4: 317 | * attrname 318 | * 319 | * We leave types 1 and 2 the same, type 3 we check for 320 | * '"' and convert to """ if needed, then wrap in 321 | * double quotes. Type 4 we convert into: 322 | * attrname="yes". 323 | */ 324 | $regary = tln_findnxreg($body, $pos, '[^\w\-_]'); 325 | if ($regary == false){ 326 | /** 327 | * Looks like body ended before the end of tag. 328 | */ 329 | return Array(false, false, false, $lt, strlen($body)); 330 | } 331 | list($pos, $attname, $match) = $regary; 332 | $attname = strtolower($attname); 333 | /** 334 | * We arrived at the end of attribute name. Several things possible 335 | * here: 336 | * '>' means the end of the tag and this is attribute type 4 337 | * '/' if followed by '>' means the same thing as above 338 | * '\s' means a lot of things -- look what it's followed by. 339 | * anything else means the attribute is invalid. 340 | */ 341 | switch($match){ 342 | case '/': 343 | /** 344 | * This is an xhtml-style tag with a closing / at the 345 | * end, like so: . Check if it's followed 346 | * by the closing bracket. If not, then this tag is invalid 347 | */ 348 | if (substr($body, $pos, 2) == '/>'){ 349 | $pos++; 350 | $tagtype = 3; 351 | } else { 352 | $gt = tln_findnxstr($body, $pos, '>'); 353 | $retary = Array(false, false, false, $lt, $gt); 354 | return $retary; 355 | } 356 | case '>': 357 | $attary{$attname} = '"yes"'; 358 | return Array($tagname, $attary, $tagtype, $lt, $pos); 359 | break; 360 | default: 361 | /** 362 | * Skip whitespace and see what we arrive at. 363 | */ 364 | $pos = tln_skipspace($body, $pos); 365 | $char = substr($body, $pos, 1); 366 | /** 367 | * Two things are valid here: 368 | * '=' means this is attribute type 1 2 or 3. 369 | * \w means this was attribute type 4. 370 | * anything else we ignore and re-loop. End of tag and 371 | * invalid stuff will be caught by our checks at the beginning 372 | * of the loop. 373 | */ 374 | if ($char == '='){ 375 | $pos++; 376 | $pos = tln_skipspace($body, $pos); 377 | /** 378 | * Here are 3 possibilities: 379 | * "'" attribute type 1 380 | * '"' attribute type 2 381 | * everything else is the content of tag type 3 382 | */ 383 | $quot = substr($body, $pos, 1); 384 | if ($quot == '\''){ 385 | $regary = tln_findnxreg($body, $pos+1, '\''); 386 | if ($regary == false){ 387 | return Array(false, false, false, $lt, strlen($body)); 388 | } 389 | list($pos, $attval, $match) = $regary; 390 | $pos++; 391 | $attary{$attname} = '\'' . $attval . '\''; 392 | } else if ($quot == '"'){ 393 | $regary = tln_findnxreg($body, $pos+1, '\"'); 394 | if ($regary == false){ 395 | return Array(false, false, false, $lt, strlen($body)); 396 | } 397 | list($pos, $attval, $match) = $regary; 398 | $pos++; 399 | $attary{$attname} = '"' . $attval . '"'; 400 | } else { 401 | /** 402 | * These are hateful. Look for \s, or >. 403 | */ 404 | $regary = tln_findnxreg($body, $pos, '[\s>]'); 405 | if ($regary == false){ 406 | return Array(false, false, false, $lt, strlen($body)); 407 | } 408 | list($pos, $attval, $match) = $regary; 409 | /** 410 | * If it's ">" it will be caught at the top. 411 | */ 412 | $attval = preg_replace('/\"/s', '"', $attval); 413 | $attary{$attname} = '"' . $attval . '"'; 414 | } 415 | } else if (preg_match('|[\w/>]|', $char)) { 416 | /** 417 | * That was attribute type 4. 418 | */ 419 | $attary{$attname} = '"yes"'; 420 | } else { 421 | /** 422 | * An illegal character. Find next '>' and return. 423 | */ 424 | $gt = tln_findnxstr($body, $pos, '>'); 425 | return Array(false, false, false, $lt, $gt); 426 | } 427 | } 428 | } 429 | /** 430 | * The fact that we got here indicates that the tag end was never 431 | * found. Return invalid tag indication so it gets stripped. 432 | */ 433 | return Array(false, false, false, $lt, strlen($body)); 434 | } 435 | 436 | /** 437 | * Translates entities into literal values so they can be checked. 438 | * 439 | * @param $attvalue the by-ref value to check. 440 | * @param $regex the regular expression to check against. 441 | * @param $hex whether the entites are hexadecimal. 442 | * @return True or False depending on whether there were matches. 443 | */ 444 | function tln_deent(&$attvalue, $regex, $hex=false){ 445 | $me = 'tln_deent'; 446 | $ret_match = false; 447 | preg_match_all($regex, $attvalue, $matches); 448 | if (is_array($matches) && sizeof($matches[0]) > 0){ 449 | $repl = Array(); 450 | for ($i = 0; $i < sizeof($matches[0]); $i++){ 451 | $numval = $matches[1][$i]; 452 | if ($hex){ 453 | $numval = hexdec($numval); 454 | } 455 | $repl{$matches[0][$i]} = chr($numval); 456 | } 457 | $attvalue = strtr($attvalue, $repl); 458 | return true; 459 | } else { 460 | return false; 461 | } 462 | } 463 | 464 | /** 465 | * This function checks attribute values for entity-encoded values 466 | * and returns them translated into 8-bit strings so we can run 467 | * checks on them. 468 | * 469 | * @param $attvalue A string to run entity check against. 470 | * @return Nothing, modifies a reference value. 471 | */ 472 | function tln_defang(&$attvalue){ 473 | $me = 'tln_defang'; 474 | /** 475 | * Skip this if there aren't ampersands or backslashes. 476 | */ 477 | if (strpos($attvalue, '&') === false 478 | && strpos($attvalue, '\\') === false){ 479 | return; 480 | } 481 | $m = false; 482 | do { 483 | $m = false; 484 | $m = $m || tln_deent($attvalue, '/\�*(\d+);*/s'); 485 | $m = $m || tln_deent($attvalue, '/\�*((\d|[a-f])+);*/si', true); 486 | $m = $m || tln_deent($attvalue, '/\\\\(\d+)/s', true); 487 | } while ($m == true); 488 | $attvalue = stripslashes($attvalue); 489 | } 490 | 491 | /** 492 | * Kill any tabs, newlines, or carriage returns. Our friends the 493 | * makers of the browser with 95% market value decided that it'd 494 | * be funny to make "java[tab]script" be just as good as "javascript". 495 | * 496 | * @param attvalue The attribute value before extraneous spaces removed. 497 | * @return attvalue Nothing, modifies a reference value. 498 | */ 499 | function tln_unspace(&$attvalue){ 500 | $me = 'tln_unspace'; 501 | if (strcspn($attvalue, "\t\r\n\0 ") != strlen($attvalue)){ 502 | $attvalue = str_replace(Array("\t", "\r", "\n", "\0", " "), 503 | Array('', '', '', '', ''), $attvalue); 504 | } 505 | } 506 | 507 | /** 508 | * This function runs various checks against the attributes. 509 | * 510 | * @param $tagname String with the name of the tag. 511 | * @param $attary Array with all tag attributes. 512 | * @param $rm_attnames See description for tln_sanitize 513 | * @param $bad_attvals See description for tln_sanitize 514 | * @param $add_attr_to_tag See description for tln_sanitize 515 | * @return Array with modified attributes. 516 | */ 517 | function tln_fixatts($tagname, 518 | $attary, 519 | $rm_attnames, 520 | $bad_attvals, 521 | $add_attr_to_tag 522 | ){ 523 | $me = 'tln_fixatts'; 524 | while (list($attname, $attvalue) = each($attary)){ 525 | /** 526 | * See if this attribute should be removed. 527 | */ 528 | foreach ($rm_attnames as $matchtag=>$matchattrs){ 529 | if (preg_match($matchtag, $tagname)){ 530 | foreach ($matchattrs as $matchattr){ 531 | if (preg_match($matchattr, $attname)){ 532 | unset($attary{$attname}); 533 | continue; 534 | } 535 | } 536 | } 537 | } 538 | /** 539 | * Remove any backslashes, entities, or extraneous whitespace. 540 | */ 541 | tln_defang($attvalue); 542 | tln_unspace($attvalue); 543 | 544 | /** 545 | * Now let's run checks on the attvalues. 546 | * I don't expect anyone to comprehend this. If you do, 547 | * get in touch with me so I can drive to where you live and 548 | * shake your hand personally. :) 549 | */ 550 | foreach ($bad_attvals as $matchtag=>$matchattrs){ 551 | if (preg_match($matchtag, $tagname)){ 552 | foreach ($matchattrs as $matchattr=>$valary){ 553 | if (preg_match($matchattr, $attname)){ 554 | /** 555 | * There are two arrays in valary. 556 | * First is matches. 557 | * Second one is replacements 558 | */ 559 | list($valmatch, $valrepl) = $valary; 560 | $newvalue = preg_replace($valmatch,$valrepl,$attvalue); 561 | if ($newvalue != $attvalue){ 562 | $attary{$attname} = $newvalue; 563 | } 564 | } 565 | } 566 | } 567 | } 568 | } 569 | /** 570 | * See if we need to append any attributes to this tag. 571 | */ 572 | foreach ($add_attr_to_tag as $matchtag=>$addattary){ 573 | if (preg_match($matchtag, $tagname)){ 574 | $attary = array_merge($attary, $addattary); 575 | } 576 | } 577 | return $attary; 578 | } 579 | 580 | /** 581 | * 582 | * @param $body the string with HTML you wish to filter 583 | * @param $tag_list see description above 584 | * @param $rm_tags_with_content see description above 585 | * @param $self_closing_tags see description above 586 | * @param $force_tag_closing see description above 587 | * @param $rm_attnames see description above 588 | * @param $bad_attvals see description above 589 | * @param $add_attr_to_tag see description above 590 | * @return tln_sanitized html safe to show on your pages. 591 | */ 592 | function tln_sanitize($body, 593 | $tag_list, 594 | $rm_tags_with_content, 595 | $self_closing_tags, 596 | $force_tag_closing, 597 | $rm_attnames, 598 | $bad_attvals, 599 | $add_attr_to_tag 600 | ) 601 | { 602 | $me = 'tln_sanitize'; 603 | /** 604 | * Normalize rm_tags and rm_tags_with_content. 605 | */ 606 | $rm_tags = array_shift($tag_list); 607 | @array_walk($tag_list, 'tln_casenormalize'); 608 | @array_walk($rm_tags_with_content, 'tln_casenormalize'); 609 | @array_walk($self_closing_tags, 'tln_casenormalize'); 610 | /** 611 | * See if tag_list is of tags to remove or tags to allow. 612 | * false means remove these tags 613 | * true means allow these tags 614 | */ 615 | $curpos = 0; 616 | $open_tags = Array(); 617 | $trusted = "\n"; 618 | $skip_content = false; 619 | /** 620 | * Take care of netscape's stupid javascript entities like 621 | * &{alert('boo')}; 622 | */ 623 | $body = preg_replace('/&(\{.*?\};)/si', '&\\1', $body); 624 | while (($curtag = tln_getnxtag($body, $curpos)) != FALSE){ 625 | list($tagname, $attary, $tagtype, $lt, $gt) = $curtag; 626 | $free_content = substr($body, $curpos, $lt - $curpos); 627 | if ($skip_content == false){ 628 | $trusted .= $free_content; 629 | } else { 630 | } 631 | if ($tagname != FALSE){ 632 | if ($tagtype == 2){ 633 | if ($skip_content == $tagname){ 634 | /** 635 | * Got to the end of tag we needed to remove. 636 | */ 637 | $tagname = false; 638 | $skip_content = false; 639 | } else { 640 | if ($skip_content == false){ 641 | if (isset($open_tags{$tagname}) && 642 | $open_tags{$tagname} > 0){ 643 | $open_tags{$tagname}--; 644 | } else { 645 | $tagname = false; 646 | } 647 | } else { 648 | } 649 | } 650 | } else { 651 | /** 652 | * $rm_tags_with_content 653 | */ 654 | if ($skip_content == false){ 655 | /** 656 | * See if this is a self-closing type and change 657 | * tagtype appropriately. 658 | */ 659 | if ($tagtype == 1 660 | && in_array($tagname, $self_closing_tags)){ 661 | $tagtype = 3; 662 | } 663 | /** 664 | * See if we should skip this tag and any content 665 | * inside it. 666 | */ 667 | if ($tagtype == 1 668 | && in_array($tagname, $rm_tags_with_content)){ 669 | $skip_content = $tagname; 670 | } else { 671 | if (($rm_tags == false 672 | && in_array($tagname, $tag_list)) || 673 | ($rm_tags == true 674 | && !in_array($tagname, $tag_list))){ 675 | $tagname = false; 676 | } else { 677 | if ($tagtype == 1){ 678 | if (isset($open_tags{$tagname})){ 679 | $open_tags{$tagname}++; 680 | } else { 681 | $open_tags{$tagname} = 1; 682 | } 683 | } 684 | /** 685 | * This is where we run other checks. 686 | */ 687 | if (is_array($attary) && sizeof($attary) > 0){ 688 | $attary = tln_fixatts($tagname, 689 | $attary, 690 | $rm_attnames, 691 | $bad_attvals, 692 | $add_attr_to_tag); 693 | } 694 | } 695 | } 696 | } else { 697 | } 698 | } 699 | if ($tagname != false && $skip_content == false){ 700 | $trusted .= tln_tagprint($tagname, $attary, $tagtype); 701 | } 702 | } else { 703 | } 704 | $curpos = $gt + 1; 705 | } 706 | $trusted .= substr($body, $curpos, strlen($body) - $curpos); 707 | if ($force_tag_closing == true){ 708 | foreach ($open_tags as $tagname=>$opentimes){ 709 | while ($opentimes > 0){ 710 | $trusted .= ''; 711 | $opentimes--; 712 | } 713 | } 714 | $trusted .= "\n"; 715 | } 716 | $trusted .= "\n"; 717 | return $trusted; 718 | } 719 | 720 | // 721 | // Use the nifty htmlfilter library 722 | // 723 | 724 | 725 | function HTMLFilter($body, $trans_image_path, $block_external_images = false) { 726 | 727 | $tag_list = Array( 728 | false, 729 | "object", 730 | "meta", 731 | "html", 732 | "head", 733 | "base", 734 | "link", 735 | "frame", 736 | "iframe", 737 | "plaintext", 738 | "marquee" 739 | ); 740 | 741 | $rm_tags_with_content = Array( 742 | "script", 743 | "applet", 744 | "embed", 745 | "title", 746 | "frameset", 747 | "xmp", 748 | "xml" 749 | ); 750 | 751 | $self_closing_tags = Array( 752 | "img", 753 | "br", 754 | "hr", 755 | "input", 756 | "outbind" 757 | ); 758 | 759 | $force_tag_closing = true; 760 | 761 | $rm_attnames = Array( 762 | "/.*/" => 763 | Array( 764 | // "/target/i", 765 | "/^on.*/i", 766 | "/^dynsrc/i", 767 | "/^data.*/i", 768 | "/^lowsrc.*/i" 769 | ) 770 | ); 771 | 772 | $bad_attvals = Array( 773 | "/.*/" => 774 | Array( 775 | "/^src|background/i" => 776 | Array( 777 | Array( 778 | "/^([\'\"])\s*\S+script\s*:.*([\'\"])/si", 779 | "/^([\'\"])\s*mocha\s*:*.*([\'\"])/si", 780 | "/^([\'\"])\s*about\s*:.*([\'\"])/si" 781 | ), 782 | Array( 783 | "\\1$trans_image_path\\2", 784 | "\\1$trans_image_path\\2", 785 | "\\1$trans_image_path\\2", 786 | "\\1$trans_image_path\\2" 787 | ) 788 | ), 789 | "/^href|action/i" => 790 | Array( 791 | Array( 792 | "/^([\'\"])\s*\S+script\s*:.*([\'\"])/si", 793 | "/^([\'\"])\s*mocha\s*:*.*([\'\"])/si", 794 | "/^([\'\"])\s*about\s*:.*([\'\"])/si" 795 | ), 796 | Array( 797 | "\\1#\\1", 798 | "\\1#\\1", 799 | "\\1#\\1", 800 | "\\1#\\1" 801 | ) 802 | ), 803 | "/^style/i" => 804 | Array( 805 | Array( 806 | "/expression/i", 807 | "/binding/i", 808 | "/behaviou*r/i", 809 | "/include-source/i", 810 | "/position\s*:\s*absolute/i", 811 | "/url\s*\(\s*([\'\"])\s*\S+script\s*:.*([\'\"])\s*\)/si", 812 | "/url\s*\(\s*([\'\"])\s*mocha\s*:.*([\'\"])\s*\)/si", 813 | "/url\s*\(\s*([\'\"])\s*about\s*:.*([\'\"])\s*\)/si", 814 | "/(.*)\s*:\s*url\s*\(\s*([\'\"]*)\s*\S+script\s*:.*([\'\"]*)\s*\)/si" 815 | ), 816 | Array( 817 | "idiocy", 818 | "idiocy", 819 | "idiocy", 820 | "idiocy", 821 | "", 822 | "url(\\1#\\1)", 823 | "url(\\1#\\1)", 824 | "url(\\1#\\1)", 825 | "url(\\1#\\1)", 826 | "url(\\1#\\1)", 827 | "\\1:url(\\2#\\3)" 828 | ) 829 | ) 830 | ) 831 | ); 832 | 833 | if ($block_external_images){ 834 | array_push($bad_attvals{'/.*/'}{'/^src|background/i'}[0], 835 | '/^([\'\"])\s*https*:.*([\'\"])/si'); 836 | array_push($bad_attvals{'/.*/'}{'/^src|background/i'}[1], 837 | "\\1$trans_image_path\\1"); 838 | array_push($bad_attvals{'/.*/'}{'/^style/i'}[0], 839 | '/url\(([\'\"])\s*https*:.*([\'\"])\)/si'); 840 | array_push($bad_attvals{'/.*/'}{'/^style/i'}[1], 841 | "url(\\1$trans_image_path\\1)"); 842 | } 843 | 844 | $add_attr_to_tag = Array( 845 | "/^a$/i" => 846 | Array('target'=>'"_blank"') 847 | ); 848 | 849 | $trusted = tln_sanitize($body, 850 | $tag_list, 851 | $rm_tags_with_content, 852 | $self_closing_tags, 853 | $force_tag_closing, 854 | $rm_attnames, 855 | $bad_attvals, 856 | $add_attr_to_tag 857 | ); 858 | return $trusted; 859 | } 860 | 861 | ?> 862 | -------------------------------------------------------------------------------- /PHPMailer/extras/ntlm_sasl_client.php: -------------------------------------------------------------------------------- 1 | "mcrypt", 31 | "mhash"=>"mhash" 32 | ); 33 | $client->error="the extension ".$extensions[$function]." required by the NTLM SASL client class is not available in this PHP configuration"; 34 | return(0); 35 | } 36 | return(1); 37 | } 38 | 39 | Function ASCIIToUnicode($ascii) 40 | { 41 | for($unicode="",$a=0;$aASCIIToUnicode($password); 70 | $md4=mhash(MHASH_MD4,$unicode); 71 | $padded=$md4.str_repeat(chr(0),21-strlen($md4)); 72 | $iv_size=mcrypt_get_iv_size(MCRYPT_DES,MCRYPT_MODE_ECB); 73 | $iv=mcrypt_create_iv($iv_size,MCRYPT_RAND); 74 | for($response="",$third=0;$third<21;$third+=7) 75 | { 76 | for($packed="",$p=$third;$p<$third+7;$p++) 77 | $packed.=str_pad(decbin(ord(substr($padded,$p,1))),8,"0",STR_PAD_LEFT); 78 | for($key="",$p=0;$pASCIIToUnicode($domain); 93 | $domain_length=strlen($domain_unicode); 94 | $domain_offset=64; 95 | $user_unicode=$this->ASCIIToUnicode($user); 96 | $user_length=strlen($user_unicode); 97 | $user_offset=$domain_offset+$domain_length; 98 | $workstation_unicode=$this->ASCIIToUnicode($workstation); 99 | $workstation_length=strlen($workstation_unicode); 100 | $workstation_offset=$user_offset+$user_length; 101 | $lm=""; 102 | $lm_length=strlen($lm); 103 | $lm_offset=$workstation_offset+$workstation_length; 104 | $ntlm=$ntlm_response; 105 | $ntlm_length=strlen($ntlm); 106 | $ntlm_offset=$lm_offset+$lm_length; 107 | $session=""; 108 | $session_length=strlen($session); 109 | $session_offset=$ntlm_offset+$ntlm_length; 110 | return( 111 | "NTLMSSP\0". 112 | "\x03\x00\x00\x00". 113 | pack("v",$lm_length). 114 | pack("v",$lm_length). 115 | pack("V",$lm_offset). 116 | pack("v",$ntlm_length). 117 | pack("v",$ntlm_length). 118 | pack("V",$ntlm_offset). 119 | pack("v",$domain_length). 120 | pack("v",$domain_length). 121 | pack("V",$domain_offset). 122 | pack("v",$user_length). 123 | pack("v",$user_length). 124 | pack("V",$user_offset). 125 | pack("v",$workstation_length). 126 | pack("v",$workstation_length). 127 | pack("V",$workstation_offset). 128 | pack("v",$session_length). 129 | pack("v",$session_length). 130 | pack("V",$session_offset). 131 | "\x01\x02\x00\x00". 132 | $domain_unicode. 133 | $user_unicode. 134 | $workstation_unicode. 135 | $lm. 136 | $ntlm 137 | ); 138 | } 139 | 140 | Function Start(&$client, &$message, &$interactions) 141 | { 142 | if($this->state!=SASL_NTLM_STATE_START) 143 | { 144 | $client->error="NTLM authentication state is not at the start"; 145 | return(SASL_FAIL); 146 | } 147 | $this->credentials=array( 148 | "user"=>"", 149 | "password"=>"", 150 | "realm"=>"", 151 | "workstation"=>"" 152 | ); 153 | $defaults=array(); 154 | $status=$client->GetCredentials($this->credentials,$defaults,$interactions); 155 | if($status==SASL_CONTINUE) 156 | $this->state=SASL_NTLM_STATE_IDENTIFY_DOMAIN; 157 | Unset($message); 158 | return($status); 159 | } 160 | 161 | Function Step(&$client, $response, &$message, &$interactions) 162 | { 163 | switch($this->state) 164 | { 165 | case SASL_NTLM_STATE_IDENTIFY_DOMAIN: 166 | $message=$this->TypeMsg1($this->credentials["realm"],$this->credentials["workstation"]); 167 | $this->state=SASL_NTLM_STATE_RESPOND_CHALLENGE; 168 | break; 169 | case SASL_NTLM_STATE_RESPOND_CHALLENGE: 170 | $ntlm_response=$this->NTLMResponse(substr($response,24,8),$this->credentials["password"]); 171 | $message=$this->TypeMsg3($ntlm_response,$this->credentials["user"],$this->credentials["realm"],$this->credentials["workstation"]); 172 | $this->state=SASL_NTLM_STATE_DONE; 173 | break; 174 | case SASL_NTLM_STATE_DONE: 175 | $client->error="NTLM authentication was finished without success"; 176 | return(SASL_FAIL); 177 | default: 178 | $client->error="invalid NTLM authentication step state"; 179 | return(SASL_FAIL); 180 | } 181 | return(SASL_CONTINUE); 182 | } 183 | }; 184 | 185 | ?> -------------------------------------------------------------------------------- /PHPMailer/language/phpmailer.lang-ar.php: -------------------------------------------------------------------------------- 1 | 6 | */ 7 | 8 | $PHPMAILER_LANG['authenticate'] = 'SMTP Error: لم نستطع تأكيد الهوية.'; 9 | $PHPMAILER_LANG['connect_host'] = 'SMTP Error: لم نستطع الاتصال بمخدم SMTP.'; 10 | $PHPMAILER_LANG['data_not_accepted'] = 'SMTP Error: لم يتم قبول المعلومات .'; 11 | //$PHPMAILER_LANG['empty_message'] = 'Message body empty'; 12 | $PHPMAILER_LANG['encoding'] = 'ترميز غير معروف: '; 13 | $PHPMAILER_LANG['execute'] = 'لم أستطع تنفيذ : '; 14 | $PHPMAILER_LANG['file_access'] = 'لم نستطع الوصول للملف: '; 15 | $PHPMAILER_LANG['file_open'] = 'File Error: لم نستطع فتح الملف: '; 16 | $PHPMAILER_LANG['from_failed'] = 'البريد التالي لم نستطع ارسال البريد له : '; 17 | $PHPMAILER_LANG['instantiate'] = 'لم نستطع توفير خدمة البريد.'; 18 | //$PHPMAILER_LANG['invalid_address'] = 'Not sending, email address is invalid: '; 19 | $PHPMAILER_LANG['mailer_not_supported'] = ' mailer غير مدعوم.'; 20 | //$PHPMAILER_LANG['provide_address'] = 'You must provide at least one recipient email address.'; 21 | $PHPMAILER_LANG['recipients_failed'] = 'SMTP Error: الأخطاء التالية ' . 22 | 'فشل في الارسال لكل من : '; 23 | $PHPMAILER_LANG['signing'] = 'خطأ في التوقيع: '; 24 | //$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.'; 25 | //$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: '; 26 | //$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: '; 27 | -------------------------------------------------------------------------------- /PHPMailer/language/phpmailer.lang-br.php: -------------------------------------------------------------------------------- 1 | 6 | */ 7 | 8 | $PHPMAILER_LANG['authenticate'] = 'SMTP fejl: Kunne ikke logge på.'; 9 | $PHPMAILER_LANG['connect_host'] = 'SMTP fejl: Kunne ikke tilslutte SMTP serveren.'; 10 | $PHPMAILER_LANG['data_not_accepted'] = 'SMTP fejl: Data kunne ikke accepteres.'; 11 | //$PHPMAILER_LANG['empty_message'] = 'Message body empty'; 12 | $PHPMAILER_LANG['encoding'] = 'Ukendt encode-format: '; 13 | $PHPMAILER_LANG['execute'] = 'Kunne ikke køre: '; 14 | $PHPMAILER_LANG['file_access'] = 'Ingen adgang til fil: '; 15 | $PHPMAILER_LANG['file_open'] = 'Fil fejl: Kunne ikke åbne filen: '; 16 | $PHPMAILER_LANG['from_failed'] = 'Følgende afsenderadresse er forkert: '; 17 | $PHPMAILER_LANG['instantiate'] = 'Kunne ikke initialisere email funktionen.'; 18 | //$PHPMAILER_LANG['invalid_address'] = 'Not sending, email address is invalid: '; 19 | $PHPMAILER_LANG['mailer_not_supported'] = ' mailer understøttes ikke.'; 20 | $PHPMAILER_LANG['provide_address'] = 'Du skal indtaste mindst en modtagers emailadresse.'; 21 | $PHPMAILER_LANG['recipients_failed'] = 'SMTP fejl: Følgende modtagere er forkerte: '; 22 | //$PHPMAILER_LANG['signing'] = 'Signing Error: '; 23 | //$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.'; 24 | //$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: '; 25 | //$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: '; 26 | -------------------------------------------------------------------------------- /PHPMailer/language/phpmailer.lang-es.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | 9 | $PHPMAILER_LANG['authenticate'] = 'SMTP Error: Impossibile autenticarsi.'; 10 | $PHPMAILER_LANG['connect_host'] = 'SMTP Error: Impossibile connettersi all\'host SMTP.'; 11 | $PHPMAILER_LANG['data_not_accepted'] = 'SMTP Error: Data non accettati dal server.'; 12 | //$PHPMAILER_LANG['empty_message'] = 'Message body empty'; 13 | $PHPMAILER_LANG['encoding'] = 'Encoding set dei caratteri sconosciuto: '; 14 | $PHPMAILER_LANG['execute'] = 'Impossibile eseguire l\'operazione: '; 15 | $PHPMAILER_LANG['file_access'] = 'Impossibile accedere al file: '; 16 | $PHPMAILER_LANG['file_open'] = 'File Error: Impossibile aprire il file: '; 17 | $PHPMAILER_LANG['from_failed'] = 'I seguenti indirizzi mittenti hanno generato errore: '; 18 | $PHPMAILER_LANG['instantiate'] = 'Impossibile istanziare la funzione mail'; 19 | //$PHPMAILER_LANG['invalid_address'] = 'Not sending, email address is invalid: '; 20 | $PHPMAILER_LANG['provide_address'] = 'Deve essere fornito almeno un indirizzo ricevente'; 21 | $PHPMAILER_LANG['mailer_not_supported'] = 'Mailer non supportato'; 22 | $PHPMAILER_LANG['recipients_failed'] = 'SMTP Error: I seguenti indirizzi destinatari hanno generato errore: '; 23 | //$PHPMAILER_LANG['signing'] = 'Signing Error: '; 24 | //$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.'; 25 | //$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: '; 26 | //$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: '; 27 | -------------------------------------------------------------------------------- /PHPMailer/language/phpmailer.lang-ja.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | 9 | $PHPMAILER_LANG['authenticate'] = 'Eroare SMTP: Nu a functionat autentificarea.'; 10 | $PHPMAILER_LANG['connect_host'] = 'Eroare SMTP: Nu m-am putut conecta la adresa SMTP.'; 11 | $PHPMAILER_LANG['data_not_accepted'] = 'Eroare SMTP: Continutul mailului nu a fost acceptat.'; 12 | //$PHPMAILER_LANG['empty_message'] = 'Message body empty'; 13 | $PHPMAILER_LANG['encoding'] = 'Encodare necunoscuta: '; 14 | $PHPMAILER_LANG['execute'] = 'Nu pot executa: '; 15 | $PHPMAILER_LANG['file_access'] = 'Nu pot accesa fisierul: '; 16 | $PHPMAILER_LANG['file_open'] = 'Eroare de fisier: Nu pot deschide fisierul: '; 17 | $PHPMAILER_LANG['from_failed'] = 'Urmatoarele adrese From au dat eroare: '; 18 | $PHPMAILER_LANG['instantiate'] = 'Nu am putut instantia functia mail.'; 19 | //$PHPMAILER_LANG['invalid_address'] = 'Not sending, email address is invalid: '; 20 | $PHPMAILER_LANG['mailer_not_supported'] = ' mailer nu este suportat.'; 21 | $PHPMAILER_LANG['provide_address'] = 'Trebuie sa adaugati cel putin un recipient (adresa de mail).'; 22 | $PHPMAILER_LANG['recipients_failed'] = 'Eroare SMTP: Urmatoarele adrese de mail au dat eroare: '; 23 | //$PHPMAILER_LANG['signing'] = 'Signing Error: '; 24 | //$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.'; 25 | //$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: '; 26 | //$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: '; 27 | -------------------------------------------------------------------------------- /PHPMailer/language/phpmailer.lang-ru.php: -------------------------------------------------------------------------------- 1 | 5 | */ 6 | 7 | $PHPMAILER_LANG['authenticate'] = 'Ошибка SMTP: ошибка авторизации.'; 8 | $PHPMAILER_LANG['connect_host'] = 'Ошибка SMTP: не удается подключиться к серверу SMTP.'; 9 | $PHPMAILER_LANG['data_not_accepted'] = 'Ошибка SMTP: данные не приняты.'; 10 | //$PHPMAILER_LANG['empty_message'] = 'Message body empty'; 11 | $PHPMAILER_LANG['encoding'] = 'Неизвестный вид кодировки: '; 12 | $PHPMAILER_LANG['execute'] = 'Невозможно выполнить команду: '; 13 | $PHPMAILER_LANG['file_access'] = 'Нет доступа к файлу: '; 14 | $PHPMAILER_LANG['file_open'] = 'Файловая ошибка: не удается открыть файл: '; 15 | $PHPMAILER_LANG['from_failed'] = 'Неверный адрес отправителя: '; 16 | $PHPMAILER_LANG['instantiate'] = 'Невозможно запустить функцию mail.'; 17 | //$PHPMAILER_LANG['invalid_address'] = 'Not sending, email address is invalid: '; 18 | $PHPMAILER_LANG['provide_address'] = 'Пожалуйста, введите хотя бы один адрес e-mail получателя.'; 19 | $PHPMAILER_LANG['mailer_not_supported'] = ' - почтовый сервер не поддерживается.'; 20 | $PHPMAILER_LANG['recipients_failed'] = 'Ошибка SMTP: отправка по следующим адресам получателей не удалась: '; 21 | //$PHPMAILER_LANG['signing'] = 'Signing Error: '; 22 | //$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.'; 23 | //$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: '; 24 | //$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: '; 25 | -------------------------------------------------------------------------------- /PHPMailer/language/phpmailer.lang-se.php: -------------------------------------------------------------------------------- 1 | 6 | */ 7 | 8 | $PHPMAILER_LANG['authenticate'] = 'SMTP fel: Kunde inte autentisera.'; 9 | $PHPMAILER_LANG['connect_host'] = 'SMTP fel: Kunde inte ansluta till SMTP-server.'; 10 | $PHPMAILER_LANG['data_not_accepted'] = 'SMTP fel: Data accepterades inte.'; 11 | //$PHPMAILER_LANG['empty_message'] = 'Message body empty'; 12 | $PHPMAILER_LANG['encoding'] = 'Okänt encode-format: '; 13 | $PHPMAILER_LANG['execute'] = 'Kunde inte köra: '; 14 | $PHPMAILER_LANG['file_access'] = 'Ingen åtkomst till fil: '; 15 | $PHPMAILER_LANG['file_open'] = 'Fil fel: Kunde inte öppna fil: '; 16 | $PHPMAILER_LANG['from_failed'] = 'Följande avsändaradress är felaktig: '; 17 | $PHPMAILER_LANG['instantiate'] = 'Kunde inte initiera e-postfunktion.'; 18 | //$PHPMAILER_LANG['invalid_address'] = 'Not sending, email address is invalid: '; 19 | $PHPMAILER_LANG['provide_address'] = 'Du måste ange minst en mottagares e-postadress.'; 20 | $PHPMAILER_LANG['mailer_not_supported'] = ' mailer stöds inte.'; 21 | $PHPMAILER_LANG['recipients_failed'] = 'SMTP fel: Följande mottagare är felaktig: '; 22 | //$PHPMAILER_LANG['signing'] = 'Signing Error: '; 23 | //$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.'; 24 | //$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: '; 25 | //$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: '; 26 | -------------------------------------------------------------------------------- /PHPMailer/language/phpmailer.lang-sk.php: -------------------------------------------------------------------------------- 1 | 6 | */ 7 | 8 | $PHPMAILER_LANG['authenticate'] = 'SMTP Error: Chyba autentifikácie.'; 9 | $PHPMAILER_LANG['connect_host'] = 'SMTP Error: Nebolo možné nadviazať spojenie so SMTP serverom.'; 10 | $PHPMAILER_LANG['data_not_accepted'] = 'SMTP Error: Dáta neboli prijaté'; 11 | $PHPMAILER_LANG['empty_message'] = 'Prázdne telo správy.'; 12 | $PHPMAILER_LANG['encoding'] = 'Neznáme kódovanie: '; 13 | $PHPMAILER_LANG['execute'] = 'Nedá sa vykonať: '; 14 | $PHPMAILER_LANG['file_access'] = 'Súbor nebol nájdený: '; 15 | $PHPMAILER_LANG['file_open'] = 'File Error: Súbor sa otvoriť pre čítanie: '; 16 | $PHPMAILER_LANG['from_failed'] = 'Následujúca adresa From je nesprávna: '; 17 | $PHPMAILER_LANG['instantiate'] = 'Nedá sa vytvoriť inštancia emailovej funkcie.'; 18 | $PHPMAILER_LANG['invalid_address'] = 'Neodoslané, emailová adresa je nesprávna: '; 19 | $PHPMAILER_LANG['mailer_not_supported'] = ' emailový klient nieje podporovaný.'; 20 | $PHPMAILER_LANG['provide_address'] = 'Musíte zadať aspoň jednu emailovú adresu príjemcu.'; 21 | $PHPMAILER_LANG['recipients_failed'] = 'SMTP Error: Adresy príjemcov niesu správne '; 22 | $PHPMAILER_LANG['signing'] = 'Chyba prihlasovania: '; 23 | $PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() zlyhalo.'; 24 | $PHPMAILER_LANG['smtp_error'] = 'SMTP chyba serveru: '; 25 | $PHPMAILER_LANG['variable_set'] = 'Nemožno nastaviť alebo resetovať premennú: '; 26 | -------------------------------------------------------------------------------- /PHPMailer/language/phpmailer.lang-tr.php: -------------------------------------------------------------------------------- 1 | 6 | */ 7 | 8 | $PHPMAILER_LANG['authenticate'] = 'SMTP 錯誤:登錄失敗。'; 9 | $PHPMAILER_LANG['connect_host'] = 'SMTP 錯誤:無法連接到 SMTP 主機。'; 10 | $PHPMAILER_LANG['data_not_accepted'] = 'SMTP 錯誤:數據不被接受。'; 11 | //$PHPMAILER_LANG['empty_message'] = 'Message body empty'; 12 | $PHPMAILER_LANG['encoding'] = '未知編碼: '; 13 | $PHPMAILER_LANG['file_access'] = '無法訪問文件:'; 14 | $PHPMAILER_LANG['file_open'] = '文件錯誤:無法打開文件:'; 15 | $PHPMAILER_LANG['from_failed'] = '發送地址錯誤:'; 16 | $PHPMAILER_LANG['execute'] = '無法執行:'; 17 | $PHPMAILER_LANG['instantiate'] = '未知函數調用。'; 18 | //$PHPMAILER_LANG['invalid_address'] = 'Not sending, email address is invalid: '; 19 | $PHPMAILER_LANG['provide_address'] = '必須提供至少一個收件人地址。'; 20 | $PHPMAILER_LANG['mailer_not_supported'] = '發信客戶端不被支持。'; 21 | $PHPMAILER_LANG['recipients_failed'] = 'SMTP 錯誤:收件人地址錯誤:'; 22 | //$PHPMAILER_LANG['signing'] = 'Signing Error: '; 23 | //$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.'; 24 | //$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: '; 25 | //$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: '; 26 | -------------------------------------------------------------------------------- /PHPMailer/language/phpmailer.lang-zh_cn.php: -------------------------------------------------------------------------------- 1 | 6 | */ 7 | 8 | $PHPMAILER_LANG['authenticate'] = 'SMTP 错误:登录失败。'; 9 | $PHPMAILER_LANG['connect_host'] = 'SMTP 错误:无法连接到 SMTP 主机。'; 10 | $PHPMAILER_LANG['data_not_accepted'] = 'SMTP 错误:数据不被接受。'; 11 | //$P$PHPMAILER_LANG['empty_message'] = 'Message body empty'; 12 | $PHPMAILER_LANG['encoding'] = '未知编码: '; 13 | $PHPMAILER_LANG['execute'] = '无法执行:'; 14 | $PHPMAILER_LANG['file_access'] = '无法访问文件:'; 15 | $PHPMAILER_LANG['file_open'] = '文件错误:无法打开文件:'; 16 | $PHPMAILER_LANG['from_failed'] = '发送地址错误:'; 17 | $PHPMAILER_LANG['instantiate'] = '未知函数调用。'; 18 | //$PHPMAILER_LANG['invalid_address'] = 'Not sending, email address is invalid: '; 19 | $PHPMAILER_LANG['mailer_not_supported'] = '发信客户端不被支持。'; 20 | $PHPMAILER_LANG['provide_address'] = '必须提供至少一个收件人地址。'; 21 | $PHPMAILER_LANG['recipients_failed'] = 'SMTP 错误:收件人地址错误:'; 22 | //$PHPMAILER_LANG['signing'] = 'Signing Error: '; 23 | //$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.'; 24 | //$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: '; 25 | //$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: '; 26 | -------------------------------------------------------------------------------- /config.php: -------------------------------------------------------------------------------- 1 | \n"; 33 | $mbox = imap_open ($host, $email_receive_username, $email_receive_password); 34 | if(!$mbox){ 35 | echo 'Failed to connect to account. Error is: '.imap_last_error(); 36 | imap_errors(); 37 | exit; 38 | } 39 | 40 | $MC = imap_check($mbox); 41 | if($debug)echo 'Connected successfully. Got this many messages: '.$MC->Nmsgs ."
\n"; 42 | 43 | $search_results = array(-1); // -1 is all messages 44 | if($email_receive_mode=='imap' && $search_string){ 45 | //imap_sort($mbox,SORTARRIVAL,0); 46 | // we do a hack to support multiple searches in the imap string. 47 | if(strpos($search_string,'||')){ 48 | $search_strings = explode('||',$search_string); 49 | }else{ 50 | $search_strings = array($search_string); 51 | } 52 | $search_results = array(); 53 | foreach($search_strings as $this_search_string){ 54 | $this_search_string = trim($this_search_string); 55 | if(!$this_search_string){ 56 | return false; 57 | } 58 | if($debug)echo "Searching for $this_search_string
\n"; 59 | $this_search_results = imap_search($mbox,$this_search_string); 60 | if($debug)echo " -- found ". ($this_search_results ? count($this_search_results) : 'no')." results
\n"; 61 | print_r($this_search_results); 62 | if($this_search_results){ 63 | $search_results = array_merge($search_results,$this_search_results); 64 | } 65 | } 66 | if(!$search_results){ 67 | if($debug)echo "No search results for $search_string
\n"; 68 | exit; 69 | }else{ 70 | sort($search_results); 71 | } 72 | } 73 | imap_errors(); 74 | 75 | $sorted_emails = array(); 76 | foreach($search_results as $search_result){ 77 | if($search_result>=0){ 78 | $result = imap_fetch_overview($mbox,$search_result,0); 79 | }else{ 80 | $result = imap_fetch_overview($mbox,"1:". min(100,$MC->Nmsgs),0); 81 | } 82 | foreach ($result as $overview) { 83 | if(!isset($overview->subject) && !$overview->date)continue; // skip these ones without dates and subjects? 84 | if(strpos($overview->subject,'Re:')!==false){ 85 | if($debug){ 86 | // not sure if this is the best thing to do. oh well. 87 | echo "Ignoring this email subject '".$overview->subject."' because it has 'Re:' in it.
\n"; 88 | } 89 | continue; 90 | } 91 | $message_id = isset($overview->message_id) ? (string)$overview->message_id : false; 92 | $overview->time = strtotime($overview->date); 93 | $sorted_emails [] = $overview; 94 | } 95 | } 96 | function dtbaker_ticket_import_sort($a,$b){ 97 | return $a->time > $b->time; 98 | } 99 | uasort($sorted_emails,'dtbaker_ticket_import_sort'); 100 | // finished sorted our emails into a nice $sorted_emails array. 101 | 102 | 103 | $message_number = 0; 104 | 105 | require_once 'PHPMailer/class.phpmailer.php'; 106 | require_once 'PHPMailer/class.smtp.php'; 107 | 108 | 109 | $mail = new PHPMailer; 110 | 111 | $mail->CharSet = 'UTF-8'; 112 | 113 | $mail->IsSMTP(); // Set mailer to use SMTP 114 | $mail->Host = $email_send_host; // Specify main and backup server 115 | $mail->SMTPAuth = $email_send_smtpauth; // Enable SMTP authentication 116 | $mail->Username = $email_send_username; // SMTP username 117 | $mail->Password = $email_send_password; // SMTP password 118 | $mail->SMTPSecure = $email_send_smtpsecure; // Enable encryption, 'ssl' also accepted 119 | $mail->Port = $email_send_port; // Port 120 | 121 | 122 | 123 | foreach($sorted_emails as $overview){ 124 | 125 | $body = file_get_contents('template.html'); 126 | 127 | $message_number++; 128 | $message_id = (string)$overview->message_id; 129 | if($debug){ 130 | ?> 131 |
132 | Found email: # 133 | Date: date;?>
134 | Subject: subject);?>
135 | From: from);?>
136 | To: to);?>
137 | Message ID: 138 |
139 | \n"; 144 | } 145 | continue; 146 | } 147 | // mark this email as seen. useful if we're searching based on "UNSEEN" emails. 148 | $status = imap_setflag_full($mbox, $overview->msgno, "\\Seen"); 149 | 150 | 151 | //clear addresses 152 | $mail->ClearAddresses(); 153 | 154 | $mail->From = $email_from; 155 | $mail->FromName = $email_from_name; 156 | 157 | //Add a recipient 158 | $mail->AddAddress($overview->from); 159 | 160 | // Add BCC 161 | if(!empty($email_bcc)) $mail->AddBCC($email_bcc); 162 | 163 | $mail->IsHTML(true); 164 | 165 | $mail->Subject = 'Re: '.$overview->subject; 166 | 167 | $replace = array( 168 | '{preheader}' => '', 169 | '{subject}' => $mail->Subject, 170 | '{senddate}' => date($timeformat, strtotime($overview->date)), 171 | '{date}' => date($timeformat), 172 | 173 | ); 174 | 175 | //replace placeholders 176 | $body = str_replace(array_keys($replace), array_values($replace), $body); 177 | 178 | //remove all missing placeholders 179 | $body = preg_replace('#{\w+}#', '', $body); 180 | 181 | $mail->Body = $body; 182 | 183 | if(!$mail->Send()) { 184 | if($debug){ 185 | echo 'Message could not be sent.'; 186 | echo 'Mailer Error: ' . $mail->ErrorInfo; 187 | continue; 188 | } 189 | }else{ 190 | if($debug){ 191 | echo 'Message sent to '.$overview->from; 192 | } 193 | } 194 | } 195 | -------------------------------------------------------------------------------- /template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {subject} 4 | 5 | 6 |

Hello, {name}

7 | This email address is not monitored.

8 | Please send any support requests via our dedicated support website located here:
9 | http://dtbaker.net/envato/

10 | Kind Regards,
11 | dtbaker 12 |

13 | 14 | 15 | --------------------------------------------------------------------------------