From be6f6797244cc28202859f5bba2f16d7584cc946 Mon Sep 17 00:00:00 2001 From: Javier Casares Date: Thu, 29 Jan 2026 09:57:28 +0000 Subject: [PATCH] v2.0.0 --- LICENSE | 674 ++ assets/css/admin.css | 44 +- assets/js/admin.js | 104 +- changelog.txt | 50 +- includes/class-plugin.php | 1943 ++- includes/class-robotstxt-smtp-encryption.php | 222 + includes/class-settings-page.php | 10658 +++++++++-------- includes/class-smtp-diagnostics-client.php | 216 +- includes/class-statistics.php | 287 + languages/robotstxt-smtp-ca.mo | Bin 0 -> 33316 bytes languages/robotstxt-smtp-ca.po | 1479 +++ languages/robotstxt-smtp-es_ES.mo | Bin 0 -> 33741 bytes languages/robotstxt-smtp-es_ES.po | 1479 +++ languages/robotstxt-smtp.pot | 1374 +++ readme.txt | 172 +- robotstxt-smtp.php | 251 +- robotstxt-updater.php | 383 + uninstall.php | 310 +- update.json | 27 + 19 files changed, 13721 insertions(+), 5952 deletions(-) create mode 100644 LICENSE create mode 100644 includes/class-robotstxt-smtp-encryption.php create mode 100644 includes/class-statistics.php create mode 100644 languages/robotstxt-smtp-ca.mo create mode 100644 languages/robotstxt-smtp-ca.po create mode 100644 languages/robotstxt-smtp-es_ES.mo create mode 100644 languages/robotstxt-smtp-es_ES.po create mode 100644 languages/robotstxt-smtp.pot create mode 100644 robotstxt-updater.php create mode 100644 update.json diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e72bfdd --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. \ No newline at end of file diff --git a/assets/css/admin.css b/assets/css/admin.css index cf82263..14f4b07 100644 --- a/assets/css/admin.css +++ b/assets/css/admin.css @@ -1,22 +1,22 @@ -.robotstxt-smtp-tools .card { - width: 100%; - max-width: 100%; - box-sizing: border-box; -} - -.robotstxt-smtp-tools .robotstxt-smtp-tool-empty { - margin-top: 1em; -} - -.robotstxt-smtp-tools .robotstxt-smtp-tool-meta { - margin: 1em 0; - font-style: italic; -} - -.robotstxt-smtp-tools .robotstxt-smtp-tool-actions { - margin: 1em 0; -} - -.robotstxt-smtp-tools .robotstxt-smtp-tool-result { - margin-top: 1.5em; -} +.robotstxt-smtp-tools .card { + width: 100%; + max-width: 100%; + box-sizing: border-box; +} + +.robotstxt-smtp-tools .robotstxt-smtp-tool-empty { + margin-top: 1em; +} + +.robotstxt-smtp-tools .robotstxt-smtp-tool-meta { + margin: 1em 0; + font-style: italic; +} + +.robotstxt-smtp-tools .robotstxt-smtp-tool-actions { + margin: 1em 0; +} + +.robotstxt-smtp-tools .robotstxt-smtp-tool-result { + margin-top: 1.5em; +} diff --git a/assets/js/admin.js b/assets/js/admin.js index 4f380ee..63cb4b2 100644 --- a/assets/js/admin.js +++ b/assets/js/admin.js @@ -1,52 +1,52 @@ -/** - * Admin UI behavior for Robotstxt SMTP settings. - * - * @package RobotstxtSMTP - */ - -(function () { - 'use strict'; - - var initializeAdmin = function () { - var security = document.getElementById( 'robotstxt_smtp_security' ); - var port = document.getElementById( 'robotstxt_smtp_port' ); - - if ( ! security || ! port) { - return; - } - - var defaultPorts = { - none: 25, - ssl: 465, - tls: 587 - }; - - var previousValue = security.value || 'none'; - - security.addEventListener( - 'change', - function () { - var newValue = security.value || 'none'; - var previousDefault = Object.prototype.hasOwnProperty.call( defaultPorts, previousValue ) - ? defaultPorts[previousValue] - : null; - var newDefault = Object.prototype.hasOwnProperty.call( defaultPorts, newValue ) - ? defaultPorts[newValue] - : null; - var currentPort = parseInt( port.value, 10 ); - - if ( ! Number.isNaN( currentPort ) && null !== previousDefault && currentPort === previousDefault && null !== newDefault) { - port.value = newDefault; - } - - previousValue = newValue; - } - ); - }; - - if ('loading' !== document.readyState) { - initializeAdmin(); - } else { - document.addEventListener( 'DOMContentLoaded', initializeAdmin ); - } -})(); +/** + * Admin UI behavior for Robotstxt SMTP settings. + * + * @package RobotstxtSMTP + */ + +(function () { + 'use strict'; + + var initializeAdmin = function () { + var security = document.getElementById( 'robotstxt_smtp_security' ); + var port = document.getElementById( 'robotstxt_smtp_port' ); + + if ( ! security || ! port) { + return; + } + + var defaultPorts = { + none: 25, + ssl: 465, + tls: 587 + }; + + var previousValue = security.value || 'none'; + + security.addEventListener( + 'change', + function () { + var newValue = security.value || 'none'; + var previousDefault = Object.prototype.hasOwnProperty.call( defaultPorts, previousValue ) + ? defaultPorts[previousValue] + : null; + var newDefault = Object.prototype.hasOwnProperty.call( defaultPorts, newValue ) + ? defaultPorts[newValue] + : null; + var currentPort = parseInt( port.value, 10 ); + + if ( ! Number.isNaN( currentPort ) && null !== previousDefault && currentPort === previousDefault && null !== newDefault) { + port.value = newDefault; + } + + previousValue = newValue; + } + ); + }; + + if ('loading' !== document.readyState) { + initializeAdmin(); + } else { + document.addEventListener( 'DOMContentLoaded', initializeAdmin ); + } +})(); diff --git a/changelog.txt b/changelog.txt index 7e0f46b..9f5bd82 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,19 +1,31 @@ -= 1.2.0 = - -* Logged failed email deliveries with status and error details in the log list and detail views. -* Captured the SMTP debug conversation for each email and surfaced it inside the log detail view. -* Fixed fatal errors in the SMTP bootstrap by restoring configuration and log cleanup hooks. - -= 1.1.0 = - -* Added Amazon SES credential fields, regional selection, and live validation helpers that appear when the Amazon SES add-on is active. -* Introduced the `robotstxt_smtp_sanitized_options` filter so add-ons can adjust sanitized settings before they are stored. -* Routed SMTP test messages and regular WordPress emails through Amazon SES whenever the add-on supplies valid credentials. - -= 1.0.0 = - -* Contextual help guidance in every SMTP configuration field. -* Automatic port updates when selecting an encryption method with standard values. -* Advanced tools: MX analysis, SPF/DKIM/DMARC validation, extended SMTP diagnostics, and blacklist monitoring. -* Enhanced logging with automatic cleanup by limit or age. -* Updated documentation for the 1.0.0 release with WordPress 6.7 and PHP 8.2 support. += 2.0.0 = + +* Comprehensive security audit and hardening. +* Enhanced nonce validation across all forms and actions. +* Improved input sanitization and validation. +* Enhanced password encryption and migration system. +* Secure handling of superglobals and transients. +* Strengthened regex patterns and port number validation. +* Fixed potential security vulnerabilities in form handling. +* Added Reply-To email and name configuration fields for custom reply addresses. +* Added email statistics tracking system with daily counters and visual charts. +* Added statistics page with Chart.js visualization and multisite support. +* Added statistics retention settings (configurable from 1 to 365 days). +* Access control and form handling improvements. +* WordPress Multisite rate limiting enhancements. +* Empty password field handling. +* Code quality improvements throughout the plugin. + += 1.1.0 = + +* Added Amazon SES credential fields, regional selection, and live validation helpers that appear when the Amazon SES add-on is active. +* Introduced the `robotstxt_smtp_sanitized_options` filter so add-ons can adjust sanitized settings before they are stored. +* Routed SMTP test messages and regular WordPress emails through Amazon SES whenever the add-on supplies valid credentials. + += 1.0.0 = + +* Contextual help guidance in every SMTP configuration field. +* Automatic port updates when selecting an encryption method with standard values. +* Advanced tools: MX analysis, SPF/DKIM/DMARC validation, extended SMTP diagnostics, and blacklist monitoring. +* Enhanced logging with automatic cleanup by limit or age. +* Updated documentation for the 1.0.0 release with WordPress 6.7 and PHP 8.2 support. diff --git a/includes/class-plugin.php b/includes/class-plugin.php index 2dbe43b..a3bf3bb 100644 --- a/includes/class-plugin.php +++ b/includes/class-plugin.php @@ -1,664 +1,1279 @@ - - */ - private array $current_debug_log = array(); - - /** - * Retrieves the plugin instance. - * - * @return Plugin Plugin instance. - */ - public static function get_instance(): Plugin { - if ( null === self::$instance ) { - self::$instance = new self(); - } - - return self::$instance; - } - - /** - * Determines whether the Amazon SES integration plugin is active. - * - * @return bool - */ - public static function is_amazon_ses_integration_active(): bool { - /** - * Filters whether the Amazon SES integration should be considered active. - * - * @since 1.0.1 - * - * @param bool $is_active True when the Amazon SES add-on is active. - */ - return (bool) \apply_filters( 'robotstxt_smtp_amazon_ses_active', false ); - } - - /** - * Sets up the plugin. - * - * @return void - */ - public function run(): void { - add_action( 'phpmailer_init', array( $this, 'configure_phpmailer' ) ); - add_filter( 'wp_mail_from', array( $this, 'filter_mail_from' ) ); - add_filter( 'wp_mail_from_name', array( $this, 'filter_mail_from_name' ) ); - - add_action( 'init', array( $this, 'register_log_post_type' ) ); - add_action( 'init', array( $this, 'maybe_schedule_cleanup' ) ); - add_action( 'wp_mail_succeeded', array( $this, 'handle_wp_mail_succeeded' ) ); - add_action( 'wp_mail_failed', array( $this, 'handle_wp_mail_failed' ) ); - add_action( self::CRON_HOOK, array( $this, 'cleanup_logs' ) ); - - if ( is_admin() ) { - $this->register_admin(); - } - } - - /** - * Registers the admin functionality. - * - * @return void - */ - private function register_admin(): void { - if ( null === $this->settings_page ) { - $this->settings_page = new Settings_Page(); - } - - $this->settings_page->register_hooks(); - } - - /** - * Registers the custom post type used to store email logs. - * - * @return void - */ - public function register_log_post_type(): void { - register_post_type( - self::LOG_POST_TYPE, - array( - 'labels' => array( - 'name' => esc_html__( 'SMTP Logs', 'robotstxt-smtp' ), - 'singular_name' => esc_html__( 'SMTP Log', 'robotstxt-smtp' ), - ), - 'public' => false, - 'show_ui' => false, - 'show_in_menu' => false, - 'show_in_nav_menus' => false, - 'exclude_from_search' => true, - 'publicly_queryable' => false, - 'supports' => array( 'title', 'editor' ), - 'capability_type' => 'post', - 'map_meta_cap' => true, - ) - ); - } - - /** - * Schedules or clears the automatic log cleanup task based on settings. - * - * @return void - */ - public function maybe_schedule_cleanup(): void { - $logging = $this->get_logging_settings(); - - if ( ! $logging['enabled'] ) { - wp_clear_scheduled_hook( self::CRON_HOOK ); - return; - } - - if ( false === wp_next_scheduled( self::CRON_HOOK ) ) { - wp_schedule_event( time() + HOUR_IN_SECONDS, 'daily', self::CRON_HOOK ); - } - } - - /** - * Filters the "From" email address used by WordPress. - * - * @param string $original_email Original email address provided by WordPress. - * - * @return string - */ - public function filter_mail_from( string $original_email ): string { - $settings = $this->get_mailer_settings(); - $from_email = isset( $settings['from_email'] ) ? sanitize_email( $settings['from_email'] ) : ''; - - if ( empty( $from_email ) ) { - return sanitize_email( $original_email ); - } - - return $from_email; - } - - /** - * Filters the "From" name used by WordPress. - * - * @param string $original_name Original name provided by WordPress. - * - * @return string - */ - public function filter_mail_from_name( string $original_name ): string { - $settings = $this->get_mailer_settings(); - $from_name = isset( $settings['from_name'] ) ? sanitize_text_field( $settings['from_name'] ) : ''; - - if ( '' === $from_name ) { - return sanitize_text_field( $original_name ); - } - - return $from_name; - } - - /** - * Retrieves the stored mailer settings merged with defaults. - * - * @return array - */ - private function get_mailer_settings(): array { - $defaults = Settings_Page::get_default_settings(); - - if ( Settings_Page::is_network_mode_enabled() ) { - $settings = get_site_option( Settings_Page::NETWORK_OPTION_NAME, array() ); - } else { - $settings = get_option( Settings_Page::OPTION_NAME, array() ); - } - - if ( ! is_array( $settings ) ) { - $settings = array(); - } - - $settings = wp_parse_args( $settings, $defaults ); - - /** - * Filters the SMTP settings before they are consumed by the mailer. - * - * @since 1.1.1 - * - * @param array $settings Sanitized settings merged with defaults. - */ - return (array) \apply_filters( 'robotstxt_smtp_mailer_settings', $settings ); - } - - /** - * Configures PHPMailer to use the stored SMTP settings. - * - * @param PHPMailer $phpmailer Mailer instance. - * - * @return void - */ - public function configure_phpmailer( PHPMailer $phpmailer ): void { - if ( self::is_amazon_ses_integration_active() ) { - return; - } - - $this->current_debug_log = array(); - - $settings = $this->get_mailer_settings(); - - if ( empty( $settings['host'] ) ) { - return; - } - - $phpmailer->isSMTP(); - - // phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase - $phpmailer->Host = $settings['host']; - $phpmailer->Port = (int) $settings['port']; - $phpmailer->SMTPAuth = ! empty( $settings['username'] ) || ! empty( $settings['password'] ); - $phpmailer->Username = $phpmailer->SMTPAuth ? $settings['username'] : ''; - $phpmailer->Password = $phpmailer->SMTPAuth ? $settings['password'] : ''; - $phpmailer->SMTPAutoTLS = false; - $phpmailer->SMTPSecure = ''; - // phpcs:enable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase - - if ( 'ssl' === $settings['security'] ) { - // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase - $phpmailer->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; - } elseif ( 'tls' === $settings['security'] ) { - // phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase - $phpmailer->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; - $phpmailer->SMTPAutoTLS = true; - // phpcs:enable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase - } - - $this->register_debug_logger( $phpmailer ); - } - - /** - * Enables SMTP debug logging for the current email. - * - * @param PHPMailer $phpmailer Mailer instance. - * - * @return void - */ - private function register_debug_logger( PHPMailer $phpmailer ): void { - $logging = $this->get_logging_settings(); - - if ( ! $logging['enabled'] ) { - return; - } - - // phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase - $phpmailer->SMTPDebug = SMTP::DEBUG_SERVER; - $phpmailer->Debugoutput = function ( string $message, int $level ): void { - $this->current_debug_log[] = '[' . $level . '] ' . $message; - }; - // phpcs:enable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase - } - - - /** - * Stores the email data when WordPress reports a successful delivery. - * - * @param array $mail_data Email data provided by wp_mail. - * - * @return void - */ - public function handle_wp_mail_succeeded( array $mail_data ): void { - $logging = $this->get_logging_settings(); - - if ( ! $logging['enabled'] ) { - return; - } - - $settings = $this->get_mailer_settings(); - - $subject = isset( $mail_data['subject'] ) ? sanitize_text_field( (string) $mail_data['subject'] ) : ''; - $message = isset( $mail_data['message'] ) ? (string) $mail_data['message'] : ''; - $headers = $this->normalize_headers( $mail_data['headers'] ?? array() ); - $to = $this->normalize_recipients( $mail_data['to'] ?? array() ); - $from = $this->determine_from_header( $headers, $settings ); - - $post_id = wp_insert_post( - array( - 'post_type' => self::LOG_POST_TYPE, - 'post_status' => 'publish', - 'post_title' => $subject, - 'post_content' => $message, - 'post_date' => current_time( 'mysql' ), - ), - true - ); - - if ( is_wp_error( $post_id ) || 0 === $post_id ) { - return; - } - - update_post_meta( $post_id, '_robotstxt_smtp_to', implode( ', ', $to ) ); - update_post_meta( $post_id, '_robotstxt_smtp_from', $from ); - update_post_meta( $post_id, '_robotstxt_smtp_headers', implode( "\n", $headers ) ); - update_post_meta( $post_id, '_robotstxt_smtp_status', 'sent' ); - update_post_meta( $post_id, '_robotstxt_smtp_error', '' ); - - if ( isset( $mail_data['attachments'] ) ) { - update_post_meta( $post_id, '_robotstxt_smtp_attachments', maybe_serialize( $mail_data['attachments'] ) ); - } - - $debug_log = $this->get_sanitized_debug_log(); - - if ( $debug_log ) { - update_post_meta( $post_id, '_robotstxt_smtp_debug_log', maybe_serialize( $debug_log ) ); - } - - if ( 'count' === $logging['mode'] ) { - $this->cleanup_logs_by_count( $logging['count'] ); - return; - } - - $this->cleanup_logs_by_days( $logging['days'] ); - } - - /** - * Stores the email data when WordPress reports a failed delivery. - * - * @param WP_Error $error Error object reported by wp_mail. - * - * @return void - */ - public function handle_wp_mail_failed( WP_Error $error ): void { - $logging = $this->get_logging_settings(); - - if ( ! $logging['enabled'] ) { - return; - } - - $settings = $this->get_mailer_settings(); - $data = $error->get_error_data(); - - if ( ! is_array( $data ) ) { - $data = array(); - } - - $subject = isset( $data['subject'] ) ? sanitize_text_field( (string) $data['subject'] ) : ''; - $message = isset( $data['message'] ) ? (string) $data['message'] : ''; - $headers = $this->normalize_headers( $data['headers'] ?? array() ); - $to = $this->normalize_recipients( $data['to'] ?? array() ); - $from = $this->determine_from_header( $headers, $settings ); - $error_msg = sanitize_text_field( $error->get_error_message() ); - - $post_id = wp_insert_post( - array( - 'post_type' => self::LOG_POST_TYPE, - 'post_status' => 'publish', - 'post_title' => $subject, - 'post_content' => $message, - 'post_date' => current_time( 'mysql' ), - ), - true - ); - - if ( is_wp_error( $post_id ) || 0 === $post_id ) { - return; - } - - update_post_meta( $post_id, '_robotstxt_smtp_to', implode( ', ', $to ) ); - update_post_meta( $post_id, '_robotstxt_smtp_from', $from ); - update_post_meta( $post_id, '_robotstxt_smtp_headers', implode( "\n", $headers ) ); - update_post_meta( $post_id, '_robotstxt_smtp_status', 'error' ); - update_post_meta( $post_id, '_robotstxt_smtp_error', $error_msg ); - - if ( isset( $data['attachments'] ) ) { - update_post_meta( $post_id, '_robotstxt_smtp_attachments', maybe_serialize( $data['attachments'] ) ); - } - - $debug_log = $this->get_sanitized_debug_log(); - - if ( $debug_log ) { - update_post_meta( $post_id, '_robotstxt_smtp_debug_log', maybe_serialize( $debug_log ) ); - } - - if ( 'count' === $logging['mode'] ) { - $this->cleanup_logs_by_count( $logging['count'] ); - return; - } - - $this->cleanup_logs_by_days( $logging['days'] ); - } - /** - * Retrieves the sanitized SMTP debug output captured for the current email. - * - * @return array - */ - private function get_sanitized_debug_log(): array { - if ( empty( $this->current_debug_log ) ) { - return array(); - } - - $sanitized = array_map( - static function ( $entry ): string { - return sanitize_textarea_field( (string) $entry ); - }, - $this->current_debug_log - ); - - $sanitized = array_filter( - $sanitized, - static function ( string $line ): bool { - return '' !== trim( $line ); - } - ); - - return array_values( $sanitized ); - } - - /** - * Performs log cleanup when triggered by cron. - * - * @return void - */ - public function cleanup_logs(): void { - $logging = $this->get_logging_settings(); - - if ( ! $logging['enabled'] ) { - return; - } - - if ( 'count' === $logging['mode'] ) { - $this->cleanup_logs_by_count( $logging['count'] ); - return; - } - - $this->cleanup_logs_by_days( $logging['days'] ); - } - - /** - * Deletes all stored logs. - * - * @return void - */ - public function clear_all_logs(): void { - do { - $posts = get_posts( - array( - 'post_type' => self::LOG_POST_TYPE, - 'post_status' => 'any', - 'fields' => 'ids', - 'posts_per_page' => 100, - 'orderby' => 'ID', - 'order' => 'ASC', - ) - ); - - foreach ( $posts as $post_id ) { - wp_delete_post( (int) $post_id, true ); - } - } while ( ! empty( $posts ) ); - } - - /** - * Cleans up logs by enforcing a maximum number of stored records. - * - * @param int $limit Maximum number of logs to keep. - * - * @return void - */ - private function cleanup_logs_by_count( int $limit ): void { - if ( $limit <= 0 ) { - $this->clear_all_logs(); - return; - } - - $logs_to_delete = get_posts( - array( - 'post_type' => self::LOG_POST_TYPE, - 'post_status' => 'any', - 'fields' => 'ids', - 'orderby' => 'date', - 'order' => 'DESC', - 'posts_per_page' => -1, - 'offset' => $limit, - 'no_found_rows' => true, - ) - ); - - foreach ( $logs_to_delete as $post_id ) { - wp_delete_post( (int) $post_id, true ); - } - } - - /** - * Cleans up logs based on the maximum number of days to retain them. - * - * @param int $days Number of days to keep. - * - * @return void - */ - private function cleanup_logs_by_days( int $days ): void { - if ( $days <= 0 ) { - $this->clear_all_logs(); - return; - } - - $cutoff = time() - ( $days * DAY_IN_SECONDS ); - - $logs_to_delete = get_posts( - array( - 'post_type' => self::LOG_POST_TYPE, - 'post_status' => 'any', - 'fields' => 'ids', - 'date_query' => array( - array( - 'column' => 'post_date_gmt', - 'before' => gmdate( 'Y-m-d H:i:s', $cutoff ), - ), - ), - 'posts_per_page' => -1, - 'no_found_rows' => true, - ) - ); - - foreach ( $logs_to_delete as $post_id ) { - wp_delete_post( (int) $post_id, true ); - } - } - - /** - * Normalizes the headers array into a list of strings. - * - * @param mixed $headers Headers provided by wp_mail. - * - * @return array - */ - private function normalize_headers( $headers ): array { - if ( empty( $headers ) ) { - return array(); - } - - if ( is_string( $headers ) ) { - $headers = preg_split( "/\r\n|\r|\n/", $headers ); - } - - if ( ! is_array( $headers ) ) { - return array(); - } - - $normalized = array(); - - foreach ( $headers as $header ) { - $line = trim( (string) $header ); - - if ( '' !== $line ) { - $normalized[] = $line; - } - } - - return $normalized; - } - - /** - * Normalizes the recipient list into an array of strings. - * - * @param mixed $recipients Recipient information from wp_mail. - * - * @return array - */ - private function normalize_recipients( $recipients ): array { - if ( empty( $recipients ) ) { - return array(); - } - - if ( is_string( $recipients ) ) { - $recipients = explode( ',', $recipients ); - } - - if ( ! is_array( $recipients ) ) { - return array(); - } - - $normalized = array(); - - foreach ( $recipients as $recipient ) { - $normalized[] = sanitize_text_field( trim( (string) $recipient ) ); - } - - return array_filter( $normalized ); - } - - /** - * Determines the "From" header for the logged message. - * - * @param array $headers Normalized header list. - * @param array $settings Plugin settings. - * - * @return string - */ - private function determine_from_header( array $headers, array $settings ): string { - foreach ( $headers as $header ) { - if ( 0 === stripos( $header, 'from:' ) ) { - return sanitize_text_field( trim( substr( $header, 5 ) ) ); - } - } - - $from_email = isset( $settings['from_email'] ) ? sanitize_email( $settings['from_email'] ) : ''; - $from_name = isset( $settings['from_name'] ) ? sanitize_text_field( $settings['from_name'] ) : ''; - - if ( $from_email && $from_name ) { - return $from_name . ' <' . $from_email . '>'; - } - - if ( $from_email ) { - return $from_email; - } - - return get_bloginfo( 'name', 'display' ); - } - - /** - * Retrieves the logging-related settings from the option store. - * - * @return array - */ - private function get_logging_settings(): array { - $settings = $this->get_mailer_settings(); - - return array( - 'enabled' => ! empty( $settings['logs_enabled'] ), - 'mode' => in_array( $settings['logs_retention_mode'], array( 'count', 'days' ), true ) - ? $settings['logs_retention_mode'] - : 'count', - 'count' => isset( $settings['logs_retention_count'] ) ? (int) $settings['logs_retention_count'] : 0, - 'days' => isset( $settings['logs_retention_days'] ) ? (int) $settings['logs_retention_days'] : 0, - ); - } -} + + */ + private array $current_debug_log = array(); + + /** + * Holds rate limit error if checking failed. + * + * @since 1.2.1 + * + * @var WP_Error|null + */ + private ?WP_Error $rate_limit_error = null; + + + + /** + * Retrieves the plugin instance. + * + * @return Plugin Plugin instance. + */ + public static function get_instance(): Plugin { + if ( null === self::$instance ) { + self::$instance = new self(); + } + + return self::$instance; + } + + /** + * Determines whether the Amazon SES integration plugin is active. + * + * @return bool + */ + public static function is_amazon_ses_integration_active(): bool { + /** + * Filters whether the Amazon SES integration should be considered active. + * + * @since 1.0.1 + * + * @param bool $is_active True when the Amazon SES add-on is active. + */ + return (bool) \apply_filters( 'robotstxt_smtp_amazon_ses_active', false ); + } + + /** + * Sets up the plugin. + * + * @return void + */ + public function run(): void { + add_action( 'phpmailer_init', array( $this, 'configure_phpmailer' ) ); + add_filter( 'pre_wp_mail', array( $this, 'pre_wp_mail_rate_limit_check' ), 1 ); + add_action( 'phpmailer_init', array( $this, 'enforce_rate_limit_in_phpmailer' ), 5 ); + add_filter( 'wp_mail_from', array( $this, 'filter_mail_from' ) ); + add_filter( 'wp_mail_from_name', array( $this, 'filter_mail_from_name' ) ); + add_action( 'phpmailer_init', array( $this, 'configure_reply_to' ), 20 ); + + add_action( 'init', array( $this, 'register_log_post_type' ) ); + add_action( 'init', array( $this, 'maybe_schedule_cleanup' ) ); + add_action( 'init', array( $this, 'maybe_schedule_stats_cleanup' ) ); + add_action( 'wp_mail_succeeded', array( $this, 'handle_wp_mail_succeeded' ) ); + add_action( 'wp_mail_failed', array( $this, 'handle_wp_mail_failed' ) ); + add_action( self::CRON_HOOK, array( $this, 'cleanup_logs' ) ); + add_action( self::STATS_CRON_HOOK, array( $this, 'cleanup_stats' ) ); + + // Initialize statistics table. + Statistics::get_instance(); + + if ( is_admin() ) { + add_action( 'admin_init', array( $this, 'migrate_plaintext_credentials' ) ); + add_action( 'admin_init', array( $this, 'handle_encryption_notice_dismissal' ) ); + add_action( 'admin_notices', array( $this, 'display_encryption_unavailable_notice' ) ); + add_action( 'network_admin_notices', array( $this, 'display_encryption_unavailable_notice' ) ); + $this->register_admin(); + } + } + + /** + * Registers the admin functionality. + * + * @return void + */ + private function register_admin(): void { + if ( null === $this->settings_page ) { + $this->settings_page = new Settings_Page(); + } + + $this->settings_page->register_hooks(); + } + + /** + * Registers the custom post type used to store email logs. + * + * @return void + */ + public function register_log_post_type(): void { + register_post_type( + self::LOG_POST_TYPE, + array( + 'labels' => array( + 'name' => esc_html__( 'SMTP Logs', 'robotstxt-smtp' ), + 'singular_name' => esc_html__( 'SMTP Log', 'robotstxt-smtp' ), + ), + 'public' => false, + 'show_ui' => false, + 'show_in_menu' => false, + 'show_in_nav_menus' => false, + 'exclude_from_search' => true, + 'publicly_queryable' => false, + 'supports' => array( 'title', 'editor' ), + 'capability_type' => 'post', + 'map_meta_cap' => true, + ) + ); + } + + /** + * Schedules or clears the automatic log cleanup task based on settings. + * + * @return void + */ + public function maybe_schedule_cleanup(): void { + $logging = $this->get_logging_settings(); + + if ( ! $logging['enabled'] ) { + wp_clear_scheduled_hook( self::CRON_HOOK ); + return; + } + + if ( false === wp_next_scheduled( self::CRON_HOOK ) ) { + wp_schedule_event( time() + HOUR_IN_SECONDS, 'daily', self::CRON_HOOK ); + } + } + + /** + * Schedules the automatic statistics cleanup task. + * + * @return void + */ + public function maybe_schedule_stats_cleanup(): void { + if ( false === wp_next_scheduled( self::STATS_CRON_HOOK ) ) { + wp_schedule_event( time() + HOUR_IN_SECONDS, 'daily', self::STATS_CRON_HOOK ); + } + } + + /** + * Filters the "From" email address used by WordPress. + * + * @param string $original_email Original email address provided by WordPress. + * + * @return string + */ + public function filter_mail_from( string $original_email ): string { + $settings = $this->get_mailer_settings(); + $from_email = isset( $settings['from_email'] ) ? sanitize_email( $settings['from_email'] ) : ''; + + if ( empty( $from_email ) ) { + return sanitize_email( $original_email ); + } + + return $from_email; + } + + /** + * Filters the "From" name used by WordPress. + * + * @param string $original_name Original name provided by WordPress. + * + * @return string + */ + public function filter_mail_from_name( string $original_name ): string { + $settings = $this->get_mailer_settings(); + $from_name = isset( $settings['from_name'] ) ? sanitize_text_field( $settings['from_name'] ) : ''; + + if ( '' === $from_name ) { + return sanitize_text_field( $original_name ); + } + + return $from_name; + } + + /** + * Configures Reply-To header if configured and not already set. + * + * This method runs with priority 20 on phpmailer_init to allow + * WordPress and other plugins to set Reply-To first. If no Reply-To + * exists and the settings include reply_to_email, it will be added. + * + * @param PHPMailer $phpmailer Mailer instance. + * + * @return void + */ + public function configure_reply_to( PHPMailer $phpmailer ): void { + $settings = $this->get_mailer_settings(); + + // Check if reply-to email is configured. + $reply_to_email = isset( $settings['reply_to_email'] ) ? sanitize_email( $settings['reply_to_email'] ) : ''; + + // If no reply-to email configured, nothing to do. + if ( empty( $reply_to_email ) || ! is_email( $reply_to_email ) ) { + return; + } + + // Check if Reply-To header already exists. + // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase + if ( ! empty( $phpmailer->getReplyToAddresses() ) ) { + // Reply-To already set by wp_mail() or another plugin, don't override. + return; + } + + // Get reply-to name (optional). + $reply_to_name = isset( $settings['reply_to_name'] ) ? sanitize_text_field( $settings['reply_to_name'] ) : ''; + + // Add the Reply-To header. + // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase + $phpmailer->addReplyTo( $reply_to_email, $reply_to_name ); + } + + /** + * Retrieves the stored mailer settings merged with defaults. + * + * @return array + */ + private function get_mailer_settings(): array { + $defaults = Settings_Page::get_default_settings(); + + if ( Settings_Page::is_network_mode_enabled() ) { + $settings = get_site_option( Settings_Page::NETWORK_OPTION_NAME, array() ); + } else { + $settings = get_option( Settings_Page::OPTION_NAME, array() ); + } + + if ( ! is_array( $settings ) ) { + $settings = array(); + } + + $settings = wp_parse_args( $settings, $defaults ); + + $settings['password'] = \Robotstxt_SMTP_Encryption::decrypt( $settings['password'] ?? '' ); + $settings['amazon_ses_access_key'] = \Robotstxt_SMTP_Encryption::decrypt( $settings['amazon_ses_access_key'] ?? '' ); + $settings['amazon_ses_secret_key'] = \Robotstxt_SMTP_Encryption::decrypt( $settings['amazon_ses_secret_key'] ?? '' ); + + if ( ! is_string( $settings['password'] ) ) { + $settings['password'] = ''; + } + + if ( ! is_string( $settings['amazon_ses_access_key'] ) ) { + $settings['amazon_ses_access_key'] = ''; + } + + if ( ! is_string( $settings['amazon_ses_secret_key'] ) ) { + $settings['amazon_ses_secret_key'] = ''; + } + + /** + * Filters the SMTP settings before they are consumed by the mailer. + * + * @since 1.1.1 + * + * @param array $settings Sanitized settings merged with defaults. + */ + return (array) \apply_filters( 'robotstxt_smtp_mailer_settings', $settings ); + } + + /** + * Automatically migrates plaintext credentials to encrypted format. + * + * This method runs once during admin_init to detect and encrypt any + * credentials that were stored in plaintext (from pre-1.2.1 installations). + * Uses a transient to prevent repeated checks after migration is complete. + * + * @since 1.2.2 + * + * @return void + */ + public function migrate_plaintext_credentials(): void { + // Check if migration has already been completed. + $migration_check_key = 'robotstxt_smtp_credentials_migration_checked'; + if ( get_transient( $migration_check_key ) ) { + return; + } + + // Check if encryption is available. + if ( ! \Robotstxt_SMTP_Encryption::is_encryption_available() ) { + // Set transient to retry in 1 hour if encryption becomes available. + set_transient( $migration_check_key, true, HOUR_IN_SECONDS ); + return; + } + + $needs_migration = false; + $is_network_mode = Settings_Page::is_network_mode_enabled(); + + // Load raw settings without decryption. + if ( $is_network_mode ) { + $settings = get_site_option( Settings_Page::NETWORK_OPTION_NAME, array() ); + } else { + $settings = get_option( Settings_Page::OPTION_NAME, array() ); + } + + if ( ! is_array( $settings ) ) { + $settings = array(); + } + + // Check each credential field for plaintext values. + $credential_fields = array( 'password', 'amazon_ses_access_key', 'amazon_ses_secret_key' ); + + foreach ( $credential_fields as $field ) { + if ( ! isset( $settings[ $field ] ) || '' === $settings[ $field ] ) { + continue; + } + + // If the value is not encrypted and not empty, it needs migration. + if ( ! \Robotstxt_SMTP_Encryption::is_encrypted( $settings[ $field ] ) ) { + $needs_migration = true; + $settings[ $field ] = \Robotstxt_SMTP_Encryption::encrypt( $settings[ $field ] ); + } + } + + // Save migrated credentials if any were found. + if ( $needs_migration ) { + if ( $is_network_mode ) { + update_site_option( Settings_Page::NETWORK_OPTION_NAME, $settings ); + } else { + update_option( Settings_Page::OPTION_NAME, $settings ); + } + } + + // Set transient to prevent future checks (valid for 30 days). + // After 30 days, it will check again in case new plaintext credentials were added. + set_transient( $migration_check_key, true, 30 * DAY_IN_SECONDS ); + } + + /** + * Displays an admin notice when encryption is unavailable. + * + * Shows a warning in the WordPress admin when encryption cannot be enabled, + * explaining what's missing and how to fix it. Only displays on plugin settings + * pages and can be dismissed for 7 days. + * + * @since 1.2.2 + * + * @return void + */ + public function display_encryption_unavailable_notice(): void { + // Only show on plugin settings pages. + $screen = get_current_screen(); + if ( null === $screen || false === strpos( $screen->id, 'robotstxt-smtp' ) ) { + return; + } + + // Check if encryption is available. + if ( \Robotstxt_SMTP_Encryption::is_encryption_available() ) { + return; + } + + // Check if notice has been dismissed. + $dismissed_key = 'robotstxt_smtp_encryption_notice_dismissed'; + if ( get_transient( $dismissed_key ) ) { + return; + } + + // Check if there are any stored credentials that need encryption. + $is_network_mode = Settings_Page::is_network_mode_enabled(); + if ( $is_network_mode ) { + $settings = get_site_option( Settings_Page::NETWORK_OPTION_NAME, array() ); + } else { + $settings = get_option( Settings_Page::OPTION_NAME, array() ); + } + + if ( ! is_array( $settings ) ) { + $settings = array(); + } + + // Check if there are any credentials stored. + $has_credentials = false; + $credential_fields = array( 'password', 'amazon_ses_access_key', 'amazon_ses_secret_key' ); + foreach ( $credential_fields as $field ) { + if ( ! empty( $settings[ $field ] ) ) { + $has_credentials = true; + break; + } + } + + // Only show notice if there are credentials to protect. + if ( ! $has_credentials ) { + return; + } + + // Determine what's missing. + $missing_requirements = array(); + + if ( ! extension_loaded( 'openssl' ) ) { + $missing_requirements[] = __( 'OpenSSL PHP extension is not loaded', 'robotstxt-smtp' ); + } elseif ( ! in_array( 'aes-256-gcm', openssl_get_cipher_methods(), true ) ) { + $missing_requirements[] = __( 'AES-256-GCM cipher is not supported by OpenSSL', 'robotstxt-smtp' ); + } + + if ( ! defined( 'AUTH_KEY' ) || '' === AUTH_KEY ) { + $missing_requirements[] = __( 'AUTH_KEY is not defined in wp-config.php', 'robotstxt-smtp' ); + } + + if ( ! defined( 'AUTH_SALT' ) || '' === AUTH_SALT ) { + $missing_requirements[] = __( 'AUTH_SALT is not defined in wp-config.php', 'robotstxt-smtp' ); + } + + if ( empty( $missing_requirements ) ) { + // Encryption should be available but check failed - don't show notice. + return; + } + + // Generate dismiss URL. + $dismiss_url = add_query_arg( + array( + 'robotstxt_smtp_dismiss_encryption_notice' => '1', + '_wpnonce' => wp_create_nonce( 'robotstxt_smtp_dismiss_encryption_notice' ), + ) + ); + + ?> +
+

+ +

+

+ +

+
    + +
  • + +
+

+ ' . esc_html__( 'WordPress authentication keys', 'robotstxt-smtp' ) . '' + ); + ?> +

+

+ + + +

+
+ current_debug_log = array(); + + $settings = $this->get_mailer_settings(); + + if ( empty( $settings['host'] ) ) { + return; + } + + $phpmailer->isSMTP(); + + // phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase + $phpmailer->Host = $settings['host']; + $phpmailer->Port = (int) $settings['port']; + $phpmailer->SMTPAuth = ! empty( $settings['username'] ) || ! empty( $settings['password'] ); + $phpmailer->Username = $phpmailer->SMTPAuth ? $settings['username'] : ''; + $phpmailer->Password = $phpmailer->SMTPAuth ? $settings['password'] : ''; + $phpmailer->SMTPAutoTLS = false; + $phpmailer->SMTPSecure = ''; + // phpcs:enable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase + + if ( 'ssl' === $settings['security'] ) { + // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase + $phpmailer->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; + } elseif ( 'tls' === $settings['security'] ) { + // phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase + $phpmailer->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; + $phpmailer->SMTPAutoTLS = true; + // phpcs:enable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase + } + + $this->register_debug_logger( $phpmailer ); + } + + /** + * Enables SMTP debug logging for the current email. + * + * @param PHPMailer $phpmailer Mailer instance. + * + * @return void + */ + private function register_debug_logger( PHPMailer $phpmailer ): void { + $logging = $this->get_logging_settings(); + + if ( ! $logging['enabled'] ) { + return; + } + + // phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase + $phpmailer->SMTPDebug = SMTP::DEBUG_SERVER; + $phpmailer->Debugoutput = function ( string $message, int $level ): void { + $this->current_debug_log[] = '[' . $level . '] ' . $message; + }; + // phpcs:enable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase + } + + + /** + * Stores the email data when WordPress reports a successful delivery. + * + * @param array $mail_data Email data provided by wp_mail. + * + * @return void + */ + public function handle_wp_mail_succeeded( array $mail_data ): void { + // Track email for statistics. + Statistics::get_instance()->increment_today(); + + $logging = $this->get_logging_settings(); + + if ( ! $logging['enabled'] ) { + // Track email for rate limiting. + $this->track_email_sent(); + + return; + } + + $settings = $this->get_mailer_settings(); + + $subject = isset( $mail_data['subject'] ) ? sanitize_text_field( (string) $mail_data['subject'] ) : ''; + $message = isset( $mail_data['message'] ) ? (string) $mail_data['message'] : ''; + $headers = $this->normalize_headers( $mail_data['headers'] ?? array() ); + $to = $this->normalize_recipients( $mail_data['to'] ?? array() ); + $from = $this->determine_from_header( $headers, $settings ); + + $post_id = wp_insert_post( + array( + 'post_type' => self::LOG_POST_TYPE, + 'post_status' => 'publish', + 'post_title' => $subject, + 'post_content' => $message, + 'post_date' => current_time( 'mysql' ), + ), + true + ); + + if ( is_wp_error( $post_id ) || 0 === $post_id ) { + return; + } + + update_post_meta( $post_id, '_robotstxt_smtp_to', implode( ', ', $to ) ); + update_post_meta( $post_id, '_robotstxt_smtp_from', $from ); + update_post_meta( $post_id, '_robotstxt_smtp_headers', implode( "\n", $headers ) ); + update_post_meta( $post_id, '_robotstxt_smtp_status', 'sent' ); + update_post_meta( $post_id, '_robotstxt_smtp_error', '' ); + + if ( isset( $mail_data['attachments'] ) ) { + update_post_meta( $post_id, '_robotstxt_smtp_attachments', maybe_serialize( $mail_data['attachments'] ) ); + } + + $debug_log = $this->get_sanitized_debug_log(); + + if ( $debug_log ) { + update_post_meta( $post_id, '_robotstxt_smtp_debug_log', maybe_serialize( $debug_log ) ); + } + + if ( 'count' === $logging['mode'] ) { + $this->cleanup_logs_by_count( $logging['count'] ); + return; + } + + $this->cleanup_logs_by_days( $logging['days'] ); + } + + /** + * Stores the email data when WordPress reports a failed delivery. + * + * @param WP_Error $error Error object reported by wp_mail. + * + * @return void + */ + public function handle_wp_mail_failed( WP_Error $error ): void { + $logging = $this->get_logging_settings(); + + if ( ! $logging['enabled'] ) { + return; + } + + $settings = $this->get_mailer_settings(); + $data = $error->get_error_data(); + + if ( ! is_array( $data ) ) { + $data = array(); + } + + $subject = isset( $data['subject'] ) ? sanitize_text_field( (string) $data['subject'] ) : ''; + $message = isset( $data['message'] ) ? (string) $data['message'] : ''; + $headers = $this->normalize_headers( $data['headers'] ?? array() ); + $to = $this->normalize_recipients( $data['to'] ?? array() ); + $from = $this->determine_from_header( $headers, $settings ); + $error_msg = sanitize_text_field( $error->get_error_message() ); + + $post_id = wp_insert_post( + array( + 'post_type' => self::LOG_POST_TYPE, + 'post_status' => 'publish', + 'post_title' => $subject, + 'post_content' => $message, + 'post_date' => current_time( 'mysql' ), + ), + true + ); + + if ( is_wp_error( $post_id ) || 0 === $post_id ) { + return; + } + + update_post_meta( $post_id, '_robotstxt_smtp_to', implode( ', ', $to ) ); + update_post_meta( $post_id, '_robotstxt_smtp_from', $from ); + update_post_meta( $post_id, '_robotstxt_smtp_headers', implode( "\n", $headers ) ); + update_post_meta( $post_id, '_robotstxt_smtp_status', 'error' ); + update_post_meta( $post_id, '_robotstxt_smtp_error', $error_msg ); + + if ( isset( $data['attachments'] ) ) { + update_post_meta( $post_id, '_robotstxt_smtp_attachments', maybe_serialize( $data['attachments'] ) ); + } + + $debug_log = $this->get_sanitized_debug_log(); + + if ( $debug_log ) { + update_post_meta( $post_id, '_robotstxt_smtp_debug_log', maybe_serialize( $debug_log ) ); + } + + if ( 'count' === $logging['mode'] ) { + $this->cleanup_logs_by_count( $logging['count'] ); + return; + } + + $this->cleanup_logs_by_days( $logging['days'] ); + } + /** + * Retrieves the sanitized SMTP debug output captured for the current email. + * + * @return array + */ + /** + * Redacts sensitive authentication data from SMTP log messages. + * + * Removes or masks authentication credentials including: + * - AUTH PLAIN/LOGIN commands with base64-encoded credentials + * - Base64-encoded authentication responses + * - Server authentication challenges + * + * @since 1.2.1 + * + * @param string $message Log message from PHPMailer SMTP debug output. + * @return string Sanitized message with credentials redacted. + */ + private function redact_smtp_credentials( string $message ): string { + // Redact AUTH PLAIN command with base64 credentials. + // Matches AUTH PLAIN anywhere in line, not just at start. + $message = preg_replace( + '/\bAUTH\s+PLAIN\s+[A-Za-z0-9+\/=]+/i', + 'AUTH PLAIN [REDACTED]', + $message + ); + + // Redact AUTH LOGIN command with base64 credentials. + // Matches AUTH LOGIN anywhere in line. + $message = preg_replace( + '/\bAUTH\s+LOGIN\s+[A-Za-z0-9+\/=]+/i', + 'AUTH LOGIN [REDACTED]', + $message + ); + + // Redact other AUTH mechanisms with credentials. + // Handles CRAM-MD5, DIGEST-MD5, XOAUTH2, NTLM, GSSAPI, EXTERNAL. + $message = preg_replace( + '/\bAUTH\s+(CRAM-MD5|DIGEST-MD5|XOAUTH2|NTLM|GSSAPI|EXTERNAL)\s+[A-Za-z0-9+\/=\-_\.]+/i', + 'AUTH ${1} [REDACTED]', + $message + ); + + // Redact base64 challenge-response (server sends 334 + base64). + // The 334 code indicates server is awaiting authentication data. + $message = preg_replace( + '/\b334\s+[A-Za-z0-9+\/=]+/', + '334 [CHALLENGE REDACTED]', + $message + ); + + // Redact standalone base64 strings (likely auth responses). + // Matches lines that are predominantly base64 (20+ chars). + // Preserves optional timestamp prefix [123] or similar. + $message = preg_replace( + '/^(\[\d+\]\s*)?([A-Za-z0-9+\/=]{20,})\s*$/mi', + '${1}[CREDENTIAL REDACTED]', + $message + ); + + return $message; + } + + /** + * Sanitizes and prepares debug log entries for storage or display. + * + * @since 1.0.0 + * + * @return array Sanitized debug log entries with credentials redacted. + */ + private function get_sanitized_debug_log(): array { + if ( empty( $this->current_debug_log ) ) { + return array(); + } + + $sanitized = array_map( + function ( $entry ): string { + $entry = sanitize_textarea_field( (string) $entry ); + return $this->redact_smtp_credentials( $entry ); + }, + $this->current_debug_log + ); + + $sanitized = array_filter( + $sanitized, + static function ( string $line ): bool { + return '' !== trim( $line ); + } + ); + + return array_values( $sanitized ); + } + + /** + * Performs log cleanup when triggered by cron. + * + * @return void + */ + public function cleanup_logs(): void { + $logging = $this->get_logging_settings(); + + if ( ! $logging['enabled'] ) { + return; + } + + if ( 'count' === $logging['mode'] ) { + $this->cleanup_logs_by_count( $logging['count'] ); + return; + } + + $this->cleanup_logs_by_days( $logging['days'] ); + } + + /** + * Performs statistics cleanup when triggered by cron. + * + * @return void + */ + public function cleanup_stats(): void { + $settings = $this->get_mailer_settings(); + $days = isset( $settings['stats_retention_days'] ) ? absint( $settings['stats_retention_days'] ) : 28; + + if ( $days <= 0 ) { + return; + } + + Statistics::get_instance()->cleanup_old_stats( $days ); + } + + /** + * Deletes all stored logs. + * + * @return void + */ + public function clear_all_logs(): void { + do { + $posts = get_posts( + array( + 'post_type' => self::LOG_POST_TYPE, + 'post_status' => 'any', + 'fields' => 'ids', + 'posts_per_page' => 100, + 'orderby' => 'ID', + 'order' => 'ASC', + ) + ); + + foreach ( $posts as $post_id ) { + wp_delete_post( (int) $post_id, true ); + } + } while ( ! empty( $posts ) ); + } + + /** + * Cleans up logs by enforcing a maximum number of stored records. + * + * @param int $limit Maximum number of logs to keep. + * + * @return void + */ + private function cleanup_logs_by_count( int $limit ): void { + if ( $limit <= 0 ) { + $this->clear_all_logs(); + return; + } + + $logs_to_delete = get_posts( + array( + 'post_type' => self::LOG_POST_TYPE, + 'post_status' => 'any', + 'fields' => 'ids', + 'orderby' => 'date', + 'order' => 'DESC', + 'posts_per_page' => -1, + 'offset' => $limit, + 'no_found_rows' => true, + ) + ); + + foreach ( $logs_to_delete as $post_id ) { + wp_delete_post( (int) $post_id, true ); + } + } + + /** + * Cleans up logs based on the maximum number of days to retain them. + * + * @param int $days Number of days to keep. + * + * @return void + */ + private function cleanup_logs_by_days( int $days ): void { + if ( $days <= 0 ) { + $this->clear_all_logs(); + return; + } + + $cutoff = time() - ( $days * DAY_IN_SECONDS ); + + $logs_to_delete = get_posts( + array( + 'post_type' => self::LOG_POST_TYPE, + 'post_status' => 'any', + 'fields' => 'ids', + 'date_query' => array( + array( + 'column' => 'post_date_gmt', + 'before' => gmdate( 'Y-m-d H:i:s', $cutoff ), + ), + ), + 'posts_per_page' => -1, + 'no_found_rows' => true, + ) + ); + + foreach ( $logs_to_delete as $post_id ) { + wp_delete_post( (int) $post_id, true ); + } + } + + /** + * Normalizes the headers array into a list of strings. + * + * @param mixed $headers Headers provided by wp_mail. + * + * @return array + */ + private function normalize_headers( $headers ): array { + if ( empty( $headers ) ) { + return array(); + } + + if ( is_string( $headers ) ) { + $headers = preg_split( "/\r\n|\r|\n/", $headers ); + } + + if ( ! is_array( $headers ) ) { + return array(); + } + + $normalized = array(); + + foreach ( $headers as $header ) { + $line = trim( (string) $header ); + + if ( '' !== $line ) { + $normalized[] = $line; + } + } + + return $normalized; + } + + /** + * Normalizes the recipient list into an array of strings. + * + * @param mixed $recipients Recipient information from wp_mail. + * + * @return array + */ + private function normalize_recipients( $recipients ): array { + if ( empty( $recipients ) ) { + return array(); + } + + if ( is_string( $recipients ) ) { + $recipients = explode( ',', $recipients ); + } + + if ( ! is_array( $recipients ) ) { + return array(); + } + + $normalized = array(); + + foreach ( $recipients as $recipient ) { + $normalized[] = sanitize_text_field( trim( (string) $recipient ) ); + } + + return array_filter( $normalized ); + } + + /** + * Determines the "From" header for the logged message. + * + * @param array $headers Normalized header list. + * @param array $settings Plugin settings. + * + * @return string + */ + private function determine_from_header( array $headers, array $settings ): string { + foreach ( $headers as $header ) { + if ( 0 === stripos( $header, 'from:' ) ) { + return sanitize_text_field( trim( substr( $header, 5 ) ) ); + } + } + + $from_email = isset( $settings['from_email'] ) ? sanitize_email( $settings['from_email'] ) : ''; + $from_name = isset( $settings['from_name'] ) ? sanitize_text_field( $settings['from_name'] ) : ''; + + if ( $from_email && $from_name ) { + return $from_name . ' <' . $from_email . '>'; + } + + if ( $from_email ) { + return $from_email; + } + + return get_bloginfo( 'name', 'display' ); + } + + /** + * Retrieves the logging-related settings from the option store. + * + * @return array + */ + private function get_logging_settings(): array { + $settings = $this->get_mailer_settings(); + + return array( + 'enabled' => ! empty( $settings['logs_enabled'] ), + 'mode' => in_array( $settings['logs_retention_mode'], array( 'count', 'days' ), true ) + ? $settings['logs_retention_mode'] + : 'count', + 'count' => isset( $settings['logs_retention_count'] ) ? (int) $settings['logs_retention_count'] : 0, + 'days' => isset( $settings['logs_retention_days'] ) ? (int) $settings['logs_retention_days'] : 0, + ); + } + + /** + * Tracks that an email was sent for rate limiting purposes. + * + * Increments counters for per-second, per-hour, and per-day windows. + * + * @since 1.2.1 + * + * @return void + */ + private function track_email_sent(): void { + $scope = $this->settings_page ? $this->settings_page->get_scope() : Settings_Page::SCOPE_SITE; + + $key_second = $this->get_rate_limit_transient_key( $scope, 'second' ); + $count = (int) ( Settings_Page::SCOPE_NETWORK === $scope ? get_site_transient( $key_second ) : get_transient( $key_second ) ); + ++$count; + if ( Settings_Page::SCOPE_NETWORK === $scope ) { + set_site_transient( $key_second, $count, 1 ); + } else { + set_transient( $key_second, $count, 1 ); + } + + $key_hour = $this->get_rate_limit_transient_key( $scope, 'hour' ); + $count = (int) ( Settings_Page::SCOPE_NETWORK === $scope ? get_site_transient( $key_hour ) : get_transient( $key_hour ) ); + ++$count; + if ( Settings_Page::SCOPE_NETWORK === $scope ) { + set_site_transient( $key_hour, $count, HOUR_IN_SECONDS ); + } else { + set_transient( $key_hour, $count, HOUR_IN_SECONDS ); + } + + $key_day = $this->get_rate_limit_transient_key( $scope, 'day' ); + $count = (int) ( Settings_Page::SCOPE_NETWORK === $scope ? get_site_transient( $key_day ) : get_transient( $key_day ) ); + ++$count; + if ( Settings_Page::SCOPE_NETWORK === $scope ) { + set_site_transient( $key_day, $count, DAY_IN_SECONDS ); + } else { + set_transient( $key_day, $count, DAY_IN_SECONDS ); + } + } + + /** + * Checks if sending an email would exceed configured rate limits. + * + * @since 1.2.1 + * + * @return true|WP_Error True if sending is allowed, WP_Error if rate limit exceeded. + */ + private function check_rate_limit() { + if ( ! $this->settings_page ) { + return true; + } + + $settings = $this->settings_page->get_settings(); + $scope = $this->settings_page->get_scope(); + + if ( isset( $settings['rate_limit_per_second'] ) && $settings['rate_limit_per_second'] > 0 ) { + $key = $this->get_rate_limit_transient_key( $scope, 'second' ); + $count = (int) ( Settings_Page::SCOPE_NETWORK === $scope ? get_site_transient( $key ) : get_transient( $key ) ); + + if ( $count >= $settings['rate_limit_per_second'] ) { + return new WP_Error( + 'rate_limit_exceeded_second', + sprintf( + /* translators: %d: rate limit per second */ + __( 'Rate limit exceeded: Maximum %d emails per second.', 'robotstxt-smtp' ), + $settings['rate_limit_per_second'] + ) + ); + } + } + + if ( isset( $settings['rate_limit_per_hour'] ) && $settings['rate_limit_per_hour'] > 0 ) { + $key = $this->get_rate_limit_transient_key( $scope, 'hour' ); + $count = (int) ( Settings_Page::SCOPE_NETWORK === $scope ? get_site_transient( $key ) : get_transient( $key ) ); + + if ( $count >= $settings['rate_limit_per_hour'] ) { + return new WP_Error( + 'rate_limit_exceeded_hour', + sprintf( + /* translators: %d: rate limit per hour */ + __( 'Rate limit exceeded: Maximum %d emails per hour.', 'robotstxt-smtp' ), + $settings['rate_limit_per_hour'] + ) + ); + } + } + + if ( isset( $settings['rate_limit_per_day'] ) && $settings['rate_limit_per_day'] > 0 ) { + $key = $this->get_rate_limit_transient_key( $scope, 'day' ); + $count = (int) ( Settings_Page::SCOPE_NETWORK === $scope ? get_site_transient( $key ) : get_transient( $key ) ); + + if ( $count >= $settings['rate_limit_per_day'] ) { + return new WP_Error( + 'rate_limit_exceeded_day', + sprintf( + /* translators: %d: rate limit per day */ + __( 'Rate limit exceeded: Maximum %d emails per 24 hours.', 'robotstxt-smtp' ), + $settings['rate_limit_per_day'] + ) + ); + } + } + + return true; + } + + /** + * Gets the transient key for rate limiting counters. + * + * @since 1.2.1 + * + * @param string $scope Scope identifier (network or site). + * @param string $window Time window (second, hour, day). + * @return string Transient key. + */ + private function get_rate_limit_transient_key( string $scope, string $window ): string { + if ( Settings_Page::SCOPE_NETWORK === $scope ) { + return "robotstxt_smtp_rate_limit_{$window}_network"; + } + + return "robotstxt_smtp_rate_limit_{$window}_" . get_current_blog_id(); + } + + /** + * Gets current send counts for all time windows. + * + * Used for debugging and displaying current usage. + * + * @since 1.2.1 + * + * @return array Current counts keyed by window (second, hour, day). + */ + public function get_current_send_counts(): array { + if ( ! $this->settings_page ) { + return array( + 'second' => 0, + 'hour' => 0, + 'day' => 0, + ); + } + + $scope = $this->settings_page->get_scope(); + + return array( + 'second' => (int) ( Settings_Page::SCOPE_NETWORK === $scope ? get_site_transient( $this->get_rate_limit_transient_key( $scope, 'second' ) ) : get_transient( $this->get_rate_limit_transient_key( $scope, 'second' ) ) ), + 'hour' => (int) ( Settings_Page::SCOPE_NETWORK === $scope ? get_site_transient( $this->get_rate_limit_transient_key( $scope, 'hour' ) ) : get_transient( $this->get_rate_limit_transient_key( $scope, 'hour' ) ) ), + 'day' => (int) ( Settings_Page::SCOPE_NETWORK === $scope ? get_site_transient( $this->get_rate_limit_transient_key( $scope, 'day' ) ) : get_transient( $this->get_rate_limit_transient_key( $scope, 'day' ) ) ), + ); + } + + /** + * Checks rate limits before sending an email. + * + * Hooks into 'pre_wp_mail' to prevent sending if rate limit is exceeded. + * + * @since 1.2.1 + * + * @param null|bool $return Short-circuit return value. + * @return null|bool|WP_Error Null to continue, WP_Error if rate limit exceeded. + * + * @phpcs:disable WordPress.NamingConventions.ValidFunctionName.ParameterNameInvalid -- WordPress core filter uses $return parameter name. + */ + public function pre_wp_mail_rate_limit_check( $return ) { + if ( null !== $return ) { + return $return; + } + + $check = $this->check_rate_limit(); + + if ( is_wp_error( $check ) ) { + $this->rate_limit_error = $check; + } + + return $return; + } + + /** + * Enforces rate limits in phpmailer_init if check failed earlier. + * + * @since 1.2.1 + * + * @param PHPMailer $phpmailer PHPMailer instance. + * @return void + * @throws \PHPMailer\PHPMailer\Exception If rate limit exceeded. + * + * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.Found -- Required by WordPress action hook signature. + */ + public function enforce_rate_limit_in_phpmailer( PHPMailer $phpmailer ): void { + if ( isset( $this->rate_limit_error ) && is_wp_error( $this->rate_limit_error ) ) { + $error = $this->rate_limit_error; + unset( $this->rate_limit_error ); + + // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Exception message not output to browser. + throw new \PHPMailer\PHPMailer\Exception( $error->get_error_message(), $error->get_error_code() ); + } + } +} diff --git a/includes/class-robotstxt-smtp-encryption.php b/includes/class-robotstxt-smtp-encryption.php new file mode 100644 index 0000000..f1f8af0 --- /dev/null +++ b/includes/class-robotstxt-smtp-encryption.php @@ -0,0 +1,222 @@ +|null - */ - private ?array $cached_settings = null; - - /** - * Tracks whether the site settings form was submitted in the current request. - * - * @var bool - */ - private bool $site_settings_submitted = false; - - /** - * Tracks whether the site settings option was updated in the current request. - * - * @var bool - */ - private bool $site_settings_option_updated = false; - - /** - * Tracks the settings scope used for the current request. - * - * @var string - */ - private string $current_scope = self::SCOPE_SITE; - - /** - * Retrieves the current configuration mode. - * - * @return string - */ - public static function get_configuration_mode(): string { - if ( ! is_multisite() ) { - return self::MODE_SITE; - } - - $mode = get_site_option( self::NETWORK_MODE_OPTION_NAME, self::MODE_NETWORK ); - - return self::MODE_NETWORK === $mode ? self::MODE_NETWORK : self::MODE_SITE; - } - - /** - * Determines whether the plugin operates in network-wide configuration mode. - * - * @return bool - */ - public static function is_network_mode_enabled(): bool { - return self::MODE_NETWORK === self::get_configuration_mode(); - } - - /** - * Updates the internal scope tracker and resets caches when the scope changes. - * - * @param string $scope Scope identifier. - * - * @return void - */ - private function set_scope( string $scope ): void { - $normalized = self::SCOPE_NETWORK === $scope ? self::SCOPE_NETWORK : self::SCOPE_SITE; - - if ( $normalized !== $this->current_scope ) { - $this->current_scope = $normalized; - $this->cached_settings = null; - } - } - - /** - * Retrieves the scope currently in use. - * - * @return string - */ - private function get_scope(): string { - return $this->current_scope; - } - - /** - * Determines the settings option name for a given scope. - * - * @param string|null $scope Optional scope identifier. - * - * @return string - */ - private function get_option_name_for_scope( ?string $scope = null ): string { - $scope = $scope ?? $this->get_scope(); - - return self::SCOPE_NETWORK === $scope ? self::NETWORK_OPTION_NAME : self::OPTION_NAME; - } - - /** - * Builds the input name for a settings field based on the active scope. - * - * @param string $field Field identifier. - * - * @return string - */ - private function get_settings_field_name( string $field ): string { - return $this->get_option_name_for_scope() . '[' . $field . ']'; - } - - /** - * Retrieves the capability required to manage settings for a scope. - * - * @param string $scope Scope identifier. - * - * @return string - */ - private function get_scope_capability( string $scope ): string { - return self::SCOPE_NETWORK === $scope ? self::NETWORK_CAPABILITY : self::CAPABILITY; - } - - /** - * Ensures the current user can manage the provided scope. - * - * @param string $scope Scope identifier. - * - * @return void - */ - private function ensure_capability( string $scope ): void { - if ( ! current_user_can( $this->get_scope_capability( $scope ) ) ) { - wp_die( esc_html__( 'You do not have permission to access this page.', 'robotstxt-smtp' ) ); - } - } - - /** - * Determines the scope associated with the current admin area. - * - * @return string - */ - private function get_current_admin_scope(): string { - return is_network_admin() ? self::SCOPE_NETWORK : self::SCOPE_SITE; - } - - /** - * Retrieves the admin URL for the provided scope. - * - * @param string $scope Scope identifier. - * @param string $path Path appended to the admin URL. - * - * @return string - */ - private function get_admin_url_for_scope( string $scope, string $path ): string { - return self::SCOPE_NETWORK === $scope ? network_admin_url( $path ) : admin_url( $path ); - } - - /** - * Retrieves the admin-post URL for a scope. - * - * @param string $scope Scope identifier. - * - * @return string - */ - private function get_admin_post_url_for_scope( string $scope ): string { - unset( $scope ); - - return admin_url( 'admin-post.php' ); - } - - /** - * Registers WordPress hooks. - * - * @return void - */ - public function register_hooks(): void { - if ( ! is_multisite() || ! self::is_network_mode_enabled() ) { - add_action( 'admin_menu', array( $this, 'register_site_menu' ) ); - } - - if ( is_multisite() ) { - add_action( 'network_admin_menu', array( $this, 'register_network_menu' ) ); - } - - add_action( 'admin_init', array( $this, 'register_settings' ) ); - add_action( 'admin_post_robotstxt_smtp_test_email', array( $this, 'handle_test_email' ) ); - add_action( 'admin_post_robotstxt_smtp_clear_logs', array( $this, 'handle_clear_logs' ) ); - add_action( 'admin_post_robotstxt_smtp_save_network_settings', array( $this, 'handle_save_network_settings' ) ); - add_action( 'admin_notices', array( $this, 'display_test_email_notice' ) ); - add_action( 'network_admin_notices', array( $this, 'display_test_email_notice' ) ); - add_action( 'shutdown', array( $this, 'maybe_send_pending_site_test' ) ); - add_action( 'updated_option', array( $this, 'handle_settings_option_updated' ), 10, 3 ); - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) ); - } - - /** - * Enqueues JavaScript assets for the admin pages. - * - * @param string $hook_suffix Current admin page hook suffix. - * - * @return void - */ - public function enqueue_assets( string $hook_suffix ): void { - if ( false === strpos( $hook_suffix, 'robotstxt-smtp' ) ) { - return; - } - - wp_enqueue_style( - 'robotstxt-smtp-admin-style', - ROBOTSTXT_SMTP_URL . 'assets/css/admin.css', - array(), - ROBOTSTXT_SMTP_VERSION - ); - - wp_enqueue_script( - 'robotstxt-smtp-admin', - ROBOTSTXT_SMTP_URL . 'assets/js/admin.js', - array(), - ROBOTSTXT_SMTP_VERSION, - true - ); - } - - /** - * Registers the admin menu for the single-site plugin pages. - * - * @return void - */ - public function register_site_menu(): void { - add_menu_page( - esc_html__( 'SMTP (by ROBOTSTXT)', 'robotstxt-smtp' ), - esc_html__( 'SMTP', 'robotstxt-smtp' ), - self::CAPABILITY, - self::MENU_SLUG, - array( $this, 'render_site_settings_page' ), - 'dashicons-email-alt2' - ); - - add_submenu_page( - self::MENU_SLUG, - esc_html__( 'SMTP (by ROBOTSTXT)', 'robotstxt-smtp' ), - esc_html__( 'Settings', 'robotstxt-smtp' ), - self::CAPABILITY, - self::MENU_SLUG, - array( $this, 'render_site_settings_page' ) - ); - - add_submenu_page( - self::MENU_SLUG, - esc_html__( 'SMTP Test', 'robotstxt-smtp' ), - esc_html__( 'Test', 'robotstxt-smtp' ), - self::CAPABILITY, - self::TEST_PAGE_SLUG, - array( $this, 'render_test_page' ) - ); - - add_submenu_page( - self::MENU_SLUG, - esc_html__( 'SMTP Tools', 'robotstxt-smtp' ), - esc_html__( 'Tools', 'robotstxt-smtp' ), - self::CAPABILITY, - self::TOOLS_PAGE_SLUG, - array( $this, 'render_tools_page' ) - ); - - add_submenu_page( - self::MENU_SLUG, - esc_html__( 'SMTP Logs', 'robotstxt-smtp' ), - esc_html__( 'Logs', 'robotstxt-smtp' ), - self::CAPABILITY, - self::LOGS_PAGE_SLUG, - array( $this, 'render_logs_page' ) - ); - } - - /** - * Registers the admin menu for the network-level pages when multisite is enabled. - * - * @return void - */ - public function register_network_menu(): void { - if ( ! current_user_can( self::NETWORK_CAPABILITY ) ) { - return; - } - - add_menu_page( - esc_html__( 'SMTP (by ROBOTSTXT)', 'robotstxt-smtp' ), - esc_html__( 'SMTP', 'robotstxt-smtp' ), - self::NETWORK_CAPABILITY, - self::NETWORK_MENU_SLUG, - array( $this, 'render_network_settings_page' ), - 'dashicons-email-alt2' - ); - - add_submenu_page( - self::NETWORK_MENU_SLUG, - esc_html__( 'SMTP (by ROBOTSTXT)', 'robotstxt-smtp' ), - esc_html__( 'Settings', 'robotstxt-smtp' ), - self::NETWORK_CAPABILITY, - self::NETWORK_PAGE_SLUG, - array( $this, 'render_network_settings_page' ) - ); - - add_submenu_page( - self::NETWORK_MENU_SLUG, - esc_html__( 'SMTP Test', 'robotstxt-smtp' ), - esc_html__( 'Test', 'robotstxt-smtp' ), - self::NETWORK_CAPABILITY, - self::TEST_PAGE_SLUG, - array( $this, 'render_test_page' ) - ); - - add_submenu_page( - self::NETWORK_MENU_SLUG, - esc_html__( 'SMTP Tools', 'robotstxt-smtp' ), - esc_html__( 'Tools', 'robotstxt-smtp' ), - self::NETWORK_CAPABILITY, - self::TOOLS_PAGE_SLUG, - array( $this, 'render_tools_page' ) - ); - - add_submenu_page( - self::NETWORK_MENU_SLUG, - esc_html__( 'SMTP Logs', 'robotstxt-smtp' ), - esc_html__( 'Logs', 'robotstxt-smtp' ), - self::NETWORK_CAPABILITY, - self::LOGS_PAGE_SLUG, - array( $this, 'render_logs_page' ) - ); - } - - /** - * Registers plugin settings, sections, and fields. - * - * @return void - */ - public function register_settings(): void { - if ( is_multisite() && self::is_network_mode_enabled() && ! is_network_admin() ) { - return; - } - - if ( is_network_admin() ) { - // Network settings are handled manually via the admin-post handler. - return; - } - - $this->set_scope( self::SCOPE_SITE ); - - register_setting( - self::SITE_SETTINGS_GROUP, - self::OPTION_NAME, - array( - 'sanitize_callback' => array( $this, 'sanitize_options' ), - ) - ); - - add_settings_section( - 'robotstxt_smtp_connection_section', - esc_html__( 'SMTP Server Configuration', 'robotstxt-smtp' ), - array( $this, 'render_connection_section_description' ), - self::PAGE_SLUG - ); - - $this->register_connection_fields(); - - add_settings_section( - 'robotstxt_smtp_logs_section', - esc_html__( 'Email Log Settings', 'robotstxt-smtp' ), - array( $this, 'render_logs_section_description' ), - self::PAGE_SLUG - ); - - $this->register_logging_fields(); - } - - /** - * Registers fields related to the SMTP connection. - * - * @return void - */ - private function register_connection_fields(): void { - foreach ( $this->get_connection_field_definitions() as $field ) { - $args = array(); - - if ( ! empty( $field['label_for'] ) ) { - $args['label_for'] = $field['label_for']; - } - - add_settings_field( - $field['id'], - $field['label'], - $field['callback'], - self::PAGE_SLUG, - 'robotstxt_smtp_connection_section', - $args - ); - } - } - - /** - * Registers the logging configuration fields. - * - * @return void - */ - private function register_logging_fields(): void { - foreach ( $this->get_logging_field_definitions() as $field ) { - $args = array(); - - if ( ! empty( $field['label_for'] ) ) { - $args['label_for'] = $field['label_for']; - } - - add_settings_field( - $field['id'], - $field['label'], - $field['callback'], - self::PAGE_SLUG, - 'robotstxt_smtp_logs_section', - $args - ); - } - } - - /** - * Provides the field definitions for the SMTP connection settings. - * - * @return array> - */ - private function get_connection_field_definitions(): array { - if ( Plugin::is_amazon_ses_integration_active() ) { - $fields = array(); - } else { - $fields = array( - array( - 'id' => 'robotstxt_smtp_host', - 'label' => esc_html__( 'Host', 'robotstxt-smtp' ), - 'callback' => array( $this, 'render_host_field' ), - 'label_for' => 'robotstxt_smtp_host', - ), - array( - 'id' => 'robotstxt_smtp_username', - 'label' => esc_html__( 'Username', 'robotstxt-smtp' ), - 'callback' => array( $this, 'render_username_field' ), - 'label_for' => 'robotstxt_smtp_username', - ), - array( - 'id' => 'robotstxt_smtp_password', - 'label' => esc_html__( 'Password', 'robotstxt-smtp' ), - 'callback' => array( $this, 'render_password_field' ), - 'label_for' => 'robotstxt_smtp_password', - ), - array( - 'id' => 'robotstxt_smtp_from_email', - 'label' => esc_html__( 'From Email', 'robotstxt-smtp' ), - 'callback' => array( $this, 'render_from_email_field' ), - 'label_for' => 'robotstxt_smtp_from_email', - ), - array( - 'id' => 'robotstxt_smtp_from_name', - 'label' => esc_html__( 'From Name', 'robotstxt-smtp' ), - 'callback' => array( $this, 'render_from_name_field' ), - 'label_for' => 'robotstxt_smtp_from_name', - ), - array( - 'id' => 'robotstxt_smtp_security', - 'label' => esc_html__( 'Security Type', 'robotstxt-smtp' ), - 'callback' => array( $this, 'render_security_field' ), - 'label_for' => 'robotstxt_smtp_security', - ), - array( - 'id' => 'robotstxt_smtp_port', - 'label' => esc_html__( 'Port', 'robotstxt-smtp' ), - 'callback' => array( $this, 'render_port_field' ), - 'label_for' => 'robotstxt_smtp_port', - ), - ); - } - - /** - * Filters the SMTP connection field definitions. - * - * @since 1.0.1 - * - * @param array> $fields Field definitions. - * @param Settings_Page $settings_page Settings page instance. - */ - return (array) \apply_filters( 'robotstxt_smtp_connection_field_definitions', $fields, $this ); - } - - - /** - * Provides the field definitions for the logging settings. - * - * @return array> - */ - private function get_logging_field_definitions(): array { - return array( - array( - 'id' => 'robotstxt_smtp_logs_enabled', - 'label' => esc_html__( 'Enable logging', 'robotstxt-smtp' ), - 'callback' => array( $this, 'render_logs_enabled_field' ), - 'label_for' => 'robotstxt_smtp_logs_enabled', - ), - array( - 'id' => 'robotstxt_smtp_logs_retention_mode', - 'label' => esc_html__( 'Retention mode', 'robotstxt-smtp' ), - 'callback' => array( $this, 'render_logs_retention_mode_field' ), - ), - array( - 'id' => 'robotstxt_smtp_logs_retention_count', - 'label' => esc_html__( 'Maximum stored emails', 'robotstxt-smtp' ), - 'callback' => array( $this, 'render_logs_retention_count_field' ), - 'label_for' => 'robotstxt_smtp_logs_retention_count', - ), - array( - 'id' => 'robotstxt_smtp_logs_retention_days', - 'label' => esc_html__( 'Retention in days', 'robotstxt-smtp' ), - 'callback' => array( $this, 'render_logs_retention_days_field' ), - 'label_for' => 'robotstxt_smtp_logs_retention_days', - ), - ); - } - - /** - * Outputs the provided fields in a table layout. - * - * @param array> $fields Field definitions. - * - * @return void - */ - private function render_field_rows( array $fields ): void { - foreach ( $fields as $field ) { - $label_for = isset( $field['label_for'] ) ? (string) $field['label_for'] : ''; - ?> - - - - - - - - - - - - - ' . esc_html__( 'Amazon SES integration is active. To configure SMTP manually, deactivate the Amazon SES add-on.', 'robotstxt-smtp' ) . '

'; - - return; - } - - echo '

' . esc_html__( 'Configure the SMTP server used to deliver outgoing emails.', 'robotstxt-smtp' ) . '

'; - } - - /** - * Outputs the logs section description. - * - * @return void - */ - public function render_logs_section_description(): void { - echo '

' . esc_html__( 'Control how email delivery logs are stored and pruned.', 'robotstxt-smtp' ) . '

'; - } - - /** - * Renders the settings page. - * - * @return void - */ - public function render_site_settings_page(): void { - $this->ensure_capability( self::SCOPE_SITE ); - $this->set_scope( self::SCOPE_SITE ); - - ?> -
-

-
- -
-
- ensure_capability( self::SCOPE_NETWORK ); - $this->set_scope( self::SCOPE_NETWORK ); - - $mode = self::get_configuration_mode(); - - ?> -
-

- - - -
-

-
- - -
- - - - -

-

- - - - - - - - - -

- -
-

-
- - -
-

-
- - - - - render_field_rows( $this->get_connection_field_definitions() ); ?> - - - -

- - - render_field_rows( $this->get_logging_field_definitions() ); ?> - - - - -
-
- ensure_capability( $scope ); - - $nonce_value = filter_input( INPUT_POST, '_wpnonce', FILTER_UNSAFE_RAW ); - - // Abort when the security nonce is missing or invalid to block forged submissions. - if ( ! is_string( $nonce_value ) || ! wp_verify_nonce( wp_unslash( $nonce_value ), 'robotstxt_smtp_save_network_settings' ) ) { - wp_die( esc_html__( 'The link you followed has expired.', 'robotstxt-smtp' ) ); - } - - $mode = self::MODE_SITE; - - $submitted_mode = filter_input( INPUT_POST, 'robotstxt_smtp_mode', FILTER_UNSAFE_RAW ); - - if ( is_string( $submitted_mode ) ) { - $submitted_mode = sanitize_key( wp_unslash( $submitted_mode ) ); - - if ( self::MODE_NETWORK === $submitted_mode ) { - $mode = self::MODE_NETWORK; - } - } - - update_site_option( self::NETWORK_MODE_OPTION_NAME, $mode ); - - $options = array(); - - $raw_options = filter_input( INPUT_POST, self::NETWORK_OPTION_NAME, FILTER_UNSAFE_RAW, FILTER_REQUIRE_ARRAY ); - - if ( is_array( $raw_options ) ) { - $options = map_deep( wp_unslash( $raw_options ), 'sanitize_text_field' ); - } - - $this->set_scope( self::SCOPE_NETWORK ); - $clean_options = $this->sanitize_options( $options ); - update_site_option( self::NETWORK_OPTION_NAME, $clean_options ); - - $result = $this->send_test_email_for_scope( self::SCOPE_NETWORK, null, 'auto' ); - $this->persist_test_result( $result ); - - $redirect = add_query_arg( - array( - 'page' => self::NETWORK_PAGE_SLUG, - 'robotstxt_smtp_saved' => 1, - 'robotstxt_smtp_test' => ! empty( $result['success'] ) ? 'success' : 'error', - ), - $this->get_admin_url_for_scope( $scope, 'admin.php' ) - ); - - $redirect = add_query_arg( - '_wpnonce', - wp_create_nonce( 'robotstxt_smtp_saved_notice' ), - $redirect - ); - - wp_safe_redirect( $redirect ); - exit; - } - - /** - * Renders the test page. - * - * @return void - */ - public function render_test_page(): void { - $scope = $this->get_current_admin_scope(); - - $this->ensure_capability( $scope ); - $this->set_scope( $scope ); - - ?> -
-

-

' . esc_html__( 'The network configuration is currently disabled. Tests will use the site-specific settings stored below.', 'robotstxt-smtp' ) . '

'; - } - - $this->render_test_email_form( $scope ); - ?> - - get_current_admin_scope(); - - $this->ensure_capability( $scope ); - $this->set_scope( $scope ); - - $requested_tool = ''; - if ( isset( $_GET['robotstxt_smtp_tool'] ) ) { - $requested_tool = sanitize_key( wp_unslash( (string) $_GET['robotstxt_smtp_tool'] ) ); - } - - $force_refresh = false; - if ( isset( $_GET['robotstxt_smtp_refresh'] ) && '' !== $requested_tool ) { - $nonce = isset( $_GET['_wpnonce'] ) ? sanitize_text_field( wp_unslash( (string) $_GET['_wpnonce'] ) ) : ''; - - if ( wp_verify_nonce( $nonce, 'robotstxt_smtp_refresh_tool_' . $requested_tool ) ) { - $force_refresh = true; - } - } - - $tools = array( - 'mx' => array( - 'title' => esc_html__( 'Automatic MX Lookup', 'robotstxt-smtp' ), - 'description' => esc_html__( 'Detects the domain from the configured sender address, retrieves its MX records, and compares them with the SMTP host.', 'robotstxt-smtp' ), - 'callback' => array( $this, 'get_tools_mx_section_html' ), - ), - 'authentication' => array( - 'title' => esc_html__( 'SPF, DKIM, and DMARC Validation', 'robotstxt-smtp' ), - 'description' => esc_html__( 'Checks common DNS TXT records for the sender domain to help you verify email authentication.', 'robotstxt-smtp' ), - 'callback' => array( $this, 'get_tools_authentication_section_html' ), - ), - 'diagnostics' => array( - 'title' => esc_html__( 'Extended SMTP Diagnostics', 'robotstxt-smtp' ), - 'description' => esc_html__( 'Reuses the configured SMTP connection to inspect the server greeting, TLS support, available authentication mechanisms, and EHLO/HELO response codes.', 'robotstxt-smtp' ), - 'callback' => array( $this, 'get_tools_smtp_diagnostics_section_html' ), - ), - 'blacklist' => array( - 'title' => esc_html__( 'Blacklist Lookup', 'robotstxt-smtp' ), - 'description' => esc_html__( 'Checks the SMTP host IP address against well-known DNS-based reputation lists. Use the feature responsibly and respect each provider’s terms of use.', 'robotstxt-smtp' ), - 'callback' => array( $this, 'get_tools_blacklist_section_html' ), - ), - ); - - $base_url = $this->get_admin_url_for_scope( $scope, 'admin.php' ); - - ?> -
-

- - -
-

-
- - -
- $tool_definition ) : ?> - get_tool_result_for_display( $scope, $tool_key, $tool_definition['callback'], $run_now ); - $has_result = null !== $result; - - $refresh_url = add_query_arg( - array( - 'page' => self::TOOLS_PAGE_SLUG, - 'robotstxt_smtp_tool' => $tool_key, - 'robotstxt_smtp_refresh' => '1', - ), - $base_url - ); - $refresh_url = wp_nonce_url( $refresh_url, 'robotstxt_smtp_refresh_tool_' . $tool_key ); - ?> -
-

-

- - - format_tool_timestamp( isset( $result['timestamp'] ) ? (int) $result['timestamp'] : 0 ); - ?> - -

- -

- - -

- - - -

- -
- -
- -

- -

- -

- - - -

- -
- -
-
- |null - */ - private function get_tool_result_for_display( string $scope, string $tool, callable $callback, bool $refresh ): ?array { - $cached = $this->get_cached_tool_result( $scope, $tool ); - - if ( $refresh ) { - $html = (string) call_user_func( $callback, $scope ); - $data = array( - 'html' => $html, - 'timestamp' => time(), - ); - - $this->set_tool_result_cache( $scope, $tool, $data ); - - return $data; - } - - return $cached; - } - - /** - * Retrieves the cached results for a tool. - * - * @param string $scope Scope identifier. - * @param string $tool Tool identifier. - * - * @return array|null - */ - private function get_cached_tool_result( string $scope, string $tool ): ?array { - $key = $this->get_tool_transient_key( $scope, $tool ); - $value = self::SCOPE_NETWORK === $scope ? get_site_transient( $key ) : get_transient( $key ); - - if ( false === $value ) { - return null; - } - - if ( ! is_array( $value ) || ! isset( $value['html'], $value['timestamp'] ) ) { - $this->delete_tool_result_cache( $scope, $tool ); - return null; - } - - return array( - 'html' => (string) $value['html'], - 'timestamp' => (int) $value['timestamp'], - ); - } - - /** - * Stores the cached results for a tool. - * - * @param string $scope Scope identifier. - * @param string $tool Tool identifier. - * @param array $data Cached data. - * - * @return void - */ - private function set_tool_result_cache( string $scope, string $tool, array $data ): void { - $payload = array( - 'html' => isset( $data['html'] ) ? (string) $data['html'] : '', - 'timestamp' => isset( $data['timestamp'] ) ? (int) $data['timestamp'] : time(), - ); - - $key = $this->get_tool_transient_key( $scope, $tool ); - - if ( self::SCOPE_NETWORK === $scope ) { - set_site_transient( $key, $payload, self::TOOLS_CACHE_LIFETIME ); - return; - } - - set_transient( $key, $payload, self::TOOLS_CACHE_LIFETIME ); - } - - /** - * Removes the cached results for a tool. - * - * @param string $scope Scope identifier. - * @param string $tool Tool identifier. - * - * @return void - */ - private function delete_tool_result_cache( string $scope, string $tool ): void { - $key = $this->get_tool_transient_key( $scope, $tool ); - - if ( self::SCOPE_NETWORK === $scope ) { - delete_site_transient( $key ); - return; - } - - delete_transient( $key ); - } - - /** - * Builds the transient key for a tool and scope combination. - * - * @param string $scope Scope identifier. - * @param string $tool Tool identifier. - * - * @return string - */ - private function get_tool_transient_key( string $scope, string $tool ): string { - return self::TOOLS_TRANSIENT_PREFIX . $scope . '_' . $tool; - } - - /** - * Formats the last checked timestamp for display. - * - * @param int $timestamp Unix timestamp. - * - * @return string - */ - private function format_tool_timestamp( int $timestamp ): string { - $timestamp = max( 0, $timestamp ); - - if ( 0 === $timestamp ) { - return ''; - } - - $date_format = (string) get_option( 'date_format', 'F j, Y' ); - $time_format = (string) get_option( 'time_format', 'g:i a' ); - $format = trim( $date_format . ' ' . $time_format ); - - if ( '' === $format ) { - $format = 'F j, Y g:i a'; - } - - return date_i18n( $format, $timestamp ); - } - - /** - * Generates the markup for the MX lookup tool. - * - * @param string $scope Scope identifier. - * @return string - */ - private function get_tools_mx_section_html( string $scope ): string { - $this->set_scope( $scope ); - - $settings = $this->get_settings(); - $smtp_host = isset( $settings['host'] ) ? (string) $settings['host'] : ''; - $from_email = isset( $settings['from_email'] ) ? (string) $settings['from_email'] : ''; - $sender_domain = $this->extract_domain_from_email( $from_email ); - $normalized_smtp_host = $this->normalize_hostname( $smtp_host ); - $mx_analysis = array( - 'domain' => $sender_domain, - 'records' => array(), - 'errors' => array(), - 'matches_smtp_host' => false, - ); - - if ( '' !== $sender_domain ) { - $mx_analysis = $this->analyze_mx_records( $sender_domain, $normalized_smtp_host ); - } - - ob_start(); - - if ( '' === $sender_domain ) : - ?> -
-

-
- -

- - -
- - -

- -
-

-
    - -
  • - -
-
- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - -
- - - -
- -
-

-
    - -
  • - -
-
- - - - -
-

- -

-
- -
-

- -

-
- - -
-

-
- - - set_scope( $scope ); - - $settings = $this->get_settings(); - $smtp_host = isset( $settings['host'] ) ? (string) $settings['host'] : ''; - $smtp_port = isset( $settings['port'] ) ? (int) $settings['port'] : 0; - $security = isset( $settings['security'] ) ? (string) $settings['security'] : 'none'; - $normalized_host = $this->normalize_hostname( $smtp_host ); - $security_options = $this->get_security_options(); - $security_label = isset( $security_options[ $security ] ) ? $security_options[ $security ] : $security; - - ob_start(); - - if ( '' === $normalized_host ) : - ?> -
-

-
- run_smtp_diagnostics( $settings ); - - if ( ! empty( $diagnostics['errors'] ) ) : - ?> -
-
    - -
  • - -
-
- -
-
    - -
  • - -
-
- -

- - -
- - -

- - -

- - - - - ( - - ) - - -

- - -

-

- -

- - -

- - - - -

- -
    - -
  • - -
- - - -

- -
    - -
  • - -
- -

- - -

- -

- - -

- - -
    - -
  • - -
- - - -

- -

- - -

- -
    - -
  • - -
- - - -

- -

- - -

- - -
    - -
  • - -
- - - - -
- -
-
- - - $settings SMTP settings. - * - * @return array - */ - private function run_smtp_diagnostics( array $settings ): array { - $defaults = array( - 'host' => '', - 'port' => 25, - 'security' => 'none', - ); - - $settings = wp_parse_args( $settings, $defaults ); - - $host = $this->normalize_hostname( (string) $settings['host'] ); - $port = (int) $settings['port']; - $security = in_array( (string) $settings['security'], array( 'none', 'ssl', 'tls' ), true ) ? (string) $settings['security'] : 'none'; - - if ( $port <= 0 || $port > 65535 ) { - $port = 25; - } - - $result = array( - 'success' => false, - 'host' => $host, - 'port' => $port, - 'security' => $security, - 'errors' => array(), - 'warnings' => array(), - 'banner' => '', - 'banner_code' => '', - 'ehlo' => array( - 'code' => '', - 'lines' => array(), - 'timed_out' => false, - ), - 'ehlo_post_tls' => null, - 'helo' => array( - 'attempted' => false, - 'code' => '', - 'lines' => array(), - 'timed_out' => false, - ), - 'tls' => array( - 'mode' => $security, - 'offered' => null, - 'upgrade_attempted' => false, - 'upgrade_response' => array( - 'code' => '', - 'lines' => array(), - 'timed_out' => false, - ), - 'negotiated' => ( 'ssl' === $security ), - ), - 'auth_mechanisms' => array(), - 'transcript' => array(), - ); - - if ( '' === $host ) { - $result['errors'][] = __( 'A valid SMTP host is required to run diagnostics.', 'robotstxt-smtp' ); - - return $result; - } - - $client = $this->create_smtp_client(); - $timeout = 15; - $transport = 'ssl' === $security ? 'ssl://' . $host : $host; - - $client->setDebugOutput( - static function ( $message, $level ) use ( &$result ) { - unset( $level ); - - if ( ! is_string( $message ) ) { - return; - } - - $message = trim( $message ); - - if ( '' === $message ) { - return; - } - - if ( str_starts_with( $message, 'CLIENT -> SERVER:' ) ) { - $result['transcript'][] = 'C: ' . trim( substr( $message, strlen( 'CLIENT -> SERVER:' ) ) ); - - return; - } - - if ( str_starts_with( $message, 'SERVER -> CLIENT:' ) ) { - $result['transcript'][] = 'S: ' . trim( substr( $message, strlen( 'SERVER -> CLIENT:' ) ) ); - } - } - ); - - // phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase - $client->do_debug = SMTP::DEBUG_SERVER; - $client->Timeout = $timeout; - $client->Timelimit = $timeout; - // phpcs:enable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase - - $connected = $client->connect( $transport, $port, $timeout ); - - if ( ! $connected ) { - $error = $client->getError(); - $error_code = isset( $error['smtp_code'] ) && is_numeric( $error['smtp_code'] ) ? (int) $error['smtp_code'] : 0; - $message = ''; - - foreach ( array( 'smtp_code_ex', 'detail', 'error' ) as $key ) { - if ( ! empty( $error[ $key ] ) ) { - $message = (string) $error[ $key ]; - break; - } - } - - if ( '' === $message ) { - $message = __( 'Unknown error', 'robotstxt-smtp' ); - } - - $result['errors'][] = sprintf( - /* translators: 1: Error message. 2: Error code. */ - __( 'Connection failed: %1$s (%2$d).', 'robotstxt-smtp' ), - $message, - $error_code - ); - - $client->close(); - - return $result; - } - - $banner = $this->parse_smtp_reply( $client->getLastReply() ); - if ( '' !== $banner['code'] ) { - $result['banner_code'] = $banner['code']; - } - - if ( ! empty( $banner['lines'] ) ) { - $first_line = preg_replace( '/^\d{3}[ \-]/', '', (string) $banner['lines'][0] ); - $result['banner'] = is_string( $first_line ) ? trim( $first_line ) : ''; - } - - if ( '' !== $result['banner_code'] && '220' !== $result['banner_code'] ) { - $result['warnings'][] = __( 'The server greeting returned an unexpected status code.', 'robotstxt-smtp' ); - } - - $ehlo_domain = $this->get_ehlo_hostname(); - - $ehlo_command = $client->execute_command( 'EHLO', 'EHLO ' . $ehlo_domain ); - $ehlo_response = $this->parse_smtp_reply( $ehlo_command['reply'], $ehlo_command['timed_out'] ); - $result['ehlo'] = $ehlo_response; - - $capabilities = $this->parse_ehlo_capabilities( $ehlo_response['lines'] ); - $result['auth_mechanisms'] = $capabilities['auth_mechanisms']; - $result['tls']['offered'] = $capabilities['has_starttls']; - - if ( '' === $ehlo_response['code'] ) { - $result['warnings'][] = __( 'The EHLO response could not be parsed.', 'robotstxt-smtp' ); - } elseif ( '250' !== $ehlo_response['code'] ) { - $result['warnings'][] = __( 'The server did not accept the EHLO command.', 'robotstxt-smtp' ); - } - - if ( 'tls' === $security ) { - if ( empty( $capabilities['has_starttls'] ) ) { - $result['warnings'][] = __( 'The server did not advertise STARTTLS support.', 'robotstxt-smtp' ); - } else { - $result['tls']['upgrade_attempted'] = true; - $tls_negotiated = $client->startTLS(); - $starttls_reply = $this->parse_smtp_reply( $client->getLastReply(), $client->did_last_command_timeout() ); - $result['tls']['upgrade_response'] = $starttls_reply; - - if ( $tls_negotiated ) { - $result['tls']['negotiated'] = true; - - $post_tls_command = $client->execute_command( 'EHLO', 'EHLO ' . $ehlo_domain ); - $post_tls_response = $this->parse_smtp_reply( $post_tls_command['reply'], $post_tls_command['timed_out'] ); - $result['ehlo_post_tls'] = $post_tls_response; - $post_tls_capabilities = $this->parse_ehlo_capabilities( $post_tls_response['lines'] ); - - if ( ! empty( $post_tls_capabilities['auth_mechanisms'] ) ) { - $result['auth_mechanisms'] = $post_tls_capabilities['auth_mechanisms']; - } - } else { - $result['warnings'][] = __( 'The TLS negotiation failed after STARTTLS.', 'robotstxt-smtp' ); - } - } - } - - if ( 'none' === $security && ! empty( $capabilities['has_starttls'] ) ) { - $result['warnings'][] = __( 'The server supports STARTTLS. Enable TLS in the configuration to protect the connection.', 'robotstxt-smtp' ); - } - - if ( empty( $result['auth_mechanisms'] ) ) { - $result['warnings'][] = __( 'No authentication mechanisms were advertised by the server.', 'robotstxt-smtp' ); - } - - if ( '250' !== $ehlo_response['code'] ) { - $result['helo']['attempted'] = true; - $helo_command = $client->execute_command( 'HELO', 'HELO ' . $ehlo_domain ); - $helo_response = $this->parse_smtp_reply( $helo_command['reply'], $helo_command['timed_out'] ); - $result['helo']['code'] = $helo_response['code']; - $result['helo']['lines'] = $helo_response['lines']; - - if ( '' === $helo_response['code'] || '250' !== $helo_response['code'] ) { - $result['warnings'][] = __( 'The legacy HELO command did not return a successful status code.', 'robotstxt-smtp' ); - } - } - - $client->execute_command( 'QUIT', 'QUIT', array( 221 ) ); - $client->close(); - - if ( ! $result['tls']['negotiated'] ) { - $result['warnings'][] = __( 'The connection is not encrypted. Credentials may travel in plain text.', 'robotstxt-smtp' ); - } - - $result['auth_mechanisms'] = array_values( array_unique( array_map( 'strtoupper', $result['auth_mechanisms'] ) ) ); - $result['warnings'] = array_values( array_unique( $result['warnings'] ) ); - $result['errors'] = array_values( array_unique( $result['errors'] ) ); - $result['success'] = empty( $result['errors'] ); - - return $result; - } - - /** - * Determines the hostname used when sending EHLO/HELO commands. - * - * @return string - */ - private function get_ehlo_hostname(): string { - $home = home_url( '/' ); - - if ( is_string( $home ) ) { - $parsed = wp_parse_url( $home ); - - if ( is_array( $parsed ) && isset( $parsed['host'] ) && '' !== $parsed['host'] ) { - return strtolower( rtrim( (string) $parsed['host'], '.' ) ); - } - } - - if ( function_exists( 'gethostname' ) ) { - $hostname = gethostname(); - - if ( is_string( $hostname ) && '' !== $hostname ) { - return strtolower( rtrim( $hostname, '.' ) ); - } - } - - return 'localhost'; - } - - /** - * Parses a raw SMTP reply string. - * - * @param string $reply Raw reply returned by the server. - * @param bool $timed_out Whether the request timed out. - * - * @return array - */ - private function parse_smtp_reply( string $reply, bool $timed_out = false ): array { - $lines = array(); - $code = ''; - - if ( '' !== $reply ) { - $normalized = str_replace( array( "\r\n", "\r" ), "\n", $reply ); - $parts = array_filter( array_map( 'trim', explode( "\n", trim( $normalized ) ) ), 'strlen' ); - - foreach ( $parts as $line ) { - $lines[] = $line; - - if ( '' === $code && preg_match( '/^(\d{3})/', $line, $matches ) ) { - $code = $matches[1]; - } - } - } - - return array( - 'code' => $code, - 'lines' => $lines, - 'timed_out' => $timed_out, - ); - } - - /** - * Creates an SMTP diagnostics client instance. - * - * @return SMTP_Diagnostics_Client - */ - private function create_smtp_client(): SMTP_Diagnostics_Client { - if ( ! class_exists( SMTP::class ) ) { - require_once ABSPATH . WPINC . '/PHPMailer/SMTP.php'; - } - - return new SMTP_Diagnostics_Client(); - } - - /** - * Parses the EHLO response to extract advertised capabilities. - * - * @param array $lines Response lines. - * - * @return array - */ - private function parse_ehlo_capabilities( array $lines ): array { - $result = array( - 'raw' => array(), - 'has_starttls' => false, - 'auth_mechanisms' => array(), - ); - - foreach ( $lines as $line ) { - $text = (string) $line; - - if ( preg_match( '/^\d{3}[ \-](.*)$/', $text, $matches ) ) { - $text = trim( (string) $matches[1] ); - } else { - $text = trim( $text ); - } - - if ( '' === $text ) { - continue; - } - - $result['raw'][] = $text; - - $upper = strtoupper( $text ); - - if ( 0 === strpos( $upper, 'STARTTLS' ) ) { - $result['has_starttls'] = true; - } - - if ( 0 === strpos( $upper, 'AUTH' ) ) { - $after_auth = trim( substr( $text, 4 ) ); - $after_auth = ltrim( $after_auth, '= ' ); - - if ( '' !== $after_auth ) { - $mechanisms = preg_split( '/\s+/', $after_auth ); - - if ( is_array( $mechanisms ) ) { - foreach ( $mechanisms as $mechanism ) { - $mechanism = strtoupper( trim( (string) $mechanism ) ); - - if ( '' !== $mechanism ) { - $result['auth_mechanisms'][] = $mechanism; - } - } - } - } - } - } - - $result['auth_mechanisms'] = array_values( array_unique( $result['auth_mechanisms'] ) ); - - return $result; - } - - /** - * Generates the markup for the SPF, DKIM, and DMARC checks. - * - * @param string $scope Scope identifier. - * @return string - */ - private function get_tools_authentication_section_html( string $scope ): string { - $this->set_scope( $scope ); - - $settings = $this->get_settings(); - $smtp_host = isset( $settings['host'] ) ? (string) $settings['host'] : ''; - $from_email = isset( $settings['from_email'] ) ? (string) $settings['from_email'] : ''; - $sender_domain = $this->extract_domain_from_email( $from_email ); - $normalized_smtp_host = $this->normalize_hostname( $smtp_host ); - $mx_analysis = array( - 'domain' => $sender_domain, - 'records' => array(), - 'errors' => array(), - 'matches_smtp_host' => false, - ); - $host_ips = $this->get_hostname_ip_addresses( $normalized_smtp_host ); - - if ( '' !== $sender_domain ) { - $mx_analysis = $this->analyze_mx_records( $sender_domain, $normalized_smtp_host ); - } - - ob_start(); - - if ( '' === $sender_domain ) : - ?> -
-

-
- analyze_domain_authentication( $sender_domain, $normalized_smtp_host, $mx_analysis, $host_ips ); - - if ( ! empty( $auth_analysis['errors'] ) ) : - ?> -
-
    - -
  • - -
-
- -

- - -
-
    - -
  • - -
-
- -
-

-
- -
    - -
  • - -
- - -
-

-
- -
-

-
- -
-

-
- - - -

- - -
-
    - -
  • - -
-
- -
-

- -

- -
- -
-

-
- - -

- - -
-
    - -
  • - -
-
- -
-

-
- -

- - -

- -

- - - -
-
    - -
  • - -
-
- -
-

-
- - - set_scope( $scope ); - - $settings = $this->get_settings(); - $smtp_host = isset( $settings['host'] ) ? (string) $settings['host'] : ''; - $normalized_smtp_host = $this->normalize_hostname( $smtp_host ); - $host_ips = $this->get_hostname_ip_addresses( $normalized_smtp_host ); - $analysis = $this->analyze_blacklist_status( $host_ips ); - - ob_start(); - - if ( ! empty( $analysis['errors'] ) ) : - ?> -
-
    - -
  • - -
-
- -
-

-
- -
-

-
- -

- -

- - -
-
    - -
  • - -
-
- - - - - - - - - - - - - - - - - - - - - - - -
-
- -
- - - -

- - -

- - -

- - - -
    - -
  • - -
- -

- - -

- -
-

- - -

- - - -

- -
- get_current_admin_scope(); - - $this->ensure_capability( $scope ); - $this->set_scope( $scope ); - - $settings = $this->get_settings(); - $logging_enabled = ! empty( $settings['logs_enabled'] ); - $nonce_action = $this->get_logs_nonce_action(); - $nonce_value = filter_input( INPUT_GET, 'robotstxt_smtp_logs_nonce', FILTER_UNSAFE_RAW ); - - // Only honor filter arguments after confirming that the nonce matches the filter form submission. - $nonce_valid = is_string( $nonce_value ) && '' !== $nonce_value && wp_verify_nonce( wp_unslash( $nonce_value ), $nonce_action ); - $nonce_required = $this->is_logs_request_using_user_input(); - - $request_args = array(); - - if ( $nonce_required && ! $nonce_valid ) { - $log_id = 0; - $paged = 1; - $filters = $this->get_default_log_filters(); - } else { - if ( $nonce_valid ) { - $request_args = $this->get_sanitized_logs_request_args(); - } - - $log_id = $this->get_requested_log_id( $request_args ); - $paged = $this->get_requested_paged( $request_args ); - $filters = $this->get_log_filters( $request_args ); - } - - $logs_nonce = wp_create_nonce( $nonce_action ); - - ?> -
-

- - -
-

-
- - - -
-

-
- - - -
-

-
- - - -
-

-
- - - 0 ) { - $this->render_log_details( $log_id, $scope, $filters, $logs_nonce ); - } else { - $this->render_logs_list( $paged, $scope, $filters, $logs_nonce ); - } - ?> -
- Filter values. - */ - private function get_logs_nonce_action(): string { - return 'robotstxt_smtp_manage_logs'; - } - - /** - * Determines whether the current request attempts to filter or paginate the logs list. - * - * @return bool - */ - private function is_logs_request_using_user_input(): bool { - if ( filter_has_var( INPUT_GET, 'paged' ) ) { - return true; - } - - $keys = array( - 'robotstxt_smtp_subject', - 'robotstxt_smtp_to', - 'robotstxt_smtp_date_from', - 'robotstxt_smtp_date_to', - 'robotstxt_smtp_per_page', - 'log_id', - ); - - foreach ( $keys as $key ) { - if ( filter_has_var( INPUT_GET, $key ) ) { - return true; - } - } - - return false; - } - - /** - * Retrieves the sanitized request parameters used to filter the logs list. - * - * @return array - */ - private function get_sanitized_logs_request_args(): array { - $request = array(); - - $log_id = filter_input( INPUT_GET, 'log_id', FILTER_UNSAFE_RAW ); - - if ( null !== $log_id && '' !== $log_id ) { - // Cast to an absolute integer before using the requested log identifier. - $request['log_id'] = absint( wp_unslash( (string) $log_id ) ); - } - - $paged = filter_input( INPUT_GET, 'paged', FILTER_UNSAFE_RAW ); - - if ( null !== $paged && '' !== $paged ) { - // Force pagination to a positive integer to avoid loading invalid pages. - $request['paged'] = max( 1, absint( wp_unslash( (string) $paged ) ) ); - } - - $subject = filter_input( INPUT_GET, 'robotstxt_smtp_subject', FILTER_UNSAFE_RAW ); - - if ( is_string( $subject ) && '' !== $subject ) { - // Sanitize the email subject search term before passing it to WP_Query. - $request['robotstxt_smtp_subject'] = sanitize_text_field( wp_unslash( $subject ) ); - } - - $recipient = filter_input( INPUT_GET, 'robotstxt_smtp_to', FILTER_UNSAFE_RAW ); - - if ( is_string( $recipient ) && '' !== $recipient ) { - // Normalize the recipient filter to plain text for safe database queries. - $request['robotstxt_smtp_to'] = sanitize_text_field( wp_unslash( $recipient ) ); - } - - $date_from = filter_input( INPUT_GET, 'robotstxt_smtp_date_from', FILTER_UNSAFE_RAW ); - - if ( is_string( $date_from ) && '' !== $date_from ) { - // Validate the start date to guard against malformed date strings. - $request['robotstxt_smtp_date_from'] = $this->sanitize_log_date( $date_from ); - } - - $date_to = filter_input( INPUT_GET, 'robotstxt_smtp_date_to', FILTER_UNSAFE_RAW ); - - if ( is_string( $date_to ) && '' !== $date_to ) { - // Validate the end date to guard against malformed date strings. - $request['robotstxt_smtp_date_to'] = $this->sanitize_log_date( $date_to ); - } - - $per_page = filter_input( INPUT_GET, 'robotstxt_smtp_per_page', FILTER_UNSAFE_RAW ); - - if ( null !== $per_page && '' !== $per_page ) { - // Clamp the per-page setting to a non-negative integer before building the query. - $request['robotstxt_smtp_per_page'] = absint( wp_unslash( (string) $per_page ) ); - } - - return $request; - } - - /** - * Retrieves the requested log identifier from the current request. - * - * @param array $request Request arguments. - * - * @return int Log identifier if provided, otherwise 0. - */ - private function get_requested_log_id( array $request ): int { - if ( ! isset( $request['log_id'] ) ) { - return 0; - } - - return (int) $request['log_id']; - } - - /** - * Retrieves the requested page number when the nonce is valid. - * - * @param array $request Request arguments. - * - * @return int - */ - private function get_requested_paged( array $request ): int { - if ( ! isset( $request['paged'] ) ) { - return 1; - } - - return (int) $request['paged']; - } - - /** - * Returns the default filter values for the logs list. - * - * @return array - */ - private function get_default_log_filters(): array { - return array( - 'subject' => '', - 'to' => '', - 'date_from' => '', - 'date_to' => '', - 'per_page' => 100, - ); - } - - /** - * Retrieves the current filters applied to the logs list. - * - * @param array $request Request arguments. - * - * @return array Filter values. - */ - private function get_log_filters( array $request ): array { - $filters = $this->get_default_log_filters(); - - if ( isset( $request['robotstxt_smtp_subject'] ) ) { - $filters['subject'] = $request['robotstxt_smtp_subject']; - } - - if ( isset( $request['robotstxt_smtp_to'] ) ) { - $filters['to'] = $request['robotstxt_smtp_to']; - } - - if ( isset( $request['robotstxt_smtp_date_from'] ) ) { - $filters['date_from'] = $request['robotstxt_smtp_date_from']; - } - - if ( isset( $request['robotstxt_smtp_date_to'] ) ) { - $filters['date_to'] = $request['robotstxt_smtp_date_to']; - } - - $allowed_per_page = array( 10, 25, 50, 100, 250, 500 ); - - if ( isset( $request['robotstxt_smtp_per_page'] ) ) { - $requested_per_page = (int) $request['robotstxt_smtp_per_page']; - - if ( in_array( $requested_per_page, $allowed_per_page, true ) ) { - $filters['per_page'] = $requested_per_page; - } - } - - return $filters; - } - - /** - * Builds the query arguments that represent the current log filters. - * - * @param array $filters Filter values. - * - * @return array URL query arguments. - */ - private function get_log_filter_query_args( array $filters ): array { - $query_args = array(); - - if ( '' !== $filters['subject'] ) { - $query_args['robotstxt_smtp_subject'] = $filters['subject']; - } - - if ( '' !== $filters['to'] ) { - $query_args['robotstxt_smtp_to'] = $filters['to']; - } - - if ( '' !== $filters['date_from'] ) { - $query_args['robotstxt_smtp_date_from'] = $filters['date_from']; - } - - if ( '' !== $filters['date_to'] ) { - $query_args['robotstxt_smtp_date_to'] = $filters['date_to']; - } - - if ( 100 !== $filters['per_page'] ) { - $query_args['robotstxt_smtp_per_page'] = (string) $filters['per_page']; - } - - return $query_args; - } - - /** - * Sanitizes a date string coming from the logs filters. - * - * @param string $value Raw date value. - * - * @return string Sanitized date in `Y-m-d` format or an empty string when invalid. - */ - private function sanitize_log_date( string $value ): string { - $value = sanitize_text_field( $value ); - - if ( '' === $value ) { - return ''; - } - - $date = \DateTime::createFromFormat( 'Y-m-d', $value ); - - if ( ! $date ) { - return ''; - } - - $errors = \DateTime::getLastErrors(); - - if ( is_array( $errors ) && ( $errors['warning_count'] > 0 || $errors['error_count'] > 0 ) ) { - return ''; - } - - return $date->format( 'Y-m-d' ); - } - - /** - * Renders the table listing of log entries. - * - * @param int $paged Current page number. - * @param string $scope Scope identifier (site or network). - * @param array $filters Current filter values. - * @param string $nonce Logs nonce value. - * - * @return void - */ - private function render_logs_list( int $paged, string $scope, array $filters, string $nonce ): void { - $per_page = $filters['per_page']; - $filter_query_args = $this->get_log_filter_query_args( $filters ); - - $query_args = array( - 'post_type' => Plugin::get_log_post_type(), - 'post_status' => 'publish', - 'posts_per_page' => $per_page, - 'paged' => $paged, - 'orderby' => 'date', - 'order' => 'DESC', - ); - - if ( '' !== $filters['subject'] ) { - $query_args['s'] = $filters['subject']; - } - - if ( '' !== $filters['to'] ) { - // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Recipient filter requires meta_query. - $query_args['meta_query'] = array( - array( - 'key' => '_robotstxt_smtp_to', - 'value' => $filters['to'], - 'compare' => 'LIKE', - ), - ); - } - - if ( '' !== $filters['date_from'] || '' !== $filters['date_to'] ) { - $date_query = array( - 'inclusive' => true, - ); - - if ( '' !== $filters['date_from'] ) { - $date_query['after'] = $filters['date_from']; - } - - if ( '' !== $filters['date_to'] ) { - $date_query['before'] = $filters['date_to']; - } - - $query_args['date_query'] = array( $date_query ); - } - - $query = new \WP_Query( $query_args ); - - $base_url = remove_query_arg( - array( 'paged', 'log_id', 'robotstxt_smtp_cleared' ), - add_query_arg( - array_merge( - array( - 'page' => self::LOGS_PAGE_SLUG, - 'robotstxt_smtp_logs_nonce' => $nonce, - ), - $filter_query_args - ), - $this->get_admin_url_for_scope( $scope, 'admin.php' ) - ) - ); - - $reset_url = empty( $filter_query_args ) - ? $base_url - : remove_query_arg( array_keys( $filter_query_args ), $base_url ); - - ?> -
- - get_logs_nonce_action(), 'robotstxt_smtp_logs_nonce', false ); - ?> -
-

- - -

-

- - -

-

- - -

-

- - -

-

- - -

-

- -

-

- -

-
-
- -
-
- - - - "return confirm('" . $confirmation . "');", - ) - ); - ?> -
-
- - posts ) ) : ?> -

- - - - - - - - - - - - - - - - posts as $log ) : ?> - ID, '_robotstxt_smtp_from', true ); - $to = get_post_meta( $log->ID, '_robotstxt_smtp_to', true ); - $subject = $log->post_title ? $log->post_title : __( '(No subject)', 'robotstxt-smtp' ); - $status_display = $this->get_log_status_display( (int) $log->ID ); - $view_url = add_query_arg( - array_merge( - array( - 'page' => self::LOGS_PAGE_SLUG, - 'log_id' => $log->ID, - 'robotstxt_smtp_logs_nonce' => $nonce, - ), - $filter_query_args - ), - $this->get_admin_url_for_scope( $scope, 'admin.php' ) - ); - $date = get_date_from_gmt( - $log->post_date_gmt, - get_option( 'date_format' ) . ' ' . get_option( 'time_format' ) - ); - ?> - - - - - - - - - - -
- - - - - - - -
- - add_query_arg( 'paged', '%#%', $base_url ), - 'format' => '', - 'current' => max( 1, $paged ), - 'total' => max( 1, (int) $query->max_num_pages ), - 'prev_text' => __( '«', 'robotstxt-smtp' ), - 'next_text' => __( '»', 'robotstxt-smtp' ), - ) - ); - - if ( $pagination ) { - echo '
' . wp_kses_post( $pagination ) . '
'; - } - - wp_reset_postdata(); - } - - /** - * Displays the details of a single log entry. - * - * @param int $log_id Log post ID. - * @param string $scope Scope identifier (site or network). - * @param array $filters Current filter values. - * @param string $nonce Logs nonce value. - * - * @return void - */ - private function render_log_details( int $log_id, string $scope, array $filters, string $nonce ): void { - $log = get_post( $log_id ); - - if ( ! $log || Plugin::get_log_post_type() !== $log->post_type ) { - echo '

' . esc_html__( 'The requested log entry could not be found.', 'robotstxt-smtp' ) . '

'; - $this->render_logs_list( 1, $scope, $filters, $nonce ); - return; - } - - $from = get_post_meta( $log->ID, '_robotstxt_smtp_from', true ); - $to = get_post_meta( $log->ID, '_robotstxt_smtp_to', true ); - $headers = (string) get_post_meta( $log->ID, '_robotstxt_smtp_headers', true ); - $attachments = maybe_unserialize( get_post_meta( $log->ID, '_robotstxt_smtp_attachments', true ) ); - $debug_log = maybe_unserialize( get_post_meta( $log->ID, '_robotstxt_smtp_debug_log', true ) ); - $date = get_date_from_gmt( $log->post_date_gmt, get_option( 'date_format' ) . ' ' . get_option( 'time_format' ) ); - $subject = $log->post_title ? $log->post_title : __( '(No subject)', 'robotstxt-smtp' ); - $status = $this->get_log_status_display( (int) $log->ID ); - $error = (string) get_post_meta( $log->ID, '_robotstxt_smtp_error', true ); - - if ( ! is_array( $attachments ) ) { - $attachments = array(); - } - - if ( ! is_array( $debug_log ) ) { - $debug_log = array(); - } - - $normalized_attachments = array(); - $normalized_debug_log = array(); - - foreach ( $attachments as $attachment ) { - if ( ! is_scalar( $attachment ) ) { - continue; - } - - $attachment_name = trim( (string) $attachment ); - - if ( '' === $attachment_name ) { - continue; - } - - $normalized_attachments[] = $attachment_name; - } - - foreach ( $debug_log as $debug_line ) { - if ( ! is_scalar( $debug_line ) ) { - continue; - } - - $clean_line = sanitize_textarea_field( (string) $debug_line ); - - if ( '' === $clean_line ) { - continue; - } - - $normalized_debug_log[] = $clean_line; - } - - ?> -

←

- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
- -
- -

-
- -

- -
    - -
  • - -
- -

- - -

- post_content ) : ?> -
post_content ) ); ?>
- -

- - -

- -
- -
-
- -

- - - */ - private function get_log_status_display( int $log_id ): array { - $status = get_post_meta( $log_id, '_robotstxt_smtp_status', true ); - - if ( 'error' === $status ) { - return array( - 'status' => 'error', - 'label' => __( 'Failed', 'robotstxt-smtp' ), - 'class' => 'robotstxt-smtp-log-status-error', - ); - } - - return array( - 'status' => 'sent', - 'label' => __( 'Sent', 'robotstxt-smtp' ), - 'class' => 'robotstxt-smtp-log-status-sent', - ); - } - - /** - * Handles the request to clear all stored logs. - * - * @return void - */ - public function handle_clear_logs(): void { - $nonce_value = filter_input( INPUT_POST, '_wpnonce', FILTER_UNSAFE_RAW ); - - // Block log deletions unless the nonce matches the action button submission. - if ( ! is_string( $nonce_value ) || ! wp_verify_nonce( wp_unslash( $nonce_value ), 'robotstxt_smtp_clear_logs' ) ) { - wp_die( esc_html__( 'The link you followed has expired.', 'robotstxt-smtp' ) ); - } - - $scope = self::SCOPE_SITE; - - $context_raw = filter_input( INPUT_POST, 'robotstxt_smtp_context', FILTER_UNSAFE_RAW ); - - if ( is_string( $context_raw ) && '' !== $context_raw ) { - // Sanitize the submitted scope before checking the requested context. - $context = sanitize_text_field( wp_unslash( $context_raw ) ); - - if ( self::SCOPE_NETWORK === $context ) { - $scope = self::SCOPE_NETWORK; - } - } - - $this->ensure_capability( $scope ); - $this->set_scope( $scope ); - - Plugin::get_instance()->clear_all_logs(); - - $redirect = add_query_arg( - array( - 'page' => self::LOGS_PAGE_SLUG, - 'robotstxt_smtp_cleared' => 1, - ), - $this->get_admin_url_for_scope( $scope, 'admin.php' ) - ); - - wp_safe_redirect( $redirect ); - exit; - } - - /** - * Renders the host field. - * - * @return void - */ - public function render_host_field(): void { - $settings = $this->get_settings(); - ?> - -

- -

- get_settings(); - ?> - -

- get_settings(); - ?> - -

- get_settings(); - ?> - -

- get_settings(); - ?> - -

- get_settings(); - $options = $this->get_security_options(); - ?> - -

- get_settings(); - ?> - -

- get_settings(); - ?> - -

- get_settings(); - $mode = isset( $settings['logs_retention_mode'] ) ? $settings['logs_retention_mode'] : 'count'; - ?> -
- -
- -
-

- get_settings(); - ?> - -

- get_settings(); - ?> - -

- $options Raw option values. - * - * @return array Sanitized option values. - */ - public function sanitize_options( array $options ): array { - $this->cached_settings = null; - - if ( self::SCOPE_SITE === $this->get_scope() && is_admin() && isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' === $_SERVER['REQUEST_METHOD'] ) { - $this->site_settings_submitted = true; - $this->site_settings_option_updated = false; - } - - $clean = self::get_default_settings(); - $options = wp_unslash( $options ); - $security = $this->get_security_options(); - - if ( isset( $options['host'] ) ) { - $clean['host'] = sanitize_text_field( $options['host'] ); - } - - if ( isset( $options['username'] ) ) { - $clean['username'] = sanitize_text_field( $options['username'] ); - } - - if ( isset( $options['password'] ) ) { - $clean['password'] = sanitize_text_field( $options['password'] ); - } - - if ( isset( $options['from_email'] ) ) { - $clean['from_email'] = sanitize_email( $options['from_email'] ); - } - - if ( isset( $options['from_name'] ) ) { - $clean['from_name'] = sanitize_text_field( $options['from_name'] ); - } - - if ( isset( $options['amazon_ses_access_key'] ) ) { - $clean['amazon_ses_access_key'] = sanitize_text_field( $options['amazon_ses_access_key'] ); - } - - if ( isset( $options['amazon_ses_secret_key'] ) ) { - $clean['amazon_ses_secret_key'] = sanitize_text_field( $options['amazon_ses_secret_key'] ); - } - - if ( isset( $options['amazon_ses_region'] ) ) { - $clean['amazon_ses_region'] = sanitize_text_field( $options['amazon_ses_region'] ); - } - - if ( isset( $options['security'] ) && array_key_exists( $options['security'], $security ) ) { - $clean['security'] = $options['security']; - } - - if ( isset( $options['port'] ) ) { - $port = absint( $options['port'] ); - if ( $port > 0 && $port <= 65535 ) { - $clean['port'] = $port; - } - } - - $clean['logs_enabled'] = ! empty( $options['logs_enabled'] ); - - if ( isset( $options['logs_retention_mode'] ) && in_array( $options['logs_retention_mode'], array( 'count', 'days' ), true ) ) { - $clean['logs_retention_mode'] = $options['logs_retention_mode']; - } - - if ( isset( $options['logs_retention_count'] ) ) { - $clean['logs_retention_count'] = absint( $options['logs_retention_count'] ); - } - - if ( isset( $options['logs_retention_days'] ) ) { - $clean['logs_retention_days'] = absint( $options['logs_retention_days'] ); - } - - /** - * Filters the sanitized SMTP options before they are persisted. - * - * This hook allows integrations to adjust the sanitized values or - * perform additional validation based on the submitted form data. - * - * @since 1.1.0 - * - * @param array $clean Sanitized option values. - * @param array $options Raw submitted values after `wp_unslash()`. - * @param Settings_Page $settings Settings page instance. - */ - $clean = (array) \apply_filters( 'robotstxt_smtp_sanitized_options', $clean, $options, $this ); - - return $clean; - } - - /** - * Retrieves the stored settings merged with defaults. - * - * @return array Stored settings. - */ - private function get_settings(): array { - if ( null !== $this->cached_settings ) { - return $this->cached_settings; - } - - $defaults = self::get_default_settings(); - $option_name = $this->get_option_name_for_scope(); - - if ( self::SCOPE_NETWORK === $this->get_scope() ) { - $settings = get_site_option( $option_name, array() ); - } else { - $settings = get_option( $option_name, array() ); - } - - if ( ! is_array( $settings ) ) { - $settings = array(); - } - - $this->cached_settings = wp_parse_args( $settings, $defaults ); - - return $this->cached_settings; - } - - /** - * Extracts the domain portion from an email address. - * - * @param string $email Email address. - * - * @return string - */ - private function extract_domain_from_email( string $email ): string { - $sanitized = sanitize_email( $email ); - - if ( empty( $sanitized ) || false === strpos( $sanitized, '@' ) ) { - return ''; - } - - $parts = explode( '@', $sanitized ); - $domain = array_pop( $parts ); - - if ( ! is_string( $domain ) ) { - return ''; - } - - $domain = strtolower( $domain ); - $domain = rtrim( $domain, '.' ); - - return $domain; - } - - /** - * Normalizes a hostname for comparison. - * - * @param string $hostname Hostname to normalize. - * - * @return string - */ - private function normalize_hostname( string $hostname ): string { - $normalized = strtolower( trim( $hostname ) ); - - if ( '' === $normalized ) { - return ''; - } - - if ( false !== strpos( $normalized, '://' ) ) { - $parsed = wp_parse_url( $normalized ); - - if ( is_array( $parsed ) && isset( $parsed['host'] ) ) { - $normalized = strtolower( (string) $parsed['host'] ); - } - } - - $normalized = ltrim( $normalized, '/\\' ); - - $normalized = preg_replace( '/:\d+$/', '', $normalized ); - - if ( ! is_string( $normalized ) ) { - $normalized = ''; - } - - $normalized = rtrim( $normalized, '.' ); - - return $normalized; - } - - /** - * Analyzes SPF, DKIM, and DMARC records for the provided domain. - * - * @param string $domain Domain to analyze. - * @param string $smtp_host Normalized SMTP host. - * @param array $mx_analysis MX lookup results. - * @param array>|null $host_ips Optional pre-resolved SMTP host IP addresses. - * - * @return array - */ - private function analyze_domain_authentication( string $domain, string $smtp_host, array $mx_analysis, ?array $host_ips = null ): array { - $result = array( - 'domain' => $domain, - 'errors' => array(), - 'spf' => array( - 'records' => array(), - 'errors' => array(), - 'authorized' => null, - 'message' => '', - ), - 'dkim' => array( - 'found' => null, - 'errors' => array(), - 'record' => '', - ), - 'dmarc' => array( - 'record' => '', - 'policy' => '', - 'errors' => array(), - 'recommendations' => array(), - ), - ); - - if ( '' === $domain ) { - $result['errors'][] = __( 'The sender domain could not be determined.', 'robotstxt-smtp' ); - - return $result; - } - - if ( ! function_exists( 'dns_get_record' ) ) { - $result['errors'][] = __( 'DNS lookups are not available because the DNS functions are disabled on this server.', 'robotstxt-smtp' ); - - return $result; - } - - if ( null === $host_ips ) { - $host_ips = $this->get_hostname_ip_addresses( $smtp_host ); - } - $result['spf'] = $this->analyze_spf_records( $domain, $smtp_host, $mx_analysis, $host_ips ); - $result['dkim'] = $this->analyze_dkim_record( $domain ); - $result['dmarc'] = $this->analyze_dmarc_record( $domain ); - - return $result; - } - - /** - * Checks the resolved SMTP host IPs against DNSBL providers. - * - * @param array> $host_ips Resolved IP addresses for the SMTP host. - * - * @return array - */ - private function analyze_blacklist_status( array $host_ips ): array { - $result = array( - 'ips' => array(), - 'ipv6' => array(), - 'errors' => array(), - ); - - if ( ! function_exists( 'dns_get_record' ) ) { - $result['errors'][] = __( 'Blacklist lookups are not available because the DNS functions are disabled on this server.', 'robotstxt-smtp' ); - - return $result; - } - - if ( ! empty( $host_ips['ipv6'] ) ) { - $result['ipv6'] = $host_ips['ipv6']; - } - - if ( empty( $host_ips['ipv4'] ) ) { - return $result; - } - - $providers = $this->get_dnsbl_providers(); - - foreach ( $host_ips['ipv4'] as $ip ) { - if ( false === filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) { - continue; - } - - $ip_result = array( - 'ip' => $ip, - 'errors' => array(), - 'listings' => array(), - ); - - foreach ( $providers as $provider ) { - $ip_result['listings'][] = $this->query_dnsbl_listing( $ip, $provider ); - } - - $result['ips'][] = $ip_result; - } - - return $result; - } - - /** - * Provides the DNSBL providers used for blacklist checks. - * - * @return array> - */ - private function get_dnsbl_providers(): array { - return array( - array( - 'id' => 'spamhaus_zen', - 'label' => __( 'Spamhaus ZEN', 'robotstxt-smtp' ), - 'zone' => 'zen.spamhaus.org', - 'impact' => __( 'High — major inbox providers rely on Spamhaus and a listing can block most traffic.', 'robotstxt-smtp' ), - 'removal_url' => 'https://check.spamhaus.org/', - 'removal_notes' => __( 'Investigate and resolve the root cause, then use the Spamhaus Blocklist Removal Center to request delisting.', 'robotstxt-smtp' ), - ), - array( - 'id' => 'spamcop', - 'label' => __( 'SpamCop', 'robotstxt-smtp' ), - 'zone' => 'bl.spamcop.net', - 'impact' => __( 'Medium — many shared hosts and spam filters consult SpamCop when scoring messages.', 'robotstxt-smtp' ), - 'removal_url' => 'https://www.spamcop.net/w3m?action=checkblock', - 'removal_notes' => __( 'Ensure no unsolicited traffic is sent and follow the SpamCop blocklist removal instructions.', 'robotstxt-smtp' ), - ), - array( - 'id' => 'barracuda', - 'label' => __( 'Barracuda Reputation Block List', 'robotstxt-smtp' ), - 'zone' => 'b.barracudacentral.org', - 'impact' => __( 'Medium — Barracuda appliances and some hosted filters can defer or reject messages.', 'robotstxt-smtp' ), - 'removal_url' => 'https://www.barracudacentral.org/lookups/lookup-reputation', - 'removal_notes' => __( 'Review the Barracuda reputation lookup and submit a delisting request after addressing any spam complaints.', 'robotstxt-smtp' ), - ), - ); - } - - /** - * Queries a DNSBL provider for a specific IPv4 address. - * - * @param string $ip IPv4 address. - * @param array $provider Provider definition. - * - * @return array - */ - private function query_dnsbl_listing( string $ip, array $provider ): array { - $result = array( - 'provider' => $provider, - 'listed' => false, - 'response_ips' => array(), - 'txt_records' => array(), - 'error' => '', - ); - - $reverse = $this->reverse_ipv4_for_dnsbl( $ip ); - - if ( '' === $reverse ) { - $result['error'] = __( 'The IP address could not be normalized for the DNSBL lookup.', 'robotstxt-smtp' ); - - return $result; - } - - $hostname = $reverse . '.' . $provider['zone']; - - $a_records = dns_get_record( $hostname, DNS_A ); - - if ( false === $a_records ) { - /* translators: %s: DNSBL provider name. */ - $result['error'] = sprintf( __( 'The DNS lookup for %s failed. Please try again later.', 'robotstxt-smtp' ), $provider['label'] ); - - return $result; - } - - if ( empty( $a_records ) ) { - return $result; - } - - $result['listed'] = true; - - foreach ( $a_records as $record ) { - if ( isset( $record['ip'] ) && filter_var( $record['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) { - $result['response_ips'][] = (string) $record['ip']; - } - } - - $txt_records = dns_get_record( $hostname, DNS_TXT ); - - if ( false !== $txt_records && ! empty( $txt_records ) ) { - foreach ( $txt_records as $txt_record ) { - if ( isset( $txt_record['txt'] ) && is_string( $txt_record['txt'] ) ) { - $value = trim( (string) $txt_record['txt'] ); - - if ( '' !== $value ) { - $result['txt_records'][] = $value; - } - } - } - } - - return $result; - } - - /** - * Normalizes an IPv4 address for DNSBL queries. - * - * @param string $ip IPv4 address. - * - * @return string - */ - private function reverse_ipv4_for_dnsbl( string $ip ): string { - if ( false === filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) { - return ''; - } - - $parts = explode( '.', $ip ); - - if ( count( $parts ) !== 4 ) { - return ''; - } - - return implode( '.', array_reverse( $parts ) ); - } - - /** - * Inspects SPF records for the sender domain. - * - * @param string $domain Sender domain. - * @param string $smtp_host Normalized SMTP host. - * @param array $mx_analysis MX lookup results. - * @param array $host_ips Resolved IP addresses for the SMTP host. - * - * @return array - */ - private function analyze_spf_records( string $domain, string $smtp_host, array $mx_analysis, array $host_ips ): array { - $result = array( - 'records' => array(), - 'errors' => array(), - 'authorized' => null, - 'message' => __( 'Unable to determine whether the SMTP host is authorized in the SPF record.', 'robotstxt-smtp' ), - ); - - if ( ! function_exists( 'dns_get_record' ) ) { - $result['errors'][] = __( 'DNS lookups are not available because the DNS functions are disabled on this server.', 'robotstxt-smtp' ); - - return $result; - } - - $txt_records = dns_get_record( $domain, DNS_TXT ); - - if ( false === $txt_records ) { - $result['errors'][] = __( 'The DNS lookup for TXT records failed. Please try again later.', 'robotstxt-smtp' ); - - return $result; - } - - foreach ( $txt_records as $record ) { - if ( empty( $record['txt'] ) || ! is_string( $record['txt'] ) ) { - continue; - } - - $value = trim( (string) $record['txt'] ); - - if ( preg_match( '/^v=spf1\b/i', $value ) ) { - $result['records'][] = $value; - } - } - - if ( empty( $result['records'] ) ) { - $result['message'] = __( 'The domain does not publish an SPF record.', 'robotstxt-smtp' ); - $result['authorized'] = null; - - return $result; - } - - if ( '' === $smtp_host ) { - $result['message'] = __( 'Configure an SMTP host to verify its presence in the SPF record.', 'robotstxt-smtp' ); - $result['authorized'] = null; - - return $result; - } - - $normalized_host = strtolower( $smtp_host ); - $mx_hosts = array(); - - if ( isset( $mx_analysis['records'] ) && is_array( $mx_analysis['records'] ) ) { - foreach ( $mx_analysis['records'] as $mx_record ) { - if ( isset( $mx_record['normalized_target'] ) && is_string( $mx_record['normalized_target'] ) ) { - $mx_hosts[] = strtolower( $mx_record['normalized_target'] ); - } - } - } - - $authorized = false; - $authorization_msg = ''; - $could_evaluate = false; - - foreach ( $result['records'] as $spf_record ) { - $tokens = preg_split( '/\s+/', strtolower( $spf_record ) ); - - if ( ! is_array( $tokens ) ) { - continue; - } - - foreach ( $tokens as $token ) { - if ( '' === $token ) { - continue; - } - - $qualifier = ''; - - if ( in_array( $token[0], array( '+', '-', '~', '?' ), true ) ) { - $qualifier = $token[0]; - $token = substr( $token, 1 ); - } - - if ( '' === $token || '-' === $qualifier ) { - continue; - } - - $token = preg_replace( '/\/\d+$/', '', $token ); - - if ( ! is_string( $token ) || '' === $token || 'v=spf1' === $token ) { - continue; - } - - if ( str_starts_with( $token, 'include:' ) || str_starts_with( $token, 'redirect=' ) ) { - $target = str_replace( array( 'include:', 'redirect=' ), '', $token ); - - if ( $this->hostname_matches_domain( $normalized_host, $target ) ) { - $authorized = true; - /* translators: %s: Included SPF domain. */ - $authorization_msg = sprintf( __( 'The SPF record includes %s, which matches the configured SMTP host.', 'robotstxt-smtp' ), $target ); - break 2; - } - - continue; - } - - if ( str_starts_with( $token, 'a:' ) ) { - $target = substr( $token, 2 ); - - if ( $this->hostname_matches_domain( $normalized_host, $target ) ) { - $authorized = true; - /* translators: %s: Hostname authorized via the SPF "a" mechanism. */ - $authorization_msg = sprintf( __( 'The SPF record authorizes %s via the "a" mechanism.', 'robotstxt-smtp' ), $normalized_host ); - break 2; - } - - continue; - } - - if ( 'a' === $token ) { - if ( $this->hostname_matches_domain( $normalized_host, $domain ) ) { - $authorized = true; - /* translators: %s: Hostname authorized via the SPF "a" mechanism. */ - $authorization_msg = sprintf( __( 'The SPF record authorizes %s via the "a" mechanism.', 'robotstxt-smtp' ), $normalized_host ); - break 2; - } - - continue; - } - - if ( str_starts_with( $token, 'mx:' ) ) { - $target = substr( $token, 3 ); - - if ( $this->hostname_matches_domain( $normalized_host, $target ) ) { - $authorized = true; - /* translators: %s: Hostname authorized via the SPF "mx" mechanism. */ - $authorization_msg = sprintf( __( 'The SPF record authorizes %s via the "mx" mechanism.', 'robotstxt-smtp' ), $normalized_host ); - break 2; - } - - continue; - } - - if ( 'mx' === $token && in_array( $normalized_host, $mx_hosts, true ) ) { - $authorized = true; - /* translators: %s: Hostname authorized via the SPF "mx" mechanism. */ - $authorization_msg = sprintf( __( 'The SPF record authorizes %s via the "mx" mechanism.', 'robotstxt-smtp' ), $normalized_host ); - break 2; - } - - if ( str_starts_with( $token, 'ip4:' ) ) { - $cidr = substr( $token, 4 ); - - if ( '' === $cidr || ! is_array( $host_ips['ipv4'] ) ) { - continue; - } - - foreach ( $host_ips['ipv4'] as $ip ) { - if ( $this->ipv4_in_cidr( $ip, $cidr ) ) { - $authorized = true; - /* translators: %1$s: IP address. %2$s: SPF mechanism. */ - $authorization_msg = sprintf( __( 'The SPF record authorizes the SMTP host IP %1$s via %2$s.', 'robotstxt-smtp' ), $ip, 'ip4' ); - break 3; - } - } - - $could_evaluate = true; - - continue; - } - - if ( str_starts_with( $token, 'ip6:' ) ) { - $cidr = substr( $token, 4 ); - - if ( '' === $cidr || ! is_array( $host_ips['ipv6'] ) ) { - continue; - } - - foreach ( $host_ips['ipv6'] as $ip ) { - if ( $this->ipv6_in_cidr( $ip, $cidr ) ) { - $authorized = true; - /* translators: %1$s: IP address. %2$s: SPF mechanism. */ - $authorization_msg = sprintf( __( 'The SPF record authorizes the SMTP host IP %1$s via %2$s.', 'robotstxt-smtp' ), $ip, 'ip6' ); - break 3; - } - } - - $could_evaluate = true; - } - } - } - - if ( $authorized ) { - $result['authorized'] = true; - $result['message'] = $authorization_msg; - - return $result; - } - - if ( ! empty( $host_ips['ipv4'] ) || ! empty( $host_ips['ipv6'] ) ) { - $result['authorized'] = false; - $result['message'] = __( 'The SMTP host was not found in the SPF record. Add it to avoid delivery issues.', 'robotstxt-smtp' ); - } elseif ( $could_evaluate ) { - $result['authorized'] = null; - $result['message'] = __( 'The SPF record contains IP ranges, but the SMTP host IP could not be resolved.', 'robotstxt-smtp' ); - } else { - $result['authorized'] = null; - $result['message'] = __( 'The SPF record does not explicitly reference the configured SMTP host.', 'robotstxt-smtp' ); - } - - return $result; - } - - /** - * Retrieves IPv4 and IPv6 addresses for the provided hostname. - * - * @param string $hostname Hostname to inspect. - * - * @return array> - */ - private function get_hostname_ip_addresses( string $hostname ): array { - $ips = array( - 'ipv4' => array(), - 'ipv6' => array(), - ); - - if ( '' === $hostname || ! function_exists( 'dns_get_record' ) ) { - return $ips; - } - - $types = DNS_A; - - if ( defined( 'DNS_AAAA' ) ) { - $types |= DNS_AAAA; - } - - $candidates = array( $hostname, $hostname . '.' ); - - foreach ( $candidates as $candidate ) { - $records = dns_get_record( $candidate, $types ); - - if ( empty( $records ) || false === $records ) { - continue; - } - - foreach ( $records as $record ) { - if ( isset( $record['type'], $record['ip'] ) && 'A' === $record['type'] ) { - $ip = (string) $record['ip']; - - if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) { - $ips['ipv4'][ $ip ] = $ip; - } - } - - if ( isset( $record['type'], $record['ipv6'] ) && 'AAAA' === $record['type'] ) { - $ip = (string) $record['ipv6']; - - if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 ) ) { - $ips['ipv6'][ $ip ] = $ip; - } - } - } - } - - $ips['ipv4'] = array_values( $ips['ipv4'] ); - $ips['ipv6'] = array_values( $ips['ipv6'] ); - - return $ips; - } - - /** - * Determines whether the provided hostname belongs to the given domain. - * - * @param string $hostname Hostname to compare. - * @param string $domain Domain to check against. - * - * @return bool - */ - private function hostname_matches_domain( string $hostname, string $domain ): bool { - $hostname = strtolower( rtrim( $hostname, '.' ) ); - $domain = strtolower( rtrim( $domain, '.' ) ); - - if ( '' === $hostname || '' === $domain ) { - return false; - } - - if ( $hostname === $domain ) { - return true; - } - - return str_ends_with( $hostname, '.' . $domain ); - } - - /** - * Determines whether an IPv4 address belongs to the provided CIDR. - * - * @param string $ip IPv4 address. - * @param string $cidr CIDR expression. - * - * @return bool - */ - private function ipv4_in_cidr( string $ip, string $cidr ): bool { - if ( false === filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) { - return false; - } - - $parts = explode( '/', $cidr, 2 ); - $net = $parts[0]; - $bits = isset( $parts[1] ) ? (int) $parts[1] : 32; - - if ( false === filter_var( $net, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) { - return false; - } - - if ( $bits < 0 || $bits > 32 ) { - return false; - } - - $ip_long = unpack( 'N', inet_pton( $ip ) ); - $net_long = unpack( 'N', inet_pton( $net ) ); - - if ( ! is_array( $ip_long ) || ! is_array( $net_long ) ) { - return false; - } - - $mask = 0; - - if ( 0 !== $bits ) { - $mask = ( 0xFFFFFFFF << ( 32 - $bits ) ) & 0xFFFFFFFF; - } - - return ( ( $ip_long[0] & $mask ) === ( $net_long[0] & $mask ) ); - } - - /** - * Determines whether an IPv6 address belongs to the provided CIDR. - * - * @param string $ip IPv6 address. - * @param string $cidr CIDR expression. - * - * @return bool - */ - private function ipv6_in_cidr( string $ip, string $cidr ): bool { - if ( false === filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 ) ) { - return false; - } - - $parts = explode( '/', $cidr, 2 ); - $net = $parts[0]; - $bits = isset( $parts[1] ) ? (int) $parts[1] : 128; - - if ( false === filter_var( $net, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 ) ) { - return false; - } - - if ( $bits < 0 || $bits > 128 ) { - return false; - } - - $ip_bin = inet_pton( $ip ); - $net_bin = inet_pton( $net ); - - if ( false === $ip_bin || false === $net_bin ) { - return false; - } - - $remaining = $bits; - - for ( $i = 0; $i < 16; $i++ ) { - if ( $remaining <= 0 ) { - break; - } - - $mask = 0xFF; - - if ( $remaining < 8 ) { - $mask = ( 0xFF << ( 8 - $remaining ) ) & 0xFF; - } - - if ( ( ord( $ip_bin[ $i ] ) & $mask ) !== ( ord( $net_bin[ $i ] ) & $mask ) ) { - return false; - } - - $remaining -= 8; - } - - return true; - } - - /** - * Looks up a DKIM record using the default selector. - * - * @param string $domain Domain to inspect. - * - * @return array - */ - private function analyze_dkim_record( string $domain ): array { - $result = array( - 'found' => false, - 'errors' => array(), - 'record' => '', - ); - - if ( ! function_exists( 'dns_get_record' ) ) { - $result['errors'][] = __( 'DNS lookups are not available because the DNS functions are disabled on this server.', 'robotstxt-smtp' ); - - return $result; - } - - $selector_domain = 'default._domainkey.' . $domain; - $records = dns_get_record( $selector_domain, DNS_TXT ); - - if ( false === $records ) { - /* translators: %s: Domain queried for the DKIM record lookup. */ - $result['errors'][] = sprintf( __( 'The DNS lookup for %s failed. Please try again later.', 'robotstxt-smtp' ), $selector_domain ); - - return $result; - } - - foreach ( $records as $record ) { - if ( empty( $record['txt'] ) || ! is_string( $record['txt'] ) ) { - continue; - } - - $value = trim( (string) $record['txt'] ); - - if ( preg_match( '/^v=DKIM1/i', $value ) ) { - $result['found'] = true; - $result['record'] = $value; - break; - } - } - - return $result; - } - - /** - * Looks up the DMARC policy for the sender domain. - * - * @param string $domain Domain to inspect. - * - * @return array - */ - private function analyze_dmarc_record( string $domain ): array { - $result = array( - 'record' => '', - 'policy' => '', - 'errors' => array(), - 'recommendations' => array(), - ); - - if ( ! function_exists( 'dns_get_record' ) ) { - $result['errors'][] = __( 'DNS lookups are not available because the DNS functions are disabled on this server.', 'robotstxt-smtp' ); - - return $result; - } - - $dmarc_domain = '_dmarc.' . $domain; - $records = dns_get_record( $dmarc_domain, DNS_TXT ); - - if ( false === $records ) { - /* translators: %s: Domain queried for the DMARC record lookup. */ - $result['errors'][] = sprintf( __( 'The DNS lookup for %s failed. Please try again later.', 'robotstxt-smtp' ), $dmarc_domain ); - - return $result; - } - - foreach ( $records as $record ) { - if ( empty( $record['txt'] ) || ! is_string( $record['txt'] ) ) { - continue; - } - - $value = trim( (string) $record['txt'] ); - - if ( preg_match( '/^v=DMARC1/i', $value ) ) { - $result['record'] = $value; - - if ( preg_match( '/\bp=([a-z]+)/i', $value, $matches ) ) { - $result['policy'] = strtolower( $matches[1] ); - } - - break; - } - } - - if ( '' === $result['record'] ) { - return $result; - } - - if ( 'none' === $result['policy'] ) { - $result['recommendations'][] = __( 'The DMARC policy is set to "p=none". Increase it to "p=quarantine" or "p=reject" to protect the domain.', 'robotstxt-smtp' ); - } elseif ( 'quarantine' === $result['policy'] ) { - $result['recommendations'][] = __( 'Consider moving the DMARC policy to "p=reject" once you have validated that legitimate messages pass authentication.', 'robotstxt-smtp' ); - } - - return $result; - } - - /** - * Performs an MX lookup for the provided domain and compares the results with the SMTP host. - * - * @param string $domain Domain to inspect. - * @param string $smtp_host Normalized SMTP host. - * - * @return array - */ - private function analyze_mx_records( string $domain, string $smtp_host ): array { - $result = array( - 'domain' => $domain, - 'records' => array(), - 'errors' => array(), - 'matches_smtp_host' => false, - ); - - if ( '' === $domain ) { - return $result; - } - - if ( ! function_exists( 'dns_get_record' ) ) { - $result['errors'][] = __( 'MX lookups are not available because the DNS functions are disabled on this server.', 'robotstxt-smtp' ); - - return $result; - } - - $records = dns_get_record( $domain, DNS_MX ); - - if ( false === $records ) { - $result['errors'][] = __( 'The DNS lookup for MX records failed. Please try again later.', 'robotstxt-smtp' ); - - return $result; - } - - foreach ( $records as $record ) { - if ( empty( $record['target'] ) ) { - continue; - } - - $priority = isset( $record['pri'] ) ? (int) $record['pri'] : null; - $display_target = rtrim( (string) $record['target'], '.' ); - $normalized = $this->normalize_hostname( $display_target ); - $resolves = $this->hostname_resolves( $normalized ); - $matches_host = '' !== $smtp_host && $normalized === $smtp_host; - - $result['records'][] = array( - 'priority' => $priority, - 'display_target' => $display_target, - 'normalized_target' => $normalized, - 'resolves' => $resolves, - 'matches_host' => $matches_host, - ); - - if ( $matches_host ) { - $result['matches_smtp_host'] = true; - } - } - - usort( - $result['records'], - static function ( array $a, array $b ): int { - $priority_a = $a['priority'] ?? PHP_INT_MAX; - $priority_b = $b['priority'] ?? PHP_INT_MAX; - - if ( $priority_a === $priority_b ) { - return strcmp( $a['display_target'], $b['display_target'] ); - } - - return $priority_a <=> $priority_b; - } - ); - - return $result; - } - - /** - * Determines whether a hostname resolves to an address record. - * - * @param string $hostname Hostname to inspect. - * - * @return bool|null True when it resolves, false when it does not, null when unknown. - */ - private function hostname_resolves( string $hostname ): ?bool { - if ( '' === $hostname ) { - return null; - } - - $candidates = array( $hostname, $hostname . '.' ); - - if ( function_exists( 'checkdnsrr' ) ) { - foreach ( $candidates as $candidate ) { - if ( checkdnsrr( $candidate, 'A' ) || checkdnsrr( $candidate, 'AAAA' ) ) { - return true; - } - } - } - - if ( function_exists( 'dns_get_record' ) ) { - $types = DNS_A; - - if ( defined( 'DNS_AAAA' ) ) { - $types |= DNS_AAAA; - } - - $had_error = false; - - foreach ( $candidates as $candidate ) { - $records = dns_get_record( $candidate, $types ); - - if ( false === $records ) { - $had_error = true; - continue; - } - - if ( ! empty( $records ) ) { - return true; - } - } - - if ( $had_error ) { - return null; - } - - return false; - } - - return null; - } - - /** - * Provides the default settings. - * - * @return array Default settings. - */ - public static function get_default_settings(): array { - return array( - 'host' => '', - 'username' => '', - 'password' => '', - 'from_email' => '', - 'from_name' => get_bloginfo( 'name', 'display' ), - 'security' => 'none', - 'port' => 25, - 'amazon_ses_access_key' => '', - 'amazon_ses_secret_key' => '', - 'amazon_ses_region' => '', - 'logs_enabled' => false, - 'logs_retention_mode' => 'count', - 'logs_retention_count' => 1024, - 'logs_retention_days' => 28, - ); - } - - /** - * Returns the available security types. - * - * @return array Security type labels keyed by value. - */ - private function get_security_options(): array { - return array( - 'none' => esc_html__( 'None', 'robotstxt-smtp' ), - 'ssl' => esc_html__( 'SSL', 'robotstxt-smtp' ), - 'tls' => esc_html__( 'TLS', 'robotstxt-smtp' ), - ); - } - - /** - * Handles the submission of the test email form. - * - * @return void - */ - public function handle_test_email(): void { - $nonce_value = filter_input( INPUT_POST, 'robotstxt_smtp_test_email_nonce', FILTER_UNSAFE_RAW ); - - // Halt the request when the nonce is missing or invalid to stop forged test submissions. - if ( ! is_string( $nonce_value ) || ! wp_verify_nonce( wp_unslash( $nonce_value ), 'robotstxt_smtp_test_email' ) ) { - wp_die( esc_html__( 'The link you followed has expired.', 'robotstxt-smtp' ) ); - } - - $scope = self::SCOPE_SITE; - - $context_raw = filter_input( INPUT_POST, 'robotstxt_smtp_context', FILTER_UNSAFE_RAW ); - - if ( is_string( $context_raw ) && '' !== $context_raw ) { - // Sanitize the submitted scope before using it to determine capabilities. - $context = sanitize_text_field( wp_unslash( $context_raw ) ); - - if ( self::SCOPE_NETWORK === $context ) { - $scope = self::SCOPE_NETWORK; - } - } - - $this->ensure_capability( $scope ); - $this->set_scope( $scope ); - - $recipient = ''; - - $recipient_raw = filter_input( INPUT_POST, 'robotstxt_smtp_test_email', FILTER_UNSAFE_RAW ); - - if ( is_string( $recipient_raw ) && '' !== $recipient_raw ) { - // Sanitize the recipient email address before attempting to send mail. - $recipient = sanitize_email( wp_unslash( $recipient_raw ) ); - } - - $result = $this->send_test_email_for_scope( $scope, $recipient, 'manual' ); - - $this->persist_test_result( $result ); - $this->redirect_after_test( ! empty( $result['success'] ) ? 'success' : 'error', (string) $result['recipient'], $scope ); - } - - /** - * Handles the updated_option hook for the site-level configuration. - * - * @param string $option Option name that was updated. - * @param mixed $old_value Previous option value. - * @param mixed $value New option value. - * - * @return void - */ - public function handle_settings_option_updated( string $option, $old_value, $value ): void { - unset( $old_value, $value ); - - if ( self::OPTION_NAME !== $option ) { - return; - } - - if ( ! is_admin() ) { - return; - } - - $nonce = filter_input( INPUT_POST, '_wpnonce', FILTER_UNSAFE_RAW ); - - if ( ! is_string( $nonce ) ) { - return; - } - - $nonce = sanitize_text_field( wp_unslash( $nonce ) ); - - if ( ! wp_verify_nonce( $nonce, self::SITE_SETTINGS_GROUP . '-options' ) ) { - return; - } - - $option_page = filter_input( INPUT_POST, 'option_page', FILTER_UNSAFE_RAW ); - - if ( ! is_string( $option_page ) ) { - return; - } - - $option_page = sanitize_key( wp_unslash( $option_page ) ); - - if ( self::SITE_SETTINGS_GROUP !== $option_page ) { - return; - } - - if ( ! current_user_can( self::CAPABILITY ) ) { - return; - } - - $this->cached_settings = null; - $this->site_settings_option_updated = true; - - $result = $this->send_test_email_for_scope( self::SCOPE_SITE, null, 'auto' ); - $this->persist_test_result( $result ); - } - - /** - * Sends the automatic test email when the site settings were submitted but - * the stored option value did not change. - * - * @return void - */ - public function maybe_send_pending_site_test(): void { - if ( ! $this->site_settings_submitted || $this->site_settings_option_updated ) { - return; - } - - if ( ! is_admin() ) { - return; - } - - $this->cached_settings = null; - - $result = $this->send_test_email_for_scope( self::SCOPE_SITE, null, 'auto' ); - $this->persist_test_result( $result ); - - $this->site_settings_submitted = false; - $this->site_settings_option_updated = false; - } - - - /** - * Sends a test email using the stored configuration for the provided scope. - * - * @param string $scope Scope identifier (site or network). - * @param string|null $recipient Optional recipient email address. - * @param string $context Context identifier (manual|auto). - * - * @return array Result data for the attempted email. - */ - private function send_test_email_for_scope( string $scope, ?string $recipient = null, string $context = 'manual' ): array { - $this->ensure_capability( $scope ); - $this->set_scope( $scope ); - - $resolved_recipient = $this->resolve_test_recipient( $recipient ); - - $result = array( - 'success' => false, - 'recipient' => $resolved_recipient, - 'timestamp' => current_time( 'mysql' ), - 'settings' => $this->get_settings_for_display(), - 'debug_log' => array(), - 'mail_data' => array(), - 'error' => '', - 'error_data' => null, - 'context' => $context, - ); - - if ( empty( $resolved_recipient ) ) { - $result['error'] = __( 'A valid recipient email address is required.', 'robotstxt-smtp' ); - - return $result; - } - - $debug_log = array(); - $failure = null; - - $debug_action = static function ( PHPMailer $phpmailer ) use ( &$debug_log ): void { - // phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase - $phpmailer->SMTPDebug = 2; - $phpmailer->Debugoutput = static function ( string $message, int $level ) use ( &$debug_log ): void { - $debug_log[] = '[' . $level . '] ' . $message; - }; - // phpcs:enable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase - }; - - $failure_filter = static function ( WP_Error $error ) use ( &$failure ) { - $failure = $error; - return $error; - }; - - add_action( 'phpmailer_init', $debug_action, 20 ); - add_filter( 'wp_mail_failed', $failure_filter ); - - $subject = __( 'ROBOTSTXT SMTP Test Email', 'robotstxt-smtp' ); - $body = sprintf( - /* translators: %s: Site name. */ - __( 'This is a test email sent from %s using the ROBOTSTXT SMTP settings.', 'robotstxt-smtp' ), - get_bloginfo( 'name', 'display' ) - ); - - $headers = array( 'Content-Type: text/plain; charset=UTF-8' ); - - $sent = wp_mail( $resolved_recipient, $subject, $body, $headers ); - - remove_action( 'phpmailer_init', $debug_action, 20 ); - remove_filter( 'wp_mail_failed', $failure_filter ); - - if ( is_wp_error( $sent ) ) { - $result['success'] = false; - - if ( empty( $result['error'] ) ) { - $result['error'] = $sent->get_error_message(); - } - - if ( null === $result['error_data'] ) { - $result['error_data'] = $sent->get_error_data(); - } - } else { - $result['success'] = (bool) $sent; - } - - $result['debug_log'] = $debug_log; - $result['mail_data'] = array( - 'subject' => $subject, - 'body' => $body, - 'headers' => $headers, - ); - - if ( $failure instanceof WP_Error ) { - $result['error'] = $failure->get_error_message(); - $result['error_data'] = $failure->get_error_data(); - } - - if ( ! $result['success'] && empty( $result['error'] ) ) { - $result['error'] = __( 'The test email could not be sent.', 'robotstxt-smtp' ); - } - - return $result; - } - - /** - * Determines the recipient address to use for a test email. - * - * @param string|null $recipient Recipient provided by the user. - * - * @return string Sanitized recipient email address or an empty string when unavailable. - */ - private function resolve_test_recipient( ?string $recipient ): string { - if ( ! empty( $recipient ) ) { - $recipient = sanitize_email( $recipient ); - - if ( ! empty( $recipient ) ) { - return $recipient; - } - } - - $current_user = wp_get_current_user(); - if ( $current_user instanceof WP_User && ! empty( $current_user->user_email ) ) { - $candidate = sanitize_email( $current_user->user_email ); - if ( ! empty( $candidate ) ) { - return $candidate; - } - } - - return sanitize_email( get_bloginfo( 'admin_email' ) ); - } - - /** - * Displays the admin notice after sending a test email. - * - * @return void - */ - public function display_test_email_notice(): void { - if ( ! is_admin() ) { - return; - } - - $page = filter_input( INPUT_GET, 'page', FILTER_UNSAFE_RAW ); - - if ( null === $page ) { - return; - } - - $page = sanitize_key( $page ); - - if ( '' === $page || ! in_array( $page, array( self::TEST_PAGE_SLUG, self::PAGE_SLUG, self::NETWORK_PAGE_SLUG ), true ) ) { - return; - } - - $result = get_transient( $this->get_test_result_transient_key() ); - - if ( false === $result ) { - return; - } - - delete_transient( $this->get_test_result_transient_key() ); - - $class = ! empty( $result['success'] ) ? 'notice notice-success' : 'notice notice-error'; - - $context = isset( $result['context'] ) ? (string) $result['context'] : 'manual'; - - if ( 'auto' === $context ) { - $status = ! empty( $result['success'] ) - ? __( 'The SMTP configuration appears to be working correctly.', 'robotstxt-smtp' ) - : __( 'The SMTP configuration could not be verified.', 'robotstxt-smtp' ); - } else { - $status = ! empty( $result['success'] ) ? __( 'Test email sent successfully.', 'robotstxt-smtp' ) : __( 'Test email failed to send.', 'robotstxt-smtp' ); - } - ?> -
-

- -

- -

- - -

- -

- - -

- - -
- -
-
- - -
- -
-
- - -
- -
-
- - -
- -
-										
-										
-
- -
- user_email ) ) { - $recipient = $current_user->user_email; - } - } - - if ( empty( $recipient ) ) { - $recipient = sanitize_email( get_bloginfo( 'admin_email' ) ); - } - - ?> -
-

-
- - - - - - - - - - - - -
- - */ - private function get_settings_for_display(): array { - $settings = $this->get_settings(); - - if ( ! empty( $settings['password'] ) ) { - $settings['password'] = str_repeat( '\u2022', 8 ); - } - - return $settings; - } - - /** - * Persists the test result for later display. - * - * @param array $result Result data. - * - * @return void - */ - private function persist_test_result( array $result ): void { - set_transient( $this->get_test_result_transient_key(), $result, MINUTE_IN_SECONDS * 10 ); - } - - /** - * Builds the transient key for the current user. - * - * @return string - */ - private function get_test_result_transient_key(): string { - return 'robotstxt_smtp_test_result_' . get_current_user_id(); - } - - /** - * Redirects the user back to the settings page after sending the test email. - * - * @param string $status The status string (success|error). - * @param string $recipient The recipient email address. - * @param string $scope Scope identifier (site or network). - * - * @return void - */ - private function redirect_after_test( string $status, string $recipient, string $scope ): void { - $redirect = add_query_arg( - array( - 'page' => self::TEST_PAGE_SLUG, - 'robotstxt_smtp_test' => $status, - 'robotstxt_smtp_recipient' => $recipient, - 'robotstxt_smtp_result_nonce' => wp_create_nonce( 'robotstxt_smtp_test_result' ), - ), - $this->get_admin_url_for_scope( $scope, 'admin.php' ) - ); - - wp_safe_redirect( $redirect ); - exit; - } -} +|null + */ + private ?array $cached_settings = null; + + /** + * Tracks whether the site settings form was submitted in the current request. + * + * @var bool + */ + private bool $site_settings_submitted = false; + + /** + * Tracks whether the site settings option was updated in the current request. + * + * @var bool + */ + private bool $site_settings_option_updated = false; + + /** + * Tracks the settings scope used for the current request. + * + * @var string + */ + private string $current_scope = self::SCOPE_SITE; + + /** + * Retrieves the current configuration mode. + * + * @return string + */ + public static function get_configuration_mode(): string { + if ( ! ROBOTSTXT_SMTP_IS_MULTISITE ) { + return self::MODE_SITE; + } + + $mode = get_site_option( self::NETWORK_MODE_OPTION_NAME, self::MODE_NETWORK ); + + return self::MODE_NETWORK === $mode ? self::MODE_NETWORK : self::MODE_SITE; + } + + /** + * Determines whether the plugin operates in network-wide configuration mode. + * + * @return bool + */ + public static function is_network_mode_enabled(): bool { + return self::MODE_NETWORK === self::get_configuration_mode(); + } + + /** + * Updates the internal scope tracker and resets caches when the scope changes. + * + * @param string $scope Scope identifier. + * + * @return void + */ + private function set_scope( string $scope ): void { + $normalized = self::SCOPE_NETWORK === $scope ? self::SCOPE_NETWORK : self::SCOPE_SITE; + + if ( $normalized !== $this->current_scope ) { + $this->current_scope = $normalized; + $this->cached_settings = null; + } + } + + /** + * Retrieves the scope currently in use. + * + * @return string + */ + public function get_scope(): string { + return $this->current_scope; + } + + /** + * Determines the settings option name for a given scope. + * + * @param string|null $scope Optional scope identifier. + * + * @return string + */ + private function get_option_name_for_scope( ?string $scope = null ): string { + $scope = $scope ?? $this->get_scope(); + + return self::SCOPE_NETWORK === $scope ? self::NETWORK_OPTION_NAME : self::OPTION_NAME; + } + + /** + * Builds the input name for a settings field based on the active scope. + * + * @param string $field Field identifier. + * + * @return string + */ + private function get_settings_field_name( string $field ): string { + return $this->get_option_name_for_scope() . '[' . $field . ']'; + } + + /** + * Retrieves the capability required to manage settings for a scope. + * + * @param string $scope Scope identifier. + * + * @return string + */ + private function get_scope_capability( string $scope ): string { + return self::SCOPE_NETWORK === $scope ? self::NETWORK_CAPABILITY : self::CAPABILITY; + } + + /** + * Ensures the current user can manage the provided scope. + * + * @param string $scope Scope identifier. + * + * @return void + */ + private function ensure_capability( string $scope ): void { + if ( ! current_user_can( $this->get_scope_capability( $scope ) ) ) { + wp_die( esc_html__( 'You do not have permission to access this page.', 'robotstxt-smtp' ) ); + } + } + + /** + * Determines the scope associated with the current admin area. + * + * @return string + */ + private function get_current_admin_scope(): string { + return is_network_admin() ? self::SCOPE_NETWORK : self::SCOPE_SITE; + } + + /** + * Retrieves the admin URL for the provided scope. + * + * @param string $scope Scope identifier. + * @param string $path Path appended to the admin URL. + * + * @return string + */ + private function get_admin_url_for_scope( string $scope, string $path ): string { + return self::SCOPE_NETWORK === $scope ? network_admin_url( $path ) : admin_url( $path ); + } + + /** + * Retrieves the admin-post URL for a scope. + * + * @param string $scope Scope identifier. + * + * @return string + */ + private function get_admin_post_url_for_scope( string $scope ): string { + unset( $scope ); + + return admin_url( 'admin-post.php' ); + } + + /** + * Registers WordPress hooks. + * + * @return void + */ + public function register_hooks(): void { + if ( ! ROBOTSTXT_SMTP_IS_MULTISITE || ! self::is_network_mode_enabled() ) { + add_action( 'admin_menu', array( $this, 'register_site_menu' ) ); + } + + if ( ROBOTSTXT_SMTP_IS_MULTISITE ) { + add_action( 'network_admin_menu', array( $this, 'register_network_menu' ) ); + } + + add_action( 'admin_init', array( $this, 'register_settings' ) ); + add_action( 'admin_post_robotstxt_smtp_test_email', array( $this, 'handle_test_email' ) ); + add_action( 'admin_post_robotstxt_smtp_clear_logs', array( $this, 'handle_clear_logs' ) ); + add_action( 'admin_post_robotstxt_smtp_save_network_settings', array( $this, 'handle_save_network_settings' ) ); + add_action( 'admin_notices', array( $this, 'display_test_email_notice' ) ); + add_action( 'network_admin_notices', array( $this, 'display_test_email_notice' ) ); + add_action( 'shutdown', array( $this, 'maybe_send_pending_site_test' ) ); + add_action( 'updated_option', array( $this, 'handle_settings_option_updated' ), 10, 3 ); + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) ); + } + + /** + * Enqueues JavaScript assets for the admin pages. + * + * @param string $hook_suffix Current admin page hook suffix. + * + * @return void + */ + public function enqueue_assets( string $hook_suffix ): void { + if ( false === strpos( $hook_suffix, 'robotstxt-smtp' ) ) { + return; + } + + wp_enqueue_style( + 'robotstxt-smtp-admin-style', + ROBOTSTXT_SMTP_URL . 'assets/css/admin.css', + array(), + ROBOTSTXT_SMTP_VERSION + ); + + wp_enqueue_script( + 'robotstxt-smtp-admin', + ROBOTSTXT_SMTP_URL . 'assets/js/admin.js', + array(), + ROBOTSTXT_SMTP_VERSION, + true + ); + } + + /** + * Registers the admin menu for the single-site plugin pages. + * + * @return void + */ + public function register_site_menu(): void { + add_menu_page( + esc_html__( 'SMTP (by ROBOTSTXT)', 'robotstxt-smtp' ), + esc_html__( 'SMTP', 'robotstxt-smtp' ), + self::CAPABILITY, + self::MENU_SLUG, + array( $this, 'render_site_settings_page' ), + 'dashicons-email-alt2' + ); + + add_submenu_page( + self::MENU_SLUG, + esc_html__( 'SMTP (by ROBOTSTXT)', 'robotstxt-smtp' ), + esc_html__( 'Settings', 'robotstxt-smtp' ), + self::CAPABILITY, + self::MENU_SLUG, + array( $this, 'render_site_settings_page' ) + ); + + add_submenu_page( + self::MENU_SLUG, + esc_html__( 'SMTP Test', 'robotstxt-smtp' ), + esc_html__( 'Test', 'robotstxt-smtp' ), + self::CAPABILITY, + self::TEST_PAGE_SLUG, + array( $this, 'render_test_page' ) + ); + + add_submenu_page( + self::MENU_SLUG, + esc_html__( 'SMTP Tools', 'robotstxt-smtp' ), + esc_html__( 'Tools', 'robotstxt-smtp' ), + self::CAPABILITY, + self::TOOLS_PAGE_SLUG, + array( $this, 'render_tools_page' ) + ); + + add_submenu_page( + self::MENU_SLUG, + esc_html__( 'SMTP Logs', 'robotstxt-smtp' ), + esc_html__( 'Logs', 'robotstxt-smtp' ), + self::CAPABILITY, + self::LOGS_PAGE_SLUG, + array( $this, 'render_logs_page' ) + ); + + add_submenu_page( + self::MENU_SLUG, + esc_html__( 'Email Statistics', 'robotstxt-smtp' ), + esc_html__( 'Statistics', 'robotstxt-smtp' ), + self::CAPABILITY, + self::STATS_PAGE_SLUG, + array( $this, 'render_stats_page' ) + ); + } + + /** + * Registers the admin menu for the network-level pages when multisite is enabled. + * + * @return void + */ + public function register_network_menu(): void { + if ( ! current_user_can( self::NETWORK_CAPABILITY ) ) { + return; + } + + add_menu_page( + esc_html__( 'SMTP (by ROBOTSTXT)', 'robotstxt-smtp' ), + esc_html__( 'SMTP', 'robotstxt-smtp' ), + self::NETWORK_CAPABILITY, + self::NETWORK_MENU_SLUG, + array( $this, 'render_network_settings_page' ), + 'dashicons-email-alt2' + ); + + add_submenu_page( + self::NETWORK_MENU_SLUG, + esc_html__( 'SMTP (by ROBOTSTXT)', 'robotstxt-smtp' ), + esc_html__( 'Settings', 'robotstxt-smtp' ), + self::NETWORK_CAPABILITY, + self::NETWORK_PAGE_SLUG, + array( $this, 'render_network_settings_page' ) + ); + + add_submenu_page( + self::NETWORK_MENU_SLUG, + esc_html__( 'SMTP Test', 'robotstxt-smtp' ), + esc_html__( 'Test', 'robotstxt-smtp' ), + self::NETWORK_CAPABILITY, + self::TEST_PAGE_SLUG, + array( $this, 'render_test_page' ) + ); + + add_submenu_page( + self::NETWORK_MENU_SLUG, + esc_html__( 'SMTP Tools', 'robotstxt-smtp' ), + esc_html__( 'Tools', 'robotstxt-smtp' ), + self::NETWORK_CAPABILITY, + self::TOOLS_PAGE_SLUG, + array( $this, 'render_tools_page' ) + ); + + add_submenu_page( + self::NETWORK_MENU_SLUG, + esc_html__( 'SMTP Logs', 'robotstxt-smtp' ), + esc_html__( 'Logs', 'robotstxt-smtp' ), + self::NETWORK_CAPABILITY, + self::LOGS_PAGE_SLUG, + array( $this, 'render_logs_page' ) + ); + + add_submenu_page( + self::NETWORK_MENU_SLUG, + esc_html__( 'Email Statistics', 'robotstxt-smtp' ), + esc_html__( 'Statistics', 'robotstxt-smtp' ), + self::NETWORK_CAPABILITY, + self::STATS_PAGE_SLUG, + array( $this, 'render_stats_page' ) + ); + } + + /** + * Registers plugin settings, sections, and fields. + * + * @return void + */ + public function register_settings(): void { + // Debug: Log register_settings entry. + + if ( ROBOTSTXT_SMTP_IS_MULTISITE && self::is_network_mode_enabled() && ! is_network_admin() ) { + // Debug: Exiting due to network mode. + return; + } + + if ( is_network_admin() ) { + // Debug: Exiting due to network admin context. + // Network settings are handled manually via the admin-post handler. + return; + } + + // Debug: About to register_setting. + + $this->set_scope( self::SCOPE_SITE ); + + register_setting( + self::SITE_SETTINGS_GROUP, + self::OPTION_NAME, + array( + 'sanitize_callback' => array( $this, 'sanitize_options' ), + ) + ); + + add_settings_section( + 'robotstxt_smtp_connection_section', + esc_html__( 'SMTP Server Configuration', 'robotstxt-smtp' ), + array( $this, 'render_connection_section_description' ), + self::PAGE_SLUG + ); + + $this->register_connection_fields(); + + add_settings_section( + 'robotstxt_smtp_logs_section', + esc_html__( 'Email Log Settings', 'robotstxt-smtp' ), + array( $this, 'render_logs_section_description' ), + self::PAGE_SLUG + ); + + $this->register_logging_fields(); + + add_settings_section( + 'robotstxt_smtp_statistics_section', + esc_html__( 'Statistics Settings', 'robotstxt-smtp' ), + array( $this, 'render_statistics_section_description' ), + self::PAGE_SLUG + ); + + $this->register_statistics_fields(); + + add_settings_section( + 'robotstxt_smtp_rate_limit_section', + esc_html__( 'Rate Limiting', 'robotstxt-smtp' ), + array( $this, 'render_rate_limit_section_description' ), + self::PAGE_SLUG + ); + + $this->register_rate_limiting_fields(); + } + + /** + * Registers fields related to the SMTP connection. + * + * @return void + */ + private function register_connection_fields(): void { + foreach ( $this->get_connection_field_definitions() as $field ) { + $args = array(); + + if ( ! empty( $field['label_for'] ) ) { + $args['label_for'] = $field['label_for']; + } + + add_settings_field( + $field['id'], + $field['label'], + $field['callback'], + self::PAGE_SLUG, + 'robotstxt_smtp_connection_section', + $args + ); + } + } + + /** + * Registers the logging configuration fields. + * + * @return void + */ + private function register_logging_fields(): void { + foreach ( $this->get_logging_field_definitions() as $field ) { + $args = array(); + + if ( ! empty( $field['label_for'] ) ) { + $args['label_for'] = $field['label_for']; + } + + add_settings_field( + $field['id'], + $field['label'], + $field['callback'], + self::PAGE_SLUG, + 'robotstxt_smtp_logs_section', + $args + ); + } + } + + /** + * Registers the rate limiting settings fields. + * + * @since 1.2.1 + * + * @return void + */ + private function register_rate_limiting_fields(): void { + foreach ( $this->get_rate_limiting_field_definitions() as $field ) { + $args = array(); + + if ( ! empty( $field['label_for'] ) ) { + $args['label_for'] = $field['label_for']; + } + + add_settings_field( + $field['id'], + $field['label'], + $field['callback'], + self::PAGE_SLUG, + 'robotstxt_smtp_rate_limit_section', + $args + ); + } + } + + /** + * Registers the statistics configuration fields. + * + * @return void + */ + private function register_statistics_fields(): void { + foreach ( $this->get_statistics_field_definitions() as $field ) { + $args = array(); + + if ( ! empty( $field['label_for'] ) ) { + $args['label_for'] = $field['label_for']; + } + + add_settings_field( + $field['id'], + $field['label'], + $field['callback'], + self::PAGE_SLUG, + 'robotstxt_smtp_statistics_section', + $args + ); + } + } + + /** + * Provides the field definitions for the rate limiting settings. + * + * @since 1.2.1 + * + * @return array> + */ + private function get_rate_limiting_field_definitions(): array { + return array( + array( + 'id' => 'robotstxt_smtp_rate_limit_per_second', + 'label' => esc_html__( 'Emails per second', 'robotstxt-smtp' ), + 'callback' => array( $this, 'render_rate_limit_per_second_field' ), + 'label_for' => 'robotstxt_smtp_rate_limit_per_second', + ), + array( + 'id' => 'robotstxt_smtp_rate_limit_per_hour', + 'label' => esc_html__( 'Emails per hour', 'robotstxt-smtp' ), + 'callback' => array( $this, 'render_rate_limit_per_hour_field' ), + 'label_for' => 'robotstxt_smtp_rate_limit_per_hour', + ), + array( + 'id' => 'robotstxt_smtp_rate_limit_per_day', + 'label' => esc_html__( 'Emails per day (24 hours)', 'robotstxt-smtp' ), + 'callback' => array( $this, 'render_rate_limit_per_day_field' ), + 'label_for' => 'robotstxt_smtp_rate_limit_per_day', + ), + ); + } + + /** + * Renders the description for the rate limiting section. + * + * @since 1.2.1 + * + * @return void + */ + public function render_rate_limit_section_description(): void { + if ( Plugin::is_amazon_ses_integration_active() ) { + ?> +

+ +

+ +

+ '; + } else { + esc_html_e( 'Quotas not yet fetched from Amazon SES.', 'robotstxt-smtp' ); + echo '
'; + } + ?> +

+ get_current_admin_scope(); + $page_slug = self::SCOPE_NETWORK === $current_scope ? self::NETWORK_PAGE_SLUG : self::PAGE_SLUG; + $base_url = $this->get_admin_url_for_scope( $current_scope, 'admin.php' ); + + $refresh_url = wp_nonce_url( + add_query_arg( + array( + 'page' => $page_slug, + 'robotstxt_smtp_action' => 'refresh_quota', + ), + $base_url + ), + 'robotstxt_smtp_refresh_quota', + 'robotstxt_smtp_refresh_quota_nonce' + ); + ?> +

+ + + +

+ +

+ +

+ get_settings(); + $value = $settings['rate_limit_per_second']; + + if ( Plugin::is_amazon_ses_integration_active() ) { + // Read from SES quota transient, NOT from settings. + // Use the AmazonSES plugin method to get the correct cache key (includes blog_id in MultiSite). + $quota_key = class_exists( '\Robotstxt_SMTP_AmazonSES\Plugin' ) ? \Robotstxt_SMTP_AmazonSES\Plugin::get_quota_cache_key() : 'robotstxt_smtp_amazonses_quota'; + $quota = get_site_transient( $quota_key ); + if ( $quota && is_array( $quota ) && isset( $quota['max_send_rate'] ) ) { + $ses_value = (int) floor( (float) $quota['max_send_rate'] ); + ?> + +

+ +

+ + +

+ +

+ + +

+ +

+ get_settings(); + $value = $settings['rate_limit_per_hour']; + + if ( Plugin::is_amazon_ses_integration_active() ) { + // Read from SES quota transient, NOT from settings. + // Use the AmazonSES plugin method to get the correct cache key (includes blog_id in MultiSite). + $quota_key = class_exists( '\Robotstxt_SMTP_AmazonSES\Plugin' ) ? \Robotstxt_SMTP_AmazonSES\Plugin::get_quota_cache_key() : 'robotstxt_smtp_amazonses_quota'; + $quota = get_site_transient( $quota_key ); + if ( $quota && is_array( $quota ) && isset( $quota['max_send_rate'] ) ) { + $max_send_rate = (float) $quota['max_send_rate']; + $ses_value = (int) floor( $max_send_rate * 3600 * 0.9 ); + ?> + +

+ +

+ + +

+ +

+ + +

+ +

+ get_settings(); + $value = $settings['rate_limit_per_day']; + + if ( Plugin::is_amazon_ses_integration_active() ) { + // Read from SES quota transient, NOT from settings. + // Use the AmazonSES plugin method to get the correct cache key (includes blog_id in MultiSite). + $quota_key = class_exists( '\Robotstxt_SMTP_AmazonSES\Plugin' ) ? \Robotstxt_SMTP_AmazonSES\Plugin::get_quota_cache_key() : 'robotstxt_smtp_amazonses_quota'; + $quota = get_site_transient( $quota_key ); + if ( $quota && is_array( $quota ) && isset( $quota['max_24_hour_send'] ) ) { + $ses_value = (int) $quota['max_24_hour_send']; + ?> + +

+ +

+ + +

+ +

+ + +

+ +

+ > + */ + private function get_connection_field_definitions(): array { + if ( Plugin::is_amazon_ses_integration_active() ) { + $fields = array(); + } else { + $fields = array( + array( + 'id' => 'robotstxt_smtp_host', + 'label' => esc_html__( 'Host', 'robotstxt-smtp' ), + 'callback' => array( $this, 'render_host_field' ), + 'label_for' => 'robotstxt_smtp_host', + ), + array( + 'id' => 'robotstxt_smtp_username', + 'label' => esc_html__( 'Username', 'robotstxt-smtp' ), + 'callback' => array( $this, 'render_username_field' ), + 'label_for' => 'robotstxt_smtp_username', + ), + array( + 'id' => 'robotstxt_smtp_password', + 'label' => esc_html__( 'Password', 'robotstxt-smtp' ), + 'callback' => array( $this, 'render_password_field' ), + 'label_for' => 'robotstxt_smtp_password', + ), + array( + 'id' => 'robotstxt_smtp_from_email', + 'label' => esc_html__( 'From Email', 'robotstxt-smtp' ), + 'callback' => array( $this, 'render_from_email_field' ), + 'label_for' => 'robotstxt_smtp_from_email', + ), + array( + 'id' => 'robotstxt_smtp_from_name', + 'label' => esc_html__( 'From Name', 'robotstxt-smtp' ), + 'callback' => array( $this, 'render_from_name_field' ), + 'label_for' => 'robotstxt_smtp_from_name', + ), + array( + 'id' => 'robotstxt_smtp_reply_to_email', + 'label' => esc_html__( 'Reply-To Email', 'robotstxt-smtp' ), + 'callback' => array( $this, 'render_reply_to_email_field' ), + 'label_for' => 'robotstxt_smtp_reply_to_email', + ), + array( + 'id' => 'robotstxt_smtp_reply_to_name', + 'label' => esc_html__( 'Reply-To Name', 'robotstxt-smtp' ), + 'callback' => array( $this, 'render_reply_to_name_field' ), + 'label_for' => 'robotstxt_smtp_reply_to_name', + ), + array( + 'id' => 'robotstxt_smtp_security', + 'label' => esc_html__( 'Security Type', 'robotstxt-smtp' ), + 'callback' => array( $this, 'render_security_field' ), + 'label_for' => 'robotstxt_smtp_security', + ), + array( + 'id' => 'robotstxt_smtp_port', + 'label' => esc_html__( 'Port', 'robotstxt-smtp' ), + 'callback' => array( $this, 'render_port_field' ), + 'label_for' => 'robotstxt_smtp_port', + ), + ); + } + + /** + * Filters the SMTP connection field definitions. + * + * @since 1.0.1 + * + * @param array> $fields Field definitions. + * @param Settings_Page $settings_page Settings page instance. + */ + return (array) \apply_filters( 'robotstxt_smtp_connection_field_definitions', $fields, $this ); + } + + + /** + * Provides the field definitions for the logging settings. + * + * @return array> + */ + private function get_logging_field_definitions(): array { + return array( + array( + 'id' => 'robotstxt_smtp_logs_enabled', + 'label' => esc_html__( 'Enable logging', 'robotstxt-smtp' ), + 'callback' => array( $this, 'render_logs_enabled_field' ), + 'label_for' => 'robotstxt_smtp_logs_enabled', + ), + array( + 'id' => 'robotstxt_smtp_logs_retention_mode', + 'label' => esc_html__( 'Retention mode', 'robotstxt-smtp' ), + 'callback' => array( $this, 'render_logs_retention_mode_field' ), + ), + array( + 'id' => 'robotstxt_smtp_logs_retention_count', + 'label' => esc_html__( 'Maximum stored emails', 'robotstxt-smtp' ), + 'callback' => array( $this, 'render_logs_retention_count_field' ), + 'label_for' => 'robotstxt_smtp_logs_retention_count', + ), + array( + 'id' => 'robotstxt_smtp_logs_retention_days', + 'label' => esc_html__( 'Retention in days', 'robotstxt-smtp' ), + 'callback' => array( $this, 'render_logs_retention_days_field' ), + 'label_for' => 'robotstxt_smtp_logs_retention_days', + ), + ); + } + + /** + * Provides the field definitions for the statistics settings. + * + * @return array> + */ + private function get_statistics_field_definitions(): array { + return array( + array( + 'id' => 'robotstxt_smtp_stats_retention_days', + 'label' => esc_html__( 'Retention in days', 'robotstxt-smtp' ), + 'callback' => array( $this, 'render_stats_retention_days_field' ), + 'label_for' => 'robotstxt_smtp_stats_retention_days', + ), + ); + } + + /** + * Outputs the provided fields in a table layout. + * + * @param array> $fields Field definitions. + * + * @return void + */ + private function render_field_rows( array $fields ): void { + foreach ( $fields as $field ) { + $label_for = isset( $field['label_for'] ) ? (string) $field['label_for'] : ''; + ?> + + + + + + + + + + + + + +
+

+
+ ' . esc_html__( 'Configure the SMTP server used to deliver outgoing emails.', 'robotstxt-smtp' ) . '

'; + } + + /** + * Outputs the logs section description. + * + * @return void + */ + public function render_logs_section_description(): void { + echo '

' . esc_html__( 'Control how email delivery logs are stored and pruned.', 'robotstxt-smtp' ) . '

'; + } + + /** + * Outputs the statistics section description. + * + * @return void + */ + public function render_statistics_section_description(): void { + echo '

' . esc_html__( 'Configure how long email statistics are retained in the database.', 'robotstxt-smtp' ) . '

'; + } + + /** + * Renders the settings page. + * + * @return void + */ + public function render_site_settings_page(): void { + $this->ensure_capability( self::SCOPE_SITE ); + $this->set_scope( self::SCOPE_SITE ); + + ?> +
+

+
+ +
+
+ ensure_capability( self::SCOPE_NETWORK ); + $this->set_scope( self::SCOPE_NETWORK ); + + $mode = self::get_configuration_mode(); + + ?> +
+

+ + + +
+

+
+ + +
+ + + + +

+

+ + + + + + + + + +

+ +
+

+
+ + +
+

+
+ + + + + render_field_rows( $this->get_connection_field_definitions() ); ?> + + + +

+ + + render_field_rows( $this->get_logging_field_definitions() ); ?> + + + +

+ render_rate_limit_section_description(); ?> + + + render_field_rows( $this->get_rate_limiting_field_definitions() ); ?> + + + + +
+
+ ensure_capability( $scope ); + + $nonce_value = filter_input( INPUT_POST, '_wpnonce', FILTER_UNSAFE_RAW ); + + // Abort when the security nonce is missing or invalid to block forged submissions. + if ( ! is_string( $nonce_value ) || ! wp_verify_nonce( wp_unslash( $nonce_value ), 'robotstxt_smtp_save_network_settings' ) ) { + wp_die( esc_html__( 'The link you followed has expired.', 'robotstxt-smtp' ) ); + } + + $mode = self::MODE_SITE; + + $submitted_mode = filter_input( INPUT_POST, 'robotstxt_smtp_mode', FILTER_UNSAFE_RAW ); + + if ( is_string( $submitted_mode ) ) { + $submitted_mode = sanitize_key( wp_unslash( $submitted_mode ) ); + + if ( self::MODE_NETWORK === $submitted_mode ) { + $mode = self::MODE_NETWORK; + } + } + + update_site_option( self::NETWORK_MODE_OPTION_NAME, $mode ); + + $options = array(); + + $raw_options = filter_input( INPUT_POST, self::NETWORK_OPTION_NAME, FILTER_UNSAFE_RAW, FILTER_REQUIRE_ARRAY ); + + if ( is_array( $raw_options ) ) { + $options = map_deep( wp_unslash( $raw_options ), 'sanitize_text_field' ); + } + + $this->set_scope( self::SCOPE_NETWORK ); + $clean_options = $this->sanitize_options( $options ); + update_site_option( self::NETWORK_OPTION_NAME, $clean_options ); + + $result = $this->send_test_email_for_scope( self::SCOPE_NETWORK, null, 'auto' ); + $this->persist_test_result( $result ); + + $redirect = add_query_arg( + array( + 'page' => self::NETWORK_PAGE_SLUG, + 'robotstxt_smtp_saved' => 1, + 'robotstxt_smtp_test' => ! empty( $result['success'] ) ? 'success' : 'error', + ), + $this->get_admin_url_for_scope( $scope, 'admin.php' ) + ); + + $redirect = add_query_arg( + '_wpnonce', + wp_create_nonce( 'robotstxt_smtp_saved_notice' ), + $redirect + ); + + wp_safe_redirect( $redirect ); + exit; + } + + /** + * Renders the test page. + * + * @return void + */ + public function render_test_page(): void { + $scope = $this->get_current_admin_scope(); + + $this->ensure_capability( $scope ); + $this->set_scope( $scope ); + + ?> +
+

+

' . esc_html__( 'The network configuration is currently disabled. Tests will use the site-specific settings stored below.', 'robotstxt-smtp' ) . '

'; + } + + $this->render_test_email_form( $scope ); + ?> + + get_current_admin_scope(); + + $this->ensure_capability( $scope ); + $this->set_scope( $scope ); + + $requested_tool = ''; + $robotstxt_smtp_tool_raw = filter_input( INPUT_GET, 'robotstxt_smtp_tool', FILTER_UNSAFE_RAW ); + if ( null !== $robotstxt_smtp_tool_raw ) { + $requested_tool = sanitize_key( wp_unslash( (string) $robotstxt_smtp_tool_raw ) ); + } + + $force_refresh = false; + $robotstxt_smtp_refresh_raw = filter_input( INPUT_GET, 'robotstxt_smtp_refresh', FILTER_UNSAFE_RAW ); + if ( null !== $robotstxt_smtp_refresh_raw && '' !== $requested_tool ) { + $wpnonce_raw = filter_input( INPUT_GET, '_wpnonce', FILTER_UNSAFE_RAW ); + $nonce = $wpnonce_raw ? sanitize_text_field( wp_unslash( (string) $wpnonce_raw ) ) : ''; + + if ( wp_verify_nonce( $nonce, 'robotstxt_smtp_refresh_tool_' . $requested_tool ) ) { + $force_refresh = true; + } + } + + $tools = array( + 'mx' => array( + 'title' => esc_html__( 'Automatic MX Lookup', 'robotstxt-smtp' ), + 'description' => esc_html__( 'Detects the domain from the configured sender address, retrieves its MX records, and compares them with the SMTP host.', 'robotstxt-smtp' ), + 'callback' => array( $this, 'get_tools_mx_section_html' ), + ), + 'authentication' => array( + 'title' => esc_html__( 'SPF, DKIM, and DMARC Validation', 'robotstxt-smtp' ), + 'description' => esc_html__( 'Checks common DNS TXT records for the sender domain to help you verify email authentication.', 'robotstxt-smtp' ), + 'callback' => array( $this, 'get_tools_authentication_section_html' ), + ), + 'diagnostics' => array( + 'title' => esc_html__( 'Extended SMTP Diagnostics', 'robotstxt-smtp' ), + 'description' => esc_html__( 'Reuses the configured SMTP connection to inspect the server greeting, TLS support, available authentication mechanisms, and EHLO/HELO response codes.', 'robotstxt-smtp' ), + 'callback' => array( $this, 'get_tools_smtp_diagnostics_section_html' ), + ), + 'blacklist' => array( + 'title' => esc_html__( 'Blacklist Lookup', 'robotstxt-smtp' ), + 'description' => esc_html__( 'Checks the SMTP host IP address against well-known DNS-based reputation lists. Use the feature responsibly and respect each provider’s terms of use.', 'robotstxt-smtp' ), + 'callback' => array( $this, 'get_tools_blacklist_section_html' ), + ), + ); + + $base_url = $this->get_admin_url_for_scope( $scope, 'admin.php' ); + + ?> +
+

+ + +
+

+
+ + +
+ $tool_definition ) : ?> + get_tool_result_for_display( $scope, $tool_key, $tool_definition['callback'], $run_now ); + $has_result = null !== $result; + + $refresh_url = add_query_arg( + array( + 'page' => self::TOOLS_PAGE_SLUG, + 'robotstxt_smtp_tool' => $tool_key, + 'robotstxt_smtp_refresh' => '1', + ), + $base_url + ); + $refresh_url = wp_nonce_url( $refresh_url, 'robotstxt_smtp_refresh_tool_' . $tool_key ); + ?> +
+

+

+ + + format_tool_timestamp( isset( $result['timestamp'] ) ? (int) $result['timestamp'] : 0 ); + ?> + +

+ +

+ + +

+ + + +

+ +
+ +
+ +

+ +

+ +

+ + + +

+ +
+ +
+
+ |null + */ + private function get_tool_result_for_display( string $scope, string $tool, callable $callback, bool $refresh ): ?array { + $cached = $this->get_cached_tool_result( $scope, $tool ); + + if ( $refresh ) { + $html = (string) call_user_func( $callback, $scope ); + $data = array( + 'html' => $html, + 'timestamp' => time(), + ); + + $this->set_tool_result_cache( $scope, $tool, $data ); + + return $data; + } + + return $cached; + } + + /** + /** + * Stores data in transient cache with HMAC signature for integrity verification. + * + * Prevents cache poisoning by signing data with WordPress AUTH_SALT. + * If AUTH_SALT is not defined, falls back to standard caching without signature. + * + * @since 1.2.1 + * + * @param string $key Transient key. + * @param mixed $data Data to cache. + * @param int $expiration Cache lifetime in seconds. + * @param bool $network Whether to use site transient (multisite-aware). + * @return bool True on success, false on failure. + */ + private function cache_set_with_signature( string $key, $data, int $expiration, bool $network = false ): bool { + if ( ! defined( 'AUTH_SALT' ) || '' === AUTH_SALT ) { + // Fallback to standard caching if AUTH_SALT is not available. + return $network ? set_site_transient( $key, $data, $expiration ) : set_transient( $key, $data, $expiration ); + } + + $payload = array( + 'data' => $data, + 'timestamp' => time(), + 'signature' => hash_hmac( 'sha256', $key . serialize( $data ), AUTH_SALT ), + ); + + return $network ? set_site_transient( $key, $payload, $expiration ) : set_transient( $key, $payload, $expiration ); + } + + /** + * Retrieves data from transient cache and verifies HMAC signature. + * + * Returns false if signature validation fails or data has been tampered with. + * + * @since 1.2.1 + * + * @param string $key Transient key. + * @param bool $network Whether to use site transient (multisite-aware). + * @return mixed|false Cached data on success, false on failure or invalid signature. + */ + private function cache_get_with_signature( string $key, bool $network = false ) { + $cached = $network ? get_site_transient( $key ) : get_transient( $key ); + + if ( false === $cached ) { + return false; + } + + // If AUTH_SALT is not defined or cache doesn't have signature structure, return as-is for compatibility. + if ( ! defined( 'AUTH_SALT' ) || '' === AUTH_SALT || ! is_array( $cached ) || ! isset( $cached['signature'] ) ) { + return $cached; + } + + // Verify signature structure. + if ( ! isset( $cached['data'], $cached['timestamp'] ) ) { + // Invalid cache structure, delete and return false. + $network ? delete_site_transient( $key ) : delete_transient( $key ); + return false; + } + + // Verify HMAC signature. + $expected_signature = hash_hmac( 'sha256', $key . serialize( $cached['data'] ), AUTH_SALT ); + + if ( ! hash_equals( $expected_signature, $cached['signature'] ) ) { + // Signature mismatch, cache has been tampered with. + $network ? delete_site_transient( $key ) : delete_transient( $key ); + return false; + } + + return $cached['data']; + } + + /** + * Retrieves the cached results for a tool. + * + * @param string $scope Scope identifier. + * @param string $tool Tool identifier. + * + * @return array|null + */ + private function get_cached_tool_result( string $scope, string $tool ): ?array { + $key = $this->get_tool_transient_key( $scope, $tool ); + $value = $this->cache_get_with_signature( $key, self::SCOPE_NETWORK === $scope ); + + if ( false === $value ) { + return null; + } + + if ( ! is_array( $value ) || ! isset( $value['html'], $value['timestamp'] ) ) { + $this->delete_tool_result_cache( $scope, $tool ); + return null; + } + + return array( + 'html' => (string) $value['html'], + 'timestamp' => (int) $value['timestamp'], + ); + } + + /** + * Stores the cached results for a tool. + * + * @param string $scope Scope identifier. + * @param string $tool Tool identifier. + * @param array $data Cached data. + * + * @return void + */ + private function set_tool_result_cache( string $scope, string $tool, array $data ): void { + $payload = array( + 'html' => isset( $data['html'] ) ? (string) $data['html'] : '', + 'timestamp' => isset( $data['timestamp'] ) ? (int) $data['timestamp'] : time(), + ); + + $key = $this->get_tool_transient_key( $scope, $tool ); + + $this->cache_set_with_signature( $key, $payload, self::TOOLS_CACHE_LIFETIME, self::SCOPE_NETWORK === $scope ); + } + + /** + * Removes the cached results for a tool. + * + * @param string $scope Scope identifier. + * @param string $tool Tool identifier. + * + * @return void + */ + private function delete_tool_result_cache( string $scope, string $tool ): void { + $key = $this->get_tool_transient_key( $scope, $tool ); + + if ( self::SCOPE_NETWORK === $scope ) { + delete_site_transient( $key ); + return; + } + + delete_transient( $key ); + } + + /** + * Builds the transient key for a tool and scope combination. + * + * @param string $scope Scope identifier. + * @param string $tool Tool identifier. + * + * @return string + */ + private function get_tool_transient_key( string $scope, string $tool ): string { + return self::TOOLS_TRANSIENT_PREFIX . $scope . '_' . $tool; + } + + /** + * Formats the last checked timestamp for display. + * + * @param int $timestamp Unix timestamp. + * + * @return string + */ + private function format_tool_timestamp( int $timestamp ): string { + $timestamp = max( 0, $timestamp ); + + if ( 0 === $timestamp ) { + return ''; + } + + $date_format = (string) get_option( 'date_format', 'F j, Y' ); + $time_format = (string) get_option( 'time_format', 'g:i a' ); + $format = trim( $date_format . ' ' . $time_format ); + + if ( '' === $format ) { + $format = 'F j, Y g:i a'; + } + + return date_i18n( $format, $timestamp ); + } + + /** + * Generates the markup for the MX lookup tool. + * + * @param string $scope Scope identifier. + * @return string + */ + private function get_tools_mx_section_html( string $scope ): string { + $this->set_scope( $scope ); + + $settings = $this->get_settings(); + $smtp_host = isset( $settings['host'] ) ? (string) $settings['host'] : ''; + $from_email = isset( $settings['from_email'] ) ? (string) $settings['from_email'] : ''; + $sender_domain = $this->extract_domain_from_email( $from_email ); + $normalized_smtp_host = $this->normalize_hostname( $smtp_host ); + $mx_analysis = array( + 'domain' => $sender_domain, + 'records' => array(), + 'errors' => array(), + 'matches_smtp_host' => false, + ); + + if ( '' !== $sender_domain ) { + $mx_analysis = $this->analyze_mx_records( $sender_domain, $normalized_smtp_host ); + } + + ob_start(); + + if ( '' === $sender_domain ) : + ?> +
+

+
+ +

+ + +
+ + +

+ +
+

+
    + +
  • + +
+
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + + + +
+ + + +
+ +
+

+
    + +
  • + +
+
+ + + + +
+

+ +

+
+ +
+

+ +

+
+ + +
+

+
+ + + set_scope( $scope ); + + $settings = $this->get_settings(); + $smtp_host = isset( $settings['host'] ) ? (string) $settings['host'] : ''; + $smtp_port = isset( $settings['port'] ) ? (int) $settings['port'] : 0; + $security = isset( $settings['security'] ) ? (string) $settings['security'] : 'none'; + $normalized_host = $this->normalize_hostname( $smtp_host ); + $security_options = $this->get_security_options(); + $security_label = isset( $security_options[ $security ] ) ? $security_options[ $security ] : $security; + + ob_start(); + + if ( '' === $normalized_host ) : + ?> +
+

+
+ run_smtp_diagnostics( $settings ); + + if ( ! empty( $diagnostics['errors'] ) ) : + ?> +
+
    + +
  • + +
+
+ +
+
    + +
  • + +
+
+ +

+ + +
+ + +

+ + +

+ + + + + ( + + ) + + +

+ + +

+

+ +

+ + +

+ + + + +

+ +
    + +
  • + +
+ + + +

+ +
    + +
  • + +
+ +

+ + +

+ +

+ + +

+ + +
    + +
  • + +
+ + + +

+ +

+ + +

+ +
    + +
  • + +
+ + + +

+ +

+ + +

+ + +
    + +
  • + +
+ + + + +
+ +
+
+ + + $settings SMTP settings. + * + * @return array + */ + private function run_smtp_diagnostics( array $settings ): array { + $defaults = array( + 'host' => '', + 'port' => 25, + 'security' => 'none', + ); + + $settings = wp_parse_args( $settings, $defaults ); + + $host = $this->normalize_hostname( (string) $settings['host'] ); + $port = (int) $settings['port']; + $security = in_array( (string) $settings['security'], array( 'none', 'ssl', 'tls' ), true ) ? (string) $settings['security'] : 'none'; + + if ( $port <= 0 || $port > 65535 ) { + $port = 25; + } + + $result = array( + 'success' => false, + 'host' => $host, + 'port' => $port, + 'security' => $security, + 'errors' => array(), + 'warnings' => array(), + 'banner' => '', + 'banner_code' => '', + 'ehlo' => array( + 'code' => '', + 'lines' => array(), + 'timed_out' => false, + ), + 'ehlo_post_tls' => null, + 'helo' => array( + 'attempted' => false, + 'code' => '', + 'lines' => array(), + 'timed_out' => false, + ), + 'tls' => array( + 'mode' => $security, + 'offered' => null, + 'upgrade_attempted' => false, + 'upgrade_response' => array( + 'code' => '', + 'lines' => array(), + 'timed_out' => false, + ), + 'negotiated' => ( 'ssl' === $security ), + ), + 'auth_mechanisms' => array(), + 'transcript' => array(), + ); + + if ( '' === $host ) { + $result['errors'][] = __( 'A valid SMTP host is required to run diagnostics.', 'robotstxt-smtp' ); + + return $result; + } + + $client = $this->create_smtp_client(); + $timeout = 15; + $transport = 'ssl' === $security ? 'ssl://' . $host : $host; + + $client->setDebugOutput( + static function ( $message, $level ) use ( &$result ) { + unset( $level ); + + if ( ! is_string( $message ) ) { + return; + } + + $message = trim( $message ); + + if ( '' === $message ) { + return; + } + + if ( str_starts_with( $message, 'CLIENT -> SERVER:' ) ) { + $result['transcript'][] = 'C: ' . trim( substr( $message, strlen( 'CLIENT -> SERVER:' ) ) ); + + return; + } + + if ( str_starts_with( $message, 'SERVER -> CLIENT:' ) ) { + $result['transcript'][] = 'S: ' . trim( substr( $message, strlen( 'SERVER -> CLIENT:' ) ) ); + } + } + ); + + // phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase + $client->do_debug = SMTP::DEBUG_SERVER; + $client->Timeout = $timeout; + $client->Timelimit = $timeout; + // phpcs:enable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase + + $connected = $client->connect( $transport, $port, $timeout ); + + if ( ! $connected ) { + $error = $client->getError(); + $error_code = isset( $error['smtp_code'] ) && is_numeric( $error['smtp_code'] ) ? (int) $error['smtp_code'] : 0; + $message = ''; + + foreach ( array( 'smtp_code_ex', 'detail', 'error' ) as $key ) { + if ( ! empty( $error[ $key ] ) ) { + $message = (string) $error[ $key ]; + break; + } + } + + if ( '' === $message ) { + $message = __( 'Unknown error', 'robotstxt-smtp' ); + } + + $result['errors'][] = sprintf( + /* translators: 1: Error message. 2: Error code. */ + __( 'Connection failed: %1$s (%2$d).', 'robotstxt-smtp' ), + $message, + $error_code + ); + + $client->close(); + + return $result; + } + + $banner = $this->parse_smtp_reply( $client->getLastReply() ); + if ( '' !== $banner['code'] ) { + $result['banner_code'] = $banner['code']; + } + + if ( ! empty( $banner['lines'] ) ) { + $first_line = preg_replace( '/^\d{3}[ \-]/', '', (string) $banner['lines'][0] ); + $result['banner'] = is_string( $first_line ) ? trim( $first_line ) : ''; + } + + if ( '' !== $result['banner_code'] && '220' !== $result['banner_code'] ) { + $result['warnings'][] = __( 'The server greeting returned an unexpected status code.', 'robotstxt-smtp' ); + } + + $ehlo_domain = $this->get_ehlo_hostname(); + + $ehlo_command = $client->execute_command( 'EHLO', 'EHLO ' . $ehlo_domain ); + $ehlo_response = $this->parse_smtp_reply( $ehlo_command['reply'], $ehlo_command['timed_out'] ); + $result['ehlo'] = $ehlo_response; + + $capabilities = $this->parse_ehlo_capabilities( $ehlo_response['lines'] ); + $result['auth_mechanisms'] = $capabilities['auth_mechanisms']; + $result['tls']['offered'] = $capabilities['has_starttls']; + + if ( '' === $ehlo_response['code'] ) { + $result['warnings'][] = __( 'The EHLO response could not be parsed.', 'robotstxt-smtp' ); + } elseif ( '250' !== $ehlo_response['code'] ) { + $result['warnings'][] = __( 'The server did not accept the EHLO command.', 'robotstxt-smtp' ); + } + + if ( 'tls' === $security ) { + if ( empty( $capabilities['has_starttls'] ) ) { + $result['warnings'][] = __( 'The server did not advertise STARTTLS support.', 'robotstxt-smtp' ); + } else { + $result['tls']['upgrade_attempted'] = true; + $tls_negotiated = $client->startTLS(); + $starttls_reply = $this->parse_smtp_reply( $client->getLastReply(), $client->did_last_command_timeout() ); + $result['tls']['upgrade_response'] = $starttls_reply; + + if ( $tls_negotiated ) { + $result['tls']['negotiated'] = true; + + $post_tls_command = $client->execute_command( 'EHLO', 'EHLO ' . $ehlo_domain ); + $post_tls_response = $this->parse_smtp_reply( $post_tls_command['reply'], $post_tls_command['timed_out'] ); + $result['ehlo_post_tls'] = $post_tls_response; + $post_tls_capabilities = $this->parse_ehlo_capabilities( $post_tls_response['lines'] ); + + if ( ! empty( $post_tls_capabilities['auth_mechanisms'] ) ) { + $result['auth_mechanisms'] = $post_tls_capabilities['auth_mechanisms']; + } + } else { + $result['warnings'][] = __( 'The TLS negotiation failed after STARTTLS.', 'robotstxt-smtp' ); + } + } + } + + if ( 'none' === $security && ! empty( $capabilities['has_starttls'] ) ) { + $result['warnings'][] = __( 'The server supports STARTTLS. Enable TLS in the configuration to protect the connection.', 'robotstxt-smtp' ); + } + + if ( empty( $result['auth_mechanisms'] ) ) { + $result['warnings'][] = __( 'No authentication mechanisms were advertised by the server.', 'robotstxt-smtp' ); + } + + if ( '250' !== $ehlo_response['code'] ) { + $result['helo']['attempted'] = true; + $helo_command = $client->execute_command( 'HELO', 'HELO ' . $ehlo_domain ); + $helo_response = $this->parse_smtp_reply( $helo_command['reply'], $helo_command['timed_out'] ); + $result['helo']['code'] = $helo_response['code']; + $result['helo']['lines'] = $helo_response['lines']; + + if ( '' === $helo_response['code'] || '250' !== $helo_response['code'] ) { + $result['warnings'][] = __( 'The legacy HELO command did not return a successful status code.', 'robotstxt-smtp' ); + } + } + + $client->execute_command( 'QUIT', 'QUIT', array( 221 ) ); + $client->close(); + + if ( ! $result['tls']['negotiated'] ) { + $result['warnings'][] = __( 'The connection is not encrypted. Credentials may travel in plain text.', 'robotstxt-smtp' ); + } + + $result['auth_mechanisms'] = array_values( array_unique( array_map( 'strtoupper', $result['auth_mechanisms'] ) ) ); + $result['warnings'] = array_values( array_unique( $result['warnings'] ) ); + $result['errors'] = array_values( array_unique( $result['errors'] ) ); + $result['success'] = empty( $result['errors'] ); + + + return $result; + } + + /** + * Determines the hostname used when sending EHLO/HELO commands. + * + * @return string + */ + private function get_ehlo_hostname(): string { + $home = home_url( '/' ); + + if ( is_string( $home ) ) { + $parsed = wp_parse_url( $home ); + + if ( is_array( $parsed ) && isset( $parsed['host'] ) && '' !== $parsed['host'] ) { + return strtolower( rtrim( (string) $parsed['host'], '.' ) ); + } + } + + if ( function_exists( 'gethostname' ) ) { + $hostname = gethostname(); + + if ( is_string( $hostname ) && '' !== $hostname ) { + return strtolower( rtrim( $hostname, '.' ) ); + } + } + + return 'localhost'; + } + + /** + * Parses a raw SMTP reply string. + * + * @param string $reply Raw reply returned by the server. + * @param bool $timed_out Whether the request timed out. + * + * @return array + */ + private function parse_smtp_reply( string $reply, bool $timed_out = false ): array { + $lines = array(); + $code = ''; + + if ( '' !== $reply ) { + $normalized = str_replace( array( "\r\n", "\r" ), "\n", $reply ); + $parts = array_filter( array_map( 'trim', explode( "\n", trim( $normalized ) ) ), 'strlen' ); + + foreach ( $parts as $line ) { + $lines[] = $line; + + if ( '' === $code && preg_match( '/^(\d{3})/', $line, $matches ) ) { + $code = $matches[1]; + } + } + } + + return array( + 'code' => $code, + 'lines' => $lines, + 'timed_out' => $timed_out, + ); + } + + /** + * Creates an SMTP diagnostics client instance. + * + * @return SMTP_Diagnostics_Client + */ + private function create_smtp_client(): SMTP_Diagnostics_Client { + if ( ! class_exists( SMTP::class ) ) { + require_once ABSPATH . WPINC . '/PHPMailer/SMTP.php'; + } + + return new SMTP_Diagnostics_Client(); + } + + /** + * Parses the EHLO response to extract advertised capabilities. + * + * @param array $lines Response lines. + * + * @return array + */ + private function parse_ehlo_capabilities( array $lines ): array { + $result = array( + 'raw' => array(), + 'has_starttls' => false, + 'auth_mechanisms' => array(), + ); + + foreach ( $lines as $line ) { + $text = (string) $line; + + if ( preg_match( '/^\d{3}[ \-](.*)$/', $text, $matches ) ) { + $text = trim( (string) $matches[1] ); + } else { + $text = trim( $text ); + } + + if ( '' === $text ) { + continue; + } + + $result['raw'][] = $text; + + $upper = strtoupper( $text ); + + if ( 0 === strpos( $upper, 'STARTTLS' ) ) { + $result['has_starttls'] = true; + } + + if ( 0 === strpos( $upper, 'AUTH' ) ) { + $after_auth = trim( substr( $text, 4 ) ); + $after_auth = ltrim( $after_auth, '= ' ); + + if ( '' !== $after_auth ) { + $mechanisms = preg_split( '/\s+/', $after_auth ); + + if ( is_array( $mechanisms ) ) { + foreach ( $mechanisms as $mechanism ) { + $mechanism = strtoupper( trim( (string) $mechanism ) ); + + if ( '' !== $mechanism ) { + $result['auth_mechanisms'][] = $mechanism; + } + } + } + } + } + } + + $result['auth_mechanisms'] = array_values( array_unique( $result['auth_mechanisms'] ) ); + + + return $result; + } + + /** + * Generates the markup for the SPF, DKIM, and DMARC checks. + * + * @param string $scope Scope identifier. + * @return string + */ + private function get_tools_authentication_section_html( string $scope ): string { + $this->set_scope( $scope ); + + $settings = $this->get_settings(); + $smtp_host = isset( $settings['host'] ) ? (string) $settings['host'] : ''; + $from_email = isset( $settings['from_email'] ) ? (string) $settings['from_email'] : ''; + $sender_domain = $this->extract_domain_from_email( $from_email ); + $normalized_smtp_host = $this->normalize_hostname( $smtp_host ); + $mx_analysis = array( + 'domain' => $sender_domain, + 'records' => array(), + 'errors' => array(), + 'matches_smtp_host' => false, + ); + $host_ips = $this->get_hostname_ip_addresses( $normalized_smtp_host ); + + if ( '' !== $sender_domain ) { + $mx_analysis = $this->analyze_mx_records( $sender_domain, $normalized_smtp_host ); + } + + ob_start(); + + if ( '' === $sender_domain ) : + ?> +
+

+
+ analyze_domain_authentication( $sender_domain, $normalized_smtp_host, $mx_analysis, $host_ips ); + + if ( ! empty( $auth_analysis['errors'] ) ) : + ?> +
+
    + +
  • + +
+
+ +

+ + +
+
    + +
  • + +
+
+ +
+

+
+ +
    + +
  • + +
+ + +
+

+
+ +
+

+
+ +
+

+
+ + + +

+ + +
+
    + +
  • + +
+
+ +
+

+ +

+ +
+ +
+

+
+ + +

+ + +
+
    + +
  • + +
+
+ +
+

+
+ +

+ + +

+ +

+ + + +
+
    + +
  • + +
+
+ +
+

+
+ + + set_scope( $scope ); + + $settings = $this->get_settings(); + $smtp_host = isset( $settings['host'] ) ? (string) $settings['host'] : ''; + $normalized_smtp_host = $this->normalize_hostname( $smtp_host ); + $host_ips = $this->get_hostname_ip_addresses( $normalized_smtp_host ); + $analysis = $this->analyze_blacklist_status( $host_ips ); + + ob_start(); + + if ( ! empty( $analysis['errors'] ) ) : + ?> +
+
    + +
  • + +
+
+ +
+

+
+ +
+

+
+ +

+ +

+ + +
+
    + +
  • + +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ + + +

+ + +

+ + +

+ + + +
    + +
  • + +
+ +

+ + +

+ +
+

+ + +

+ + + +

+ +
+ get_current_admin_scope(); + + $this->ensure_capability( $scope ); + $this->set_scope( $scope ); + + $settings = $this->get_settings(); + $logging_enabled = ! empty( $settings['logs_enabled'] ); + $nonce_action = $this->get_logs_nonce_action(); + $nonce_value = filter_input( INPUT_GET, 'robotstxt_smtp_logs_nonce', FILTER_UNSAFE_RAW ); + + // Only honor filter arguments after confirming that the nonce matches the filter form submission. + $nonce_valid = is_string( $nonce_value ) && '' !== $nonce_value && wp_verify_nonce( wp_unslash( $nonce_value ), $nonce_action ); + $nonce_required = $this->is_logs_request_using_user_input(); + + $request_args = array(); + + if ( $nonce_required && ! $nonce_valid ) { + $log_id = 0; + $paged = 1; + $filters = $this->get_default_log_filters(); + } else { + if ( $nonce_valid ) { + $request_args = $this->get_sanitized_logs_request_args(); + } + + $log_id = $this->get_requested_log_id( $request_args ); + $paged = $this->get_requested_paged( $request_args ); + $filters = $this->get_log_filters( $request_args ); + } + + $logs_nonce = wp_create_nonce( $nonce_action ); + + ?> +
+

+ + +
+

+
+ + + +
+

+
+ + + +
+

+
+ + + +
+

+
+ + + 0 ) { + $this->render_log_details( $log_id, $scope, $filters, $logs_nonce ); + } else { + $this->render_logs_list( $paged, $scope, $filters, $logs_nonce ); + } + ?> +
+ Filter values. + */ + private function get_logs_nonce_action(): string { + return 'robotstxt_smtp_manage_logs'; + } + + /** + * Determines whether the current request attempts to filter or paginate the logs list. + * + * @return bool + */ + private function is_logs_request_using_user_input(): bool { + if ( filter_has_var( INPUT_GET, 'paged' ) ) { + return true; + } + + $keys = array( + 'robotstxt_smtp_subject', + 'robotstxt_smtp_to', + 'robotstxt_smtp_date_from', + 'robotstxt_smtp_date_to', + 'robotstxt_smtp_per_page', + 'log_id', + ); + + foreach ( $keys as $key ) { + if ( filter_has_var( INPUT_GET, $key ) ) { + return true; + } + } + + return false; + } + + /** + * Retrieves the sanitized request parameters used to filter the logs list. + * + * @return array + */ + private function get_sanitized_logs_request_args(): array { + $request = array(); + + $log_id = filter_input( INPUT_GET, 'log_id', FILTER_UNSAFE_RAW ); + + if ( null !== $log_id && '' !== $log_id ) { + // Cast to an absolute integer before using the requested log identifier. + $request['log_id'] = absint( wp_unslash( (string) $log_id ) ); + } + + $paged = filter_input( INPUT_GET, 'paged', FILTER_UNSAFE_RAW ); + + if ( null !== $paged && '' !== $paged ) { + // Force pagination to a positive integer to avoid loading invalid pages. + $request['paged'] = max( 1, absint( wp_unslash( (string) $paged ) ) ); + } + + $subject = filter_input( INPUT_GET, 'robotstxt_smtp_subject', FILTER_UNSAFE_RAW ); + + if ( is_string( $subject ) && '' !== $subject ) { + // Sanitize the email subject search term before passing it to WP_Query. + $request['robotstxt_smtp_subject'] = sanitize_text_field( wp_unslash( $subject ) ); + } + + $recipient = filter_input( INPUT_GET, 'robotstxt_smtp_to', FILTER_UNSAFE_RAW ); + + if ( is_string( $recipient ) && '' !== $recipient ) { + // Normalize the recipient filter to plain text for safe database queries. + $request['robotstxt_smtp_to'] = sanitize_text_field( wp_unslash( $recipient ) ); + } + + $date_from = filter_input( INPUT_GET, 'robotstxt_smtp_date_from', FILTER_UNSAFE_RAW ); + + if ( is_string( $date_from ) && '' !== $date_from ) { + // Validate the start date to guard against malformed date strings. + $request['robotstxt_smtp_date_from'] = $this->sanitize_log_date( $date_from ); + } + + $date_to = filter_input( INPUT_GET, 'robotstxt_smtp_date_to', FILTER_UNSAFE_RAW ); + + if ( is_string( $date_to ) && '' !== $date_to ) { + // Validate the end date to guard against malformed date strings. + $request['robotstxt_smtp_date_to'] = $this->sanitize_log_date( $date_to ); + } + + $per_page = filter_input( INPUT_GET, 'robotstxt_smtp_per_page', FILTER_UNSAFE_RAW ); + + if ( null !== $per_page && '' !== $per_page ) { + // Clamp the per-page setting to a non-negative integer before building the query. + $request['robotstxt_smtp_per_page'] = absint( wp_unslash( (string) $per_page ) ); + } + + return $request; + } + + /** + * Retrieves the requested log identifier from the current request. + * + * @param array $request Request arguments. + * + * @return int Log identifier if provided, otherwise 0. + */ + private function get_requested_log_id( array $request ): int { + if ( ! isset( $request['log_id'] ) ) { + return 0; + } + + return (int) $request['log_id']; + } + + /** + * Retrieves the requested page number when the nonce is valid. + * + * @param array $request Request arguments. + * + * @return int + */ + private function get_requested_paged( array $request ): int { + if ( ! isset( $request['paged'] ) ) { + return 1; + } + + return (int) $request['paged']; + } + + /** + * Returns the default filter values for the logs list. + * + * @return array + */ + private function get_default_log_filters(): array { + return array( + 'subject' => '', + 'to' => '', + 'date_from' => '', + 'date_to' => '', + 'per_page' => 100, + ); + } + + /** + * Retrieves the current filters applied to the logs list. + * + * @param array $request Request arguments. + * + * @return array Filter values. + */ + private function get_log_filters( array $request ): array { + $filters = $this->get_default_log_filters(); + + if ( isset( $request['robotstxt_smtp_subject'] ) ) { + $filters['subject'] = $request['robotstxt_smtp_subject']; + } + + if ( isset( $request['robotstxt_smtp_to'] ) ) { + $filters['to'] = $request['robotstxt_smtp_to']; + } + + if ( isset( $request['robotstxt_smtp_date_from'] ) ) { + $filters['date_from'] = $request['robotstxt_smtp_date_from']; + } + + if ( isset( $request['robotstxt_smtp_date_to'] ) ) { + $filters['date_to'] = $request['robotstxt_smtp_date_to']; + } + + $allowed_per_page = array( 10, 25, 50, 100, 250, 500 ); + + if ( isset( $request['robotstxt_smtp_per_page'] ) ) { + $requested_per_page = (int) $request['robotstxt_smtp_per_page']; + + if ( in_array( $requested_per_page, $allowed_per_page, true ) ) { + $filters['per_page'] = $requested_per_page; + } + } + + return $filters; + } + + /** + * Builds the query arguments that represent the current log filters. + * + * @param array $filters Filter values. + * + * @return array URL query arguments. + */ + private function get_log_filter_query_args( array $filters ): array { + $query_args = array(); + + if ( '' !== $filters['subject'] ) { + $query_args['robotstxt_smtp_subject'] = $filters['subject']; + } + + if ( '' !== $filters['to'] ) { + $query_args['robotstxt_smtp_to'] = $filters['to']; + } + + if ( '' !== $filters['date_from'] ) { + $query_args['robotstxt_smtp_date_from'] = $filters['date_from']; + } + + if ( '' !== $filters['date_to'] ) { + $query_args['robotstxt_smtp_date_to'] = $filters['date_to']; + } + + if ( 100 !== $filters['per_page'] ) { + $query_args['robotstxt_smtp_per_page'] = (string) $filters['per_page']; + } + + return $query_args; + } + + /** + * Sanitizes a date string coming from the logs filters. + * + * @param string $value Raw date value. + * + * @return string Sanitized date in `Y-m-d` format or an empty string when invalid. + */ + private function sanitize_log_date( string $value ): string { + $value = sanitize_text_field( $value ); + + if ( '' === $value ) { + return ''; + } + + $date = \DateTime::createFromFormat( 'Y-m-d', $value ); + + if ( ! $date ) { + return ''; + } + + $errors = \DateTime::getLastErrors(); + + if ( is_array( $errors ) && ( $errors['warning_count'] > 0 || $errors['error_count'] > 0 ) ) { + return ''; + } + + return $date->format( 'Y-m-d' ); + } + + /** + * Renders the table listing of log entries. + * + * @param int $paged Current page number. + * @param string $scope Scope identifier (site or network). + * @param array $filters Current filter values. + * @param string $nonce Logs nonce value. + * + * @return void + */ + private function render_logs_list( int $paged, string $scope, array $filters, string $nonce ): void { + $per_page = $filters['per_page']; + $filter_query_args = $this->get_log_filter_query_args( $filters ); + + $query_args = array( + 'post_type' => Plugin::get_log_post_type(), + 'post_status' => 'publish', + 'posts_per_page' => $per_page, + 'paged' => $paged, + 'orderby' => 'date', + 'order' => 'DESC', + ); + + if ( '' !== $filters['subject'] ) { + $query_args['s'] = $filters['subject']; + } + + if ( '' !== $filters['to'] ) { + // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Recipient filter requires meta_query. + $query_args['meta_query'] = array( + array( + 'key' => '_robotstxt_smtp_to', + 'value' => $filters['to'], + 'compare' => 'LIKE', + ), + ); + } + + if ( '' !== $filters['date_from'] || '' !== $filters['date_to'] ) { + $date_query = array( + 'inclusive' => true, + ); + + if ( '' !== $filters['date_from'] ) { + $date_query['after'] = $filters['date_from']; + } + + if ( '' !== $filters['date_to'] ) { + $date_query['before'] = $filters['date_to']; + } + + $query_args['date_query'] = array( $date_query ); + } + + $query = new \WP_Query( $query_args ); + + $base_url = remove_query_arg( + array( 'paged', 'log_id', 'robotstxt_smtp_cleared' ), + add_query_arg( + array_merge( + array( + 'page' => self::LOGS_PAGE_SLUG, + 'robotstxt_smtp_logs_nonce' => $nonce, + ), + $filter_query_args + ), + $this->get_admin_url_for_scope( $scope, 'admin.php' ) + ) + ); + + $reset_url = empty( $filter_query_args ) + ? $base_url + : remove_query_arg( array_keys( $filter_query_args ), $base_url ); + + ?> +
+ + get_logs_nonce_action(), 'robotstxt_smtp_logs_nonce', false ); + ?> +
+

+ + +

+

+ + +

+

+ + +

+

+ + +

+

+ + +

+

+ +

+

+ +

+
+
+ +
+
+ + + + "return confirm('" . $confirmation . "');", + ) + ); + ?> +
+
+ + posts ) ) : ?> +

+ + + + + + + + + + + + + + + + posts as $log ) : ?> + ID, '_robotstxt_smtp_from', true ); + $to = get_post_meta( $log->ID, '_robotstxt_smtp_to', true ); + $subject = $log->post_title ? $log->post_title : __( '(No subject)', 'robotstxt-smtp' ); + $status_display = $this->get_log_status_display( (int) $log->ID ); + $view_url = add_query_arg( + array_merge( + array( + 'page' => self::LOGS_PAGE_SLUG, + 'log_id' => $log->ID, + 'robotstxt_smtp_logs_nonce' => $nonce, + ), + $filter_query_args + ), + $this->get_admin_url_for_scope( $scope, 'admin.php' ) + ); + $date = get_date_from_gmt( + $log->post_date_gmt, + get_option( 'date_format' ) . ' ' . get_option( 'time_format' ) + ); + ?> + + + + + + + + + + +
+ + + + + + + +
+ + add_query_arg( 'paged', '%#%', $base_url ), + 'format' => '', + 'current' => max( 1, $paged ), + 'total' => max( 1, (int) $query->max_num_pages ), + 'prev_text' => __( '«', 'robotstxt-smtp' ), + 'next_text' => __( '»', 'robotstxt-smtp' ), + ) + ); + + if ( $pagination ) { + echo '
' . wp_kses_post( $pagination ) . '
'; + } + + wp_reset_postdata(); + } + + /** + * Displays the details of a single log entry. + * + * @param int $log_id Log post ID. + * @param string $scope Scope identifier (site or network). + * @param array $filters Current filter values. + * @param string $nonce Logs nonce value. + * + * @return void + */ + private function render_log_details( int $log_id, string $scope, array $filters, string $nonce ): void { + $log = get_post( $log_id ); + + if ( ! $log || Plugin::get_log_post_type() !== $log->post_type ) { + echo '

' . esc_html__( 'The requested log entry could not be found.', 'robotstxt-smtp' ) . '

'; + $this->render_logs_list( 1, $scope, $filters, $nonce ); + return; + } + + $from = get_post_meta( $log->ID, '_robotstxt_smtp_from', true ); + $to = get_post_meta( $log->ID, '_robotstxt_smtp_to', true ); + $headers = (string) get_post_meta( $log->ID, '_robotstxt_smtp_headers', true ); + $attachments = maybe_unserialize( get_post_meta( $log->ID, '_robotstxt_smtp_attachments', true ) ); + $debug_log = maybe_unserialize( get_post_meta( $log->ID, '_robotstxt_smtp_debug_log', true ) ); + $date = get_date_from_gmt( $log->post_date_gmt, get_option( 'date_format' ) . ' ' . get_option( 'time_format' ) ); + $subject = $log->post_title ? $log->post_title : __( '(No subject)', 'robotstxt-smtp' ); + $status = $this->get_log_status_display( (int) $log->ID ); + $error = (string) get_post_meta( $log->ID, '_robotstxt_smtp_error', true ); + + if ( ! is_array( $attachments ) ) { + $attachments = array(); + } + + if ( ! is_array( $debug_log ) ) { + $debug_log = array(); + } + + $normalized_attachments = array(); + $normalized_debug_log = array(); + + foreach ( $attachments as $attachment ) { + if ( ! is_scalar( $attachment ) ) { + continue; + } + + $attachment_name = trim( (string) $attachment ); + + if ( '' === $attachment_name ) { + continue; + } + + $normalized_attachments[] = $attachment_name; + } + + foreach ( $debug_log as $debug_line ) { + if ( ! is_scalar( $debug_line ) ) { + continue; + } + + $clean_line = sanitize_textarea_field( (string) $debug_line ); + $clean_line = $this->redact_smtp_credentials( $clean_line ); + + if ( '' === $clean_line ) { + continue; + } + + $normalized_debug_log[] = $clean_line; + } + + + $back_url = add_query_arg( + array( + 'page' => self::LOGS_PAGE_SLUG, + ), + $this->get_admin_url_for_scope( $scope, 'admin.php' ) + ); + + if ( ! empty( $filters['subject'] ) ) { + $back_url = add_query_arg( 'subject', rawurlencode( $filters['subject'] ), $back_url ); + } + + if ( ! empty( $filters['to'] ) ) { + $back_url = add_query_arg( 'to', rawurlencode( $filters['to'] ), $back_url ); + } + + if ( ! empty( $filters['date_from'] ) ) { + $back_url = add_query_arg( 'date_from', rawurlencode( $filters['date_from'] ), $back_url ); + } + + if ( ! empty( $filters['date_to'] ) ) { + $back_url = add_query_arg( 'date_to', rawurlencode( $filters['date_to'] ), $back_url ); + } + + if ( ! empty( $filters['per_page'] ) && 100 !== $filters['per_page'] ) { + $back_url = add_query_arg( 'per_page', (int) $filters['per_page'], $back_url ); + } + ?> +

←

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ +
+ +

+
+ +

+ +
    + +
  • + +
+ +

+ + +

+ post_content ) : ?> +
post_content ) ); ?>
+ +

+ + +

+ +
+ +
+
+ +

+ + + */ + private function get_log_status_display( int $log_id ): array { + $status = get_post_meta( $log_id, '_robotstxt_smtp_status', true ); + + if ( 'error' === $status ) { + return array( + 'status' => 'error', + 'label' => __( 'Failed', 'robotstxt-smtp' ), + 'class' => 'robotstxt-smtp-log-status-error', + ); + } + + return array( + 'status' => 'sent', + 'label' => __( 'Sent', 'robotstxt-smtp' ), + 'class' => 'robotstxt-smtp-log-status-sent', + ); + } + + /** + * Handles the request to clear all stored logs. + * + * @return void + */ + public function handle_clear_logs(): void { + $nonce_value = filter_input( INPUT_POST, '_wpnonce', FILTER_UNSAFE_RAW ); + + // Block log deletions unless the nonce matches the action button submission. + if ( ! is_string( $nonce_value ) || ! wp_verify_nonce( wp_unslash( $nonce_value ), 'robotstxt_smtp_clear_logs' ) ) { + wp_die( esc_html__( 'The link you followed has expired.', 'robotstxt-smtp' ) ); + } + + $scope = self::SCOPE_SITE; + + $context_raw = filter_input( INPUT_POST, 'robotstxt_smtp_context', FILTER_UNSAFE_RAW ); + + if ( is_string( $context_raw ) && '' !== $context_raw ) { + // Sanitize the submitted scope before checking the requested context. + $context = sanitize_text_field( wp_unslash( $context_raw ) ); + + if ( self::SCOPE_NETWORK === $context ) { + $scope = self::SCOPE_NETWORK; + } + } + + $this->ensure_capability( $scope ); + $this->set_scope( $scope ); + + Plugin::get_instance()->clear_all_logs(); + + $redirect = add_query_arg( + array( + 'page' => self::LOGS_PAGE_SLUG, + 'robotstxt_smtp_cleared' => 1, + ), + $this->get_admin_url_for_scope( $scope, 'admin.php' ) + ); + + wp_safe_redirect( $redirect ); + exit; + } + + /** + * Renders the host field. + * + * @return void + */ + public function render_host_field(): void { + $settings = $this->get_settings(); + ?> + +

+ +

+ get_settings(); + ?> + +

+ get_settings(); + $has_password = '' !== $settings['password']; + $placeholder_msg = $has_password ? __( 'Leave empty to keep the current password.', 'robotstxt-smtp' ) : ''; + ?> + +

+ get_settings(); + ?> + +

+ get_settings(); + ?> + +

+ get_settings(); + ?> + +

+ get_settings(); + ?> + +

+ get_settings(); + $options = $this->get_security_options(); + ?> + +

+ get_settings(); + ?> + +

+ get_settings(); + ?> + +

+ get_settings(); + $mode = isset( $settings['logs_retention_mode'] ) ? $settings['logs_retention_mode'] : 'count'; + ?> +
+ +
+ +
+

+ get_settings(); + ?> + +

+ get_settings(); + ?> + +

+ get_settings(); + ?> + +

+ $options Raw option values. + * + * @return array Sanitized option values. + */ + public function sanitize_options( array $options ): array { + // Debug: Log sanitize_options entry. + + $this->cached_settings = null; + + $request_method = filter_input( INPUT_SERVER, 'REQUEST_METHOD', FILTER_UNSAFE_RAW ); + if ( self::SCOPE_SITE === $this->get_scope() && is_admin() && 'POST' === $request_method ) { + $this->site_settings_submitted = true; + $this->site_settings_option_updated = false; + } + + + $option_name = $this->get_option_name_for_scope(); + + if ( self::SCOPE_NETWORK === $this->get_scope() ) { + $existing = get_site_option( $option_name, array() ); + } else { + $existing = get_option( $option_name, array() ); + } + + if ( ! is_array( $existing ) ) { + $existing = array(); + } + + $clean = wp_parse_args( $existing, self::get_default_settings() ); + $options = wp_unslash( $options ); + $security = $this->get_security_options(); + + if ( isset( $options['host'] ) ) { + $hostname = sanitize_text_field( $options['host'] ); + + // Validate hostname to prevent SSRF attacks. + $validation = $this->validate_smtp_hostname( $hostname ); + + if ( is_wp_error( $validation ) ) { + add_settings_error( + 'robotstxt_smtp_settings', + 'private_ip_blocked', + $validation->get_error_message() + ); + } else { + $clean['host'] = $hostname; + } + } + + if ( isset( $options['username'] ) ) { + $clean['username'] = sanitize_text_field( $options['username'] ); + } + + if ( isset( $options['password'] ) ) { + $submitted_password = trim( sanitize_text_field( $options['password'] ) ); + + if ( '' !== $submitted_password ) { + $clean['password'] = $submitted_password; + } + } + + if ( isset( $options['from_email'] ) ) { + $email = sanitize_email( $options['from_email'] ); + if ( ! empty( $email ) && is_email( $email ) ) { + $clean['from_email'] = $email; + } elseif ( ! empty( $email ) ) { + add_settings_error( + 'robotstxt_smtp_settings', + 'invalid_from_email', + __( 'The "From Email" address is not valid. Please provide a valid email address.', 'robotstxt-smtp' ) + ); + } + } + + if ( isset( $options['from_name'] ) ) { + $clean['from_name'] = sanitize_text_field( $options['from_name'] ); + } + + if ( isset( $options['reply_to_email'] ) ) { + $email = sanitize_email( $options['reply_to_email'] ); + if ( ! empty( $email ) && is_email( $email ) ) { + $clean['reply_to_email'] = $email; + } elseif ( ! empty( $email ) ) { + add_settings_error( + 'robotstxt_smtp_settings', + 'invalid_reply_to_email', + __( 'The "Reply-To Email" address is not valid. Please provide a valid email address.', 'robotstxt-smtp' ) + ); + } + } + + if ( isset( $options['reply_to_name'] ) ) { + $clean['reply_to_name'] = sanitize_text_field( $options['reply_to_name'] ); + } + + // Only process Amazon SES fields if Amazon SES integration is NOT active (the add-on will handle it). + if ( ! Plugin::is_amazon_ses_integration_active() ) { + if ( isset( $options['amazon_ses_access_key'] ) ) { + $submitted_key = trim( wp_unslash( $options['amazon_ses_access_key'] ) ); + + if ( preg_match( '/^AKIA[0-9A-Z]{16}$/', $submitted_key ) ) { + $clean['amazon_ses_access_key'] = $submitted_key; + } elseif ( '' !== $submitted_key ) { + add_settings_error( + $this->get_settings_option_name(), + 'invalid_aws_access_key', + __( 'The AWS Access Key format is invalid. It should start with AKIA followed by 16 alphanumeric characters.', 'robotstxt-smtp' ), + 'error' + ); + } + } + + if ( isset( $options['amazon_ses_secret_key'] ) ) { + $submitted_secret = trim( wp_unslash( $options['amazon_ses_secret_key'] ) ); + + if ( '' !== $submitted_secret && preg_match( '/^[A-Za-z0-9\/+=]{40}$/', $submitted_secret ) ) { + $clean['amazon_ses_secret_key'] = $submitted_secret; + } elseif ( '' !== $submitted_secret ) { + add_settings_error( + $this->get_settings_option_name(), + 'invalid_aws_secret_key', + __( 'The AWS Secret Key format is invalid. It should be 40 characters of base64-encoded data.', 'robotstxt-smtp' ), + 'error' + ); + } + } + + if ( isset( $options['amazon_ses_region'] ) ) { + $valid_regions = array( + 'us-east-1', 'us-east-2', 'us-west-1', 'us-west-2', + 'af-south-1', + 'ap-south-1', 'ap-south-2', 'ap-southeast-1', 'ap-southeast-2', 'ap-southeast-3', + 'ap-northeast-1', 'ap-northeast-2', 'ap-northeast-3', + 'ca-central-1', + 'eu-central-1', 'eu-central-2', 'eu-west-1', 'eu-west-2', 'eu-west-3', + 'eu-north-1', 'eu-south-1', + 'il-central-1', + 'me-south-1', 'me-central-1', + 'sa-east-1', + 'us-gov-east-1', 'us-gov-west-1', + ); + + $submitted_region = sanitize_text_field( $options['amazon_ses_region'] ); + + if ( in_array( $submitted_region, $valid_regions, true ) ) { + $clean['amazon_ses_region'] = $submitted_region; + } + } + } // End of Amazon SES fields processing when add-on is not active + + if ( isset( $options['security'] ) && array_key_exists( $options['security'], $security ) ) { + $clean['security'] = $options['security']; + } + + if ( isset( $options['port'] ) ) { + $port = absint( $options['port'] ); + + // Validate port is within valid TCP/IP range (1-65535). + if ( $port >= 1 && $port <= 65535 ) { + $clean['port'] = $port; + } else { + // Set default port (25) and show error message. + $clean['port'] = 25; + + add_settings_error( + $this->get_settings_option_name(), + 'invalid_port', + sprintf( + /* translators: %d: Invalid port number entered by user */ + __( 'The port number "%d" is invalid. Port must be between 1 and 65535. Using default port 25.', 'robotstxt-smtp' ), + $port + ), + 'error' + ); + } + } + + $clean['logs_enabled'] = ! empty( $options['logs_enabled'] ); + + if ( isset( $options['logs_retention_mode'] ) && in_array( $options['logs_retention_mode'], array( 'count', 'days' ), true ) ) { + $clean['logs_retention_mode'] = $options['logs_retention_mode']; + } + + if ( isset( $options['logs_retention_count'] ) ) { + $clean['logs_retention_count'] = absint( $options['logs_retention_count'] ); + } + + if ( isset( $options['logs_retention_days'] ) ) { + $clean['logs_retention_days'] = absint( $options['logs_retention_days'] ); + } + + if ( isset( $options['stats_retention_days'] ) ) { + $days = absint( $options['stats_retention_days'] ); + // Enforce minimum of 1 day and maximum of 365 days. + $clean['stats_retention_days'] = max( 1, min( 365, $days ) ); + } + + if ( isset( $options['rate_limit_per_second'] ) ) { + $clean['rate_limit_per_second'] = absint( $options['rate_limit_per_second'] ); + } + + if ( isset( $options['rate_limit_per_hour'] ) ) { + $clean['rate_limit_per_hour'] = absint( $options['rate_limit_per_hour'] ); + } + + if ( isset( $options['rate_limit_per_day'] ) ) { + $clean['rate_limit_per_day'] = absint( $options['rate_limit_per_day'] ); + } + + /** + * Filters the sanitized SMTP options before they are persisted. + * + * This hook allows integrations to adjust the sanitized values or + * perform additional validation based on the submitted form data. + * + * @since 1.1.0 + * + * @param array $clean Sanitized option values. + * @param array $options Raw submitted values after wp_unslash(). + * @param Settings_Page $settings Settings page instance. + */ + // Debug: Check $clean before filter. + + $clean = (array) \apply_filters( 'robotstxt_smtp_sanitized_options', $clean, $options, $this ); + + + // Encrypt sensitive credentials before storing (after the filter so add-ons can work with plain text). + if ( isset( $clean['password'] ) && '' !== $clean['password'] ) { + $clean['password'] = Robotstxt_SMTP_Encryption::encrypt( $clean['password'] ); + } + + if ( isset( $clean['amazon_ses_access_key'] ) && '' !== $clean['amazon_ses_access_key'] ) { + $clean['amazon_ses_access_key'] = Robotstxt_SMTP_Encryption::encrypt( $clean['amazon_ses_access_key'] ); + } + + if ( isset( $clean['amazon_ses_secret_key'] ) && '' !== $clean['amazon_ses_secret_key'] ) { + $clean['amazon_ses_secret_key'] = Robotstxt_SMTP_Encryption::encrypt( $clean['amazon_ses_secret_key'] ); + } + + return $clean; + } + + /** + * Retrieves the stored settings merged with defaults. + * + * @return array Stored settings. + */ + public function get_settings(): array { + if ( null !== $this->cached_settings ) { + return $this->cached_settings; + } + + $defaults = self::get_default_settings(); + $option_name = $this->get_option_name_for_scope(); + + if ( self::SCOPE_NETWORK === $this->get_scope() ) { + $settings = get_site_option( $option_name, array() ); + } else { + $settings = get_option( $option_name, array() ); + } + + if ( ! is_array( $settings ) ) { + $settings = array(); + } + + $this->cached_settings = wp_parse_args( $settings, $defaults ); + + // Decrypt sensitive credentials after loading from database. + if ( isset( $this->cached_settings['password'] ) && '' !== $this->cached_settings['password'] ) { + $this->cached_settings['password'] = Robotstxt_SMTP_Encryption::decrypt( $this->cached_settings['password'] ); + } + + if ( isset( $this->cached_settings['amazon_ses_access_key'] ) && '' !== $this->cached_settings['amazon_ses_access_key'] ) { + $this->cached_settings['amazon_ses_access_key'] = Robotstxt_SMTP_Encryption::decrypt( $this->cached_settings['amazon_ses_access_key'] ); + } + + if ( isset( $this->cached_settings['amazon_ses_secret_key'] ) && '' !== $this->cached_settings['amazon_ses_secret_key'] ) { + $this->cached_settings['amazon_ses_secret_key'] = Robotstxt_SMTP_Encryption::decrypt( $this->cached_settings['amazon_ses_secret_key'] ); + } + + return $this->cached_settings; + } + + /** + * Validates SMTP hostname to prevent SSRF attacks to private/local IPs. + * + * Checks if the hostname resolves to a private IP address and blocks it + * to prevent Server-Side Request Forgery (SSRF) attacks. + * + * Can be bypassed in development environments by defining: + * define( 'ROBOTSTXT_SMTP_ALLOW_PRIVATE_IPS', true ); + * + * @since 1.2.1 + * + * @param string $hostname SMTP hostname to validate. + * @return true|WP_Error True if valid, WP_Error if blocked. + */ + private function validate_smtp_hostname( string $hostname ) { + // Allow bypass for development environments. + if ( defined( 'ROBOTSTXT_SMTP_ALLOW_PRIVATE_IPS' ) && ROBOTSTXT_SMTP_ALLOW_PRIVATE_IPS ) { + return true; + } + + // Skip validation for empty hostnames (will fail elsewhere). + if ( empty( $hostname ) ) { + return true; + } + + // Resolve hostname to IP address. + $ip = gethostbyname( $hostname ); + + // If resolution failed, allow it to fail during actual connection. + if ( $ip === $hostname && ! filter_var( $hostname, FILTER_VALIDATE_IP ) ) { + // Could not resolve, but don't block here - let SMTP connection handle it. + return true; + } + + // Check if IP is private/local. + if ( $this->is_private_ip( $ip ) ) { + return new WP_Error( + 'private_ip_blocked', + sprintf( + /* translators: %s: IP address */ + __( 'The SMTP hostname resolves to a private IP address (%s) which is not allowed for security reasons. If you need to connect to a local SMTP server in development, add this to wp-config.php: define( \'ROBOTSTXT_SMTP_ALLOW_PRIVATE_IPS\', true );', 'robotstxt-smtp' ), + $ip + ) + ); + } + + return true; + } + + /** + * Checks if an IP address is private or reserved. + * + * @since 1.2.1 + * + * @param string $ip IP address to check. + * @return bool True if private, false otherwise. + */ + private function is_private_ip( string $ip ): bool { + // Validate IP format. + if ( ! filter_var( $ip, FILTER_VALIDATE_IP ) ) { + return false; + } + + // Use PHP's built-in filter for private IPs. + // This covers: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 127.0.0.0/8, etc. + if ( ! filter_var( + $ip, + FILTER_VALIDATE_IP, + FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE + ) ) { + return true; + } + + return false; + } + + /** + * Redacts sensitive authentication data from SMTP log messages. + * + * Removes or masks authentication credentials including: + * - AUTH PLAIN/LOGIN commands with base64-encoded credentials + * - Base64-encoded authentication responses + * - Server authentication challenges + * + * @since 1.2.1 + * + * @param string $message Log message from PHPMailer SMTP debug output. + * @return string Sanitized message with credentials redacted. + */ + private function redact_smtp_credentials( string $message ): string { + // Redact AUTH PLAIN command with base64 credentials. + // Matches AUTH PLAIN anywhere in line, not just at start. + $message = preg_replace( + '/\bAUTH\s+PLAIN\s+[A-Za-z0-9+\/=]+/i', + 'AUTH PLAIN [REDACTED]', + $message + ); + + // Redact AUTH LOGIN command with base64 credentials. + // Matches AUTH LOGIN anywhere in line. + $message = preg_replace( + '/\bAUTH\s+LOGIN\s+[A-Za-z0-9+\/=]+/i', + 'AUTH LOGIN [REDACTED]', + $message + ); + + // Redact other AUTH mechanisms with credentials. + // Handles CRAM-MD5, DIGEST-MD5, XOAUTH2, NTLM, GSSAPI, EXTERNAL. + $message = preg_replace( + '/\bAUTH\s+(CRAM-MD5|DIGEST-MD5|XOAUTH2|NTLM|GSSAPI|EXTERNAL)\s+[A-Za-z0-9+\/=\-_\.]+/i', + 'AUTH ${1} [REDACTED]', + $message + ); + + // Redact base64 challenge-response (server sends 334 + base64). + // The 334 code indicates server is awaiting authentication data. + $message = preg_replace( + '/\b334\s+[A-Za-z0-9+\/=]+/', + '334 [CHALLENGE REDACTED]', + $message + ); + + // Redact standalone base64 strings (likely auth responses). + // Matches lines that are predominantly base64 (20+ chars). + // Preserves optional timestamp prefix [123] or similar. + $message = preg_replace( + '/^(\[\d+\]\s*)?([A-Za-z0-9+\/=]{20,})\s*$/mi', + '${1}[CREDENTIAL REDACTED]', + $message + ); + + return $message; + } + + /** + * Extracts the domain portion from an email address. + * + * @param string $email Email address. + * + * @return string + */ + private function extract_domain_from_email( string $email ): string { + $sanitized = sanitize_email( $email ); + + if ( empty( $sanitized ) || false === strpos( $sanitized, '@' ) ) { + return ''; + } + + $parts = explode( '@', $sanitized ); + $domain = array_pop( $parts ); + + if ( ! is_string( $domain ) ) { + return ''; + } + + $domain = strtolower( $domain ); + $domain = rtrim( $domain, '.' ); + + return $domain; + } + + /** + * Normalizes a hostname for comparison. + * + * @param string $hostname Hostname to normalize. + * + * @return string + */ + private function normalize_hostname( string $hostname ): string { + $normalized = strtolower( trim( $hostname ) ); + + if ( '' === $normalized ) { + return ''; + } + + if ( false !== strpos( $normalized, '://' ) ) { + $parsed = wp_parse_url( $normalized ); + + if ( is_array( $parsed ) && isset( $parsed['host'] ) ) { + $normalized = strtolower( (string) $parsed['host'] ); + } + } + + $normalized = ltrim( $normalized, '/\\' ); + + $normalized = preg_replace( '/:\d+$/', '', $normalized ); + + if ( ! is_string( $normalized ) ) { + $normalized = ''; + } + + $normalized = rtrim( $normalized, '.' ); + + return $normalized; + } + + /** + * Analyzes SPF, DKIM, and DMARC records for the provided domain. + * + * @param string $domain Domain to analyze. + * @param string $smtp_host Normalized SMTP host. + * @param array $mx_analysis MX lookup results. + * @param array>|null $host_ips Optional pre-resolved SMTP host IP addresses. + * + * @return array + */ + private function analyze_domain_authentication( string $domain, string $smtp_host, array $mx_analysis, ?array $host_ips = null ): array { + $result = array( + 'domain' => $domain, + 'errors' => array(), + 'spf' => array( + 'records' => array(), + 'errors' => array(), + 'authorized' => null, + 'message' => '', + ), + 'dkim' => array( + 'found' => null, + 'errors' => array(), + 'record' => '', + ), + 'dmarc' => array( + 'record' => '', + 'policy' => '', + 'errors' => array(), + 'recommendations' => array(), + ), + ); + + if ( '' === $domain ) { + $result['errors'][] = __( 'The sender domain could not be determined.', 'robotstxt-smtp' ); + + return $result; + } + + if ( ! function_exists( 'dns_get_record' ) ) { + $result['errors'][] = __( 'DNS lookups are not available because the DNS functions are disabled on this server.', 'robotstxt-smtp' ); + + return $result; + } + + if ( null === $host_ips ) { + $host_ips = $this->get_hostname_ip_addresses( $smtp_host ); + } + $result['spf'] = $this->analyze_spf_records( $domain, $smtp_host, $mx_analysis, $host_ips ); + $result['dkim'] = $this->analyze_dkim_record( $domain ); + $result['dmarc'] = $this->analyze_dmarc_record( $domain ); + + + return $result; + } + + /** + * Checks the resolved SMTP host IPs against DNSBL providers. + * + * @param array> $host_ips Resolved IP addresses for the SMTP host. + * + * @return array + */ + private function analyze_blacklist_status( array $host_ips ): array { + $result = array( + 'ips' => array(), + 'ipv6' => array(), + 'errors' => array(), + ); + + if ( ! function_exists( 'dns_get_record' ) ) { + $result['errors'][] = __( 'Blacklist lookups are not available because the DNS functions are disabled on this server.', 'robotstxt-smtp' ); + + return $result; + } + + if ( ! empty( $host_ips['ipv6'] ) ) { + $result['ipv6'] = $host_ips['ipv6']; + } + + if ( empty( $host_ips['ipv4'] ) ) { + return $result; + } + + $providers = $this->get_dnsbl_providers(); + + foreach ( $host_ips['ipv4'] as $ip ) { + if ( false === filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) { + continue; + } + + $ip_result = array( + 'ip' => $ip, + 'errors' => array(), + 'listings' => array(), + ); + + foreach ( $providers as $provider ) { + $ip_result['listings'][] = $this->query_dnsbl_listing( $ip, $provider ); + } + + $result['ips'][] = $ip_result; + } + + return $result; + } + + /** + * Provides the DNSBL providers used for blacklist checks. + * + * @return array> + */ + private function get_dnsbl_providers(): array { + return array( + array( + 'id' => 'spamhaus_zen', + 'label' => __( 'Spamhaus ZEN', 'robotstxt-smtp' ), + 'zone' => 'zen.spamhaus.org', + 'impact' => __( 'High — major inbox providers rely on Spamhaus and a listing can block most traffic.', 'robotstxt-smtp' ), + 'removal_url' => 'https://check.spamhaus.org/', + 'removal_notes' => __( 'Investigate and resolve the root cause, then use the Spamhaus Blocklist Removal Center to request delisting.', 'robotstxt-smtp' ), + ), + array( + 'id' => 'spamcop', + 'label' => __( 'SpamCop', 'robotstxt-smtp' ), + 'zone' => 'bl.spamcop.net', + 'impact' => __( 'Medium — many shared hosts and spam filters consult SpamCop when scoring messages.', 'robotstxt-smtp' ), + 'removal_url' => 'https://www.spamcop.net/w3m?action=checkblock', + 'removal_notes' => __( 'Ensure no unsolicited traffic is sent and follow the SpamCop blocklist removal instructions.', 'robotstxt-smtp' ), + ), + array( + 'id' => 'barracuda', + 'label' => __( 'Barracuda Reputation Block List', 'robotstxt-smtp' ), + 'zone' => 'b.barracudacentral.org', + 'impact' => __( 'Medium — Barracuda appliances and some hosted filters can defer or reject messages.', 'robotstxt-smtp' ), + 'removal_url' => 'https://www.barracudacentral.org/lookups/lookup-reputation', + 'removal_notes' => __( 'Review the Barracuda reputation lookup and submit a delisting request after addressing any spam complaints.', 'robotstxt-smtp' ), + ), + ); + } + + /** + * Realiza consulta DNS con manejo de errores y timeout. + * + * @since 1.2.1 + * + * @param string $hostname Hostname a consultar. + * @param int $type Tipo de registro DNS (DNS_A, DNS_TXT, DNS_MX, etc.). + * @param int $timeout Timeout en segundos. + * + * @return array|false Array de registros o false en error. + */ + private function safe_dns_lookup( string $hostname, int $type, int $timeout = 2 ) { + // Verificar si la función existe. + if ( ! function_exists( 'dns_get_record' ) ) { + return false; + } + + // Configurar timeout de socket (afecta consultas DNS). + $original_timeout = ini_get( 'default_socket_timeout' ); + // phpcs:ignore WordPress.PHP.IniSet.Risky -- Necesario para evitar que consultas DNS cuelguen indefinidamente. + ini_set( 'default_socket_timeout', (string) $timeout ); + + // Suprimir warnings de DNS usando error handler personalizado. + // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_set_error_handler -- Necesario para capturar fallos DNS sin mostrar warnings. + set_error_handler( + function ( $errno, $errstr ) use ( $hostname ) { + // Registrar error para debugging pero no mostrar warning. + if ( defined( 'WP_DEBUG' ) && WP_DEBUG && defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) { + // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log -- Solo se ejecuta cuando WP_DEBUG_LOG está activo. + error_log( + sprintf( + 'ROBOTSTXT SMTP: DNS lookup warning for %s: [%d] %s', + $hostname, + $errno, + $errstr + ) + ); + } + return true; // Prevenir que PHP muestre el warning. + }, + E_WARNING + ); + + // Realizar consulta DNS. + $records = dns_get_record( $hostname, $type ); + + // Restaurar configuración. + restore_error_handler(); + // phpcs:ignore WordPress.PHP.IniSet.Risky -- Restaurar valor original después de consulta DNS. + ini_set( 'default_socket_timeout', (string) $original_timeout ); + + return $records; + } + + /** + * Verifica rate limiting para consultas DNS blacklist. + * + * @since 1.2.1 + * + * @return bool True si puede continuar, false si excedió límite. + */ + private function check_blacklist_rate_limit(): bool { + $user_id = get_current_user_id(); + $transient_key = 'robotstxt_smtp_blacklist_limit_' . $user_id; + $attempts = (int) get_transient( $transient_key ); + + // Máximo 3 consultas por hora por usuario. + if ( $attempts >= 3 ) { + return false; + } + + set_transient( $transient_key, $attempts + 1, HOUR_IN_SECONDS ); + return true; + } + + /** + * Queries a DNSBL provider for a specific IPv4 address. + * + * @param string $ip IPv4 address. + * @param array $provider Provider definition. + * + * @return array + */ + private function query_dnsbl_listing( string $ip, array $provider ): array { + // Verificar cache primero (1 hora). + $cache_key = 'robotstxt_smtp_dnsbl_' . md5( $ip . $provider['zone'] ); + $cached = get_transient( $cache_key ); + + if ( false !== $cached && is_array( $cached ) ) { + return $cached; + } + + $result = array( + 'provider' => $provider, + 'listed' => false, + 'response_ips' => array(), + 'txt_records' => array(), + 'error' => '', + ); + + $reverse = $this->reverse_ipv4_for_dnsbl( $ip ); + + if ( '' === $reverse ) { + $result['error'] = __( 'The IP address could not be normalized for the DNSBL lookup.', 'robotstxt-smtp' ); + + return $result; + } + + $hostname = $reverse . '.' . $provider['zone']; + + $a_records = $this->safe_dns_lookup( $hostname, DNS_A, 2 ); + + if ( false === $a_records ) { + /* translators: %s: DNSBL provider name. */ + $result['error'] = sprintf( __( 'The DNS lookup for %s failed. Please try again later.', 'robotstxt-smtp' ), $provider['label'] ); + + return $result; + } + + if ( empty( $a_records ) ) { + return $result; + } + + $result['listed'] = true; + + foreach ( $a_records as $record ) { + if ( isset( $record['ip'] ) && filter_var( $record['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) { + $result['response_ips'][] = (string) $record['ip']; + } + } + + $txt_records = $this->safe_dns_lookup( $hostname, DNS_TXT, 2 ); + + if ( false !== $txt_records && ! empty( $txt_records ) ) { + foreach ( $txt_records as $txt_record ) { + if ( isset( $txt_record['txt'] ) && is_string( $txt_record['txt'] ) ) { + $value = trim( (string) $txt_record['txt'] ); + + if ( '' !== $value ) { + $result['txt_records'][] = $value; + } + } + } + } + + + return $result; + } + + /** + * Normalizes an IPv4 address for DNSBL queries. + * + * @param string $ip IPv4 address. + * + * @return string + */ + private function reverse_ipv4_for_dnsbl( string $ip ): string { + if ( false === filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) { + return ''; + } + + $parts = explode( '.', $ip ); + + if ( count( $parts ) !== 4 ) { + return ''; + } + + return implode( '.', array_reverse( $parts ) ); + } + + /** + * Inspects SPF records for the sender domain. + * + * @param string $domain Sender domain. + * @param string $smtp_host Normalized SMTP host. + * @param array $mx_analysis MX lookup results. + * @param array $host_ips Resolved IP addresses for the SMTP host. + * + * @return array + */ + private function analyze_spf_records( string $domain, string $smtp_host, array $mx_analysis, array $host_ips ): array { + $result = array( + 'records' => array(), + 'errors' => array(), + 'authorized' => null, + 'message' => __( 'Unable to determine whether the SMTP host is authorized in the SPF record.', 'robotstxt-smtp' ), + ); + + if ( ! function_exists( 'dns_get_record' ) ) { + $result['errors'][] = __( 'DNS lookups are not available because the DNS functions are disabled on this server.', 'robotstxt-smtp' ); + + return $result; + } + + $txt_records = $this->safe_dns_lookup( $domain, DNS_TXT, 2 ); + + if ( false === $txt_records ) { + $result['errors'][] = __( 'The DNS lookup for TXT records failed. Please try again later.', 'robotstxt-smtp' ); + + return $result; + } + + foreach ( $txt_records as $record ) { + if ( empty( $record['txt'] ) || ! is_string( $record['txt'] ) ) { + continue; + } + + $value = trim( (string) $record['txt'] ); + + if ( preg_match( '/^v=spf1\b/i', $value ) ) { + $result['records'][] = $value; + } + } + + if ( empty( $result['records'] ) ) { + $result['message'] = __( 'The domain does not publish an SPF record.', 'robotstxt-smtp' ); + $result['authorized'] = null; + + return $result; + } + + if ( '' === $smtp_host ) { + $result['message'] = __( 'Configure an SMTP host to verify its presence in the SPF record.', 'robotstxt-smtp' ); + $result['authorized'] = null; + + return $result; + } + + $normalized_host = strtolower( $smtp_host ); + $mx_hosts = array(); + + if ( isset( $mx_analysis['records'] ) && is_array( $mx_analysis['records'] ) ) { + foreach ( $mx_analysis['records'] as $mx_record ) { + if ( isset( $mx_record['normalized_target'] ) && is_string( $mx_record['normalized_target'] ) ) { + $mx_hosts[] = strtolower( $mx_record['normalized_target'] ); + } + } + } + + $authorized = false; + $authorization_msg = ''; + $could_evaluate = false; + + foreach ( $result['records'] as $spf_record ) { + $tokens = preg_split( '/\s+/', strtolower( $spf_record ) ); + + if ( ! is_array( $tokens ) ) { + continue; + } + + foreach ( $tokens as $token ) { + if ( '' === $token ) { + continue; + } + + $qualifier = ''; + + if ( in_array( $token[0], array( '+', '-', '~', '?' ), true ) ) { + $qualifier = $token[0]; + $token = substr( $token, 1 ); + } + + if ( '' === $token || '-' === $qualifier ) { + continue; + } + + $token = preg_replace( '/\/\d+$/', '', $token ); + + if ( ! is_string( $token ) || '' === $token || 'v=spf1' === $token ) { + continue; + } + + if ( str_starts_with( $token, 'include:' ) || str_starts_with( $token, 'redirect=' ) ) { + $target = str_replace( array( 'include:', 'redirect=' ), '', $token ); + + if ( $this->hostname_matches_domain( $normalized_host, $target ) ) { + $authorized = true; + /* translators: %s: Included SPF domain. */ + $authorization_msg = sprintf( __( 'The SPF record includes %s, which matches the configured SMTP host.', 'robotstxt-smtp' ), $target ); + break 2; + } + + continue; + } + + if ( str_starts_with( $token, 'a:' ) ) { + $target = substr( $token, 2 ); + + if ( $this->hostname_matches_domain( $normalized_host, $target ) ) { + $authorized = true; + /* translators: %s: Hostname authorized via the SPF "a" mechanism. */ + $authorization_msg = sprintf( __( 'The SPF record authorizes %s via the "a" mechanism.', 'robotstxt-smtp' ), $normalized_host ); + break 2; + } + + continue; + } + + if ( 'a' === $token ) { + if ( $this->hostname_matches_domain( $normalized_host, $domain ) ) { + $authorized = true; + /* translators: %s: Hostname authorized via the SPF "a" mechanism. */ + $authorization_msg = sprintf( __( 'The SPF record authorizes %s via the "a" mechanism.', 'robotstxt-smtp' ), $normalized_host ); + break 2; + } + + continue; + } + + if ( str_starts_with( $token, 'mx:' ) ) { + $target = substr( $token, 3 ); + + if ( $this->hostname_matches_domain( $normalized_host, $target ) ) { + $authorized = true; + /* translators: %s: Hostname authorized via the SPF "mx" mechanism. */ + $authorization_msg = sprintf( __( 'The SPF record authorizes %s via the "mx" mechanism.', 'robotstxt-smtp' ), $normalized_host ); + break 2; + } + + continue; + } + + if ( 'mx' === $token && in_array( $normalized_host, $mx_hosts, true ) ) { + $authorized = true; + /* translators: %s: Hostname authorized via the SPF "mx" mechanism. */ + $authorization_msg = sprintf( __( 'The SPF record authorizes %s via the "mx" mechanism.', 'robotstxt-smtp' ), $normalized_host ); + break 2; + } + + if ( str_starts_with( $token, 'ip4:' ) ) { + $cidr = substr( $token, 4 ); + + if ( '' === $cidr || ! is_array( $host_ips['ipv4'] ) ) { + continue; + } + + foreach ( $host_ips['ipv4'] as $ip ) { + if ( $this->ipv4_in_cidr( $ip, $cidr ) ) { + $authorized = true; + /* translators: %1$s: IP address. %2$s: SPF mechanism. */ + $authorization_msg = sprintf( __( 'The SPF record authorizes the SMTP host IP %1$s via %2$s.', 'robotstxt-smtp' ), $ip, 'ip4' ); + break 3; + } + } + + $could_evaluate = true; + + continue; + } + + if ( str_starts_with( $token, 'ip6:' ) ) { + $cidr = substr( $token, 4 ); + + if ( '' === $cidr || ! is_array( $host_ips['ipv6'] ) ) { + continue; + } + + foreach ( $host_ips['ipv6'] as $ip ) { + if ( $this->ipv6_in_cidr( $ip, $cidr ) ) { + $authorized = true; + /* translators: %1$s: IP address. %2$s: SPF mechanism. */ + $authorization_msg = sprintf( __( 'The SPF record authorizes the SMTP host IP %1$s via %2$s.', 'robotstxt-smtp' ), $ip, 'ip6' ); + break 3; + } + } + + $could_evaluate = true; + } + } + } + + if ( $authorized ) { + $result['authorized'] = true; + $result['message'] = $authorization_msg; + + return $result; + } + + if ( ! empty( $host_ips['ipv4'] ) || ! empty( $host_ips['ipv6'] ) ) { + $result['authorized'] = false; + $result['message'] = __( 'The SMTP host was not found in the SPF record. Add it to avoid delivery issues.', 'robotstxt-smtp' ); + } elseif ( $could_evaluate ) { + $result['authorized'] = null; + $result['message'] = __( 'The SPF record contains IP ranges, but the SMTP host IP could not be resolved.', 'robotstxt-smtp' ); + } else { + $result['authorized'] = null; + $result['message'] = __( 'The SPF record does not explicitly reference the configured SMTP host.', 'robotstxt-smtp' ); + } + + + return $result; + } + + /** + * Retrieves IPv4 and IPv6 addresses for the provided hostname. + * + * @param string $hostname Hostname to inspect. + * + * @return array> + */ + private function get_hostname_ip_addresses( string $hostname ): array { + $ips = array( + 'ipv4' => array(), + 'ipv6' => array(), + ); + + if ( '' === $hostname || ! function_exists( 'dns_get_record' ) ) { + return $ips; + } + + $types = DNS_A; + + if ( defined( 'DNS_AAAA' ) ) { + $types |= DNS_AAAA; + } + + $candidates = array( $hostname, $hostname . '.' ); + + foreach ( $candidates as $candidate ) { + $records = $this->safe_dns_lookup( $candidate, $types, 2 ); + + if ( empty( $records ) || false === $records ) { + continue; + } + + foreach ( $records as $record ) { + if ( isset( $record['type'], $record['ip'] ) && 'A' === $record['type'] ) { + $ip = (string) $record['ip']; + + if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) { + $ips['ipv4'][ $ip ] = $ip; + } + } + + if ( isset( $record['type'], $record['ipv6'] ) && 'AAAA' === $record['type'] ) { + $ip = (string) $record['ipv6']; + + if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 ) ) { + $ips['ipv6'][ $ip ] = $ip; + } + } + } + } + + $ips['ipv4'] = array_values( $ips['ipv4'] ); + $ips['ipv6'] = array_values( $ips['ipv6'] ); + + return $ips; + } + + /** + * Determines whether the provided hostname belongs to the given domain. + * + * @param string $hostname Hostname to compare. + * @param string $domain Domain to check against. + * + * @return bool + */ + private function hostname_matches_domain( string $hostname, string $domain ): bool { + $hostname = strtolower( rtrim( $hostname, '.' ) ); + $domain = strtolower( rtrim( $domain, '.' ) ); + + if ( '' === $hostname || '' === $domain ) { + return false; + } + + if ( $hostname === $domain ) { + return true; + } + + return str_ends_with( $hostname, '.' . $domain ); + } + + /** + * Determines whether an IPv4 address belongs to the provided CIDR. + * + * @param string $ip IPv4 address. + * @param string $cidr CIDR expression. + * + * @return bool + */ + private function ipv4_in_cidr( string $ip, string $cidr ): bool { + if ( false === filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) { + return false; + } + + $parts = explode( '/', $cidr, 2 ); + $net = $parts[0]; + $bits = isset( $parts[1] ) ? (int) $parts[1] : 32; + + if ( false === filter_var( $net, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) { + return false; + } + + if ( $bits < 0 || $bits > 32 ) { + return false; + } + + $ip_long = unpack( 'N', inet_pton( $ip ) ); + $net_long = unpack( 'N', inet_pton( $net ) ); + + if ( ! is_array( $ip_long ) || ! is_array( $net_long ) ) { + return false; + } + + // unpack('N') returns array with index 1, not 0. + if ( ! isset( $ip_long[1] ) || ! isset( $net_long[1] ) ) { + return false; + } + + $mask = 0; + + if ( 0 !== $bits ) { + $mask = ( 0xFFFFFFFF << ( 32 - $bits ) ) & 0xFFFFFFFF; + } + + return ( ( $ip_long[1] & $mask ) === ( $net_long[1] & $mask ) ); + } + + /** + * Determines whether an IPv6 address belongs to the provided CIDR. + * + * @param string $ip IPv6 address. + * @param string $cidr CIDR expression. + * + * @return bool + */ + private function ipv6_in_cidr( string $ip, string $cidr ): bool { + if ( false === filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 ) ) { + return false; + } + + $parts = explode( '/', $cidr, 2 ); + $net = $parts[0]; + $bits = isset( $parts[1] ) ? (int) $parts[1] : 128; + + if ( false === filter_var( $net, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 ) ) { + return false; + } + + if ( $bits < 0 || $bits > 128 ) { + return false; + } + + $ip_bin = inet_pton( $ip ); + $net_bin = inet_pton( $net ); + + if ( false === $ip_bin || false === $net_bin ) { + return false; + } + + $remaining = $bits; + + for ( $i = 0; $i < 16; $i++ ) { + if ( $remaining <= 0 ) { + break; + } + + $mask = 0xFF; + + if ( $remaining < 8 ) { + $mask = ( 0xFF << ( 8 - $remaining ) ) & 0xFF; + } + + if ( ( ord( $ip_bin[ $i ] ) & $mask ) !== ( ord( $net_bin[ $i ] ) & $mask ) ) { + return false; + } + + $remaining -= 8; + } + + return true; + } + + /** + * Looks up a DKIM record using the default selector. + * + * @param string $domain Domain to inspect. + * + * @return array + */ + private function analyze_dkim_record( string $domain ): array { + $result = array( + 'found' => false, + 'errors' => array(), + 'record' => '', + ); + + if ( ! function_exists( 'dns_get_record' ) ) { + $result['errors'][] = __( 'DNS lookups are not available because the DNS functions are disabled on this server.', 'robotstxt-smtp' ); + + return $result; + } + + $selector_domain = 'default._domainkey.' . $domain; + $records = dns_get_record( $selector_domain, DNS_TXT ); + + if ( false === $records ) { + /* translators: %s: Domain queried for the DKIM record lookup. */ + $result['errors'][] = sprintf( __( 'The DNS lookup for %s failed. Please try again later.', 'robotstxt-smtp' ), $selector_domain ); + + return $result; + } + + foreach ( $records as $record ) { + if ( empty( $record['txt'] ) || ! is_string( $record['txt'] ) ) { + continue; + } + + $value = trim( (string) $record['txt'] ); + + if ( preg_match( '/^v=DKIM1/i', $value ) ) { + $result['found'] = true; + $result['record'] = $value; + break; + } + } + + + return $result; + } + + /** + * Looks up the DMARC policy for the sender domain. + * + * @param string $domain Domain to inspect. + * + * @return array + */ + private function analyze_dmarc_record( string $domain ): array { + $result = array( + 'record' => '', + 'policy' => '', + 'errors' => array(), + 'recommendations' => array(), + ); + + if ( ! function_exists( 'dns_get_record' ) ) { + $result['errors'][] = __( 'DNS lookups are not available because the DNS functions are disabled on this server.', 'robotstxt-smtp' ); + + return $result; + } + + $dmarc_domain = '_dmarc.' . $domain; + $records = dns_get_record( $dmarc_domain, DNS_TXT ); + + if ( false === $records ) { + /* translators: %s: Domain queried for the DMARC record lookup. */ + $result['errors'][] = sprintf( __( 'The DNS lookup for %s failed. Please try again later.', 'robotstxt-smtp' ), $dmarc_domain ); + + return $result; + } + + foreach ( $records as $record ) { + if ( empty( $record['txt'] ) || ! is_string( $record['txt'] ) ) { + continue; + } + + $value = trim( (string) $record['txt'] ); + + if ( preg_match( '/^v=DMARC1/i', $value ) ) { + $result['record'] = $value; + + if ( preg_match( '/\bp=([a-z]+)/i', $value, $matches ) ) { + $result['policy'] = strtolower( $matches[1] ); + } + + break; + } + } + + if ( '' === $result['record'] ) { + return $result; + } + + if ( 'none' === $result['policy'] ) { + $result['recommendations'][] = __( 'The DMARC policy is set to "p=none". Increase it to "p=quarantine" or "p=reject" to protect the domain.', 'robotstxt-smtp' ); + } elseif ( 'quarantine' === $result['policy'] ) { + $result['recommendations'][] = __( 'Consider moving the DMARC policy to "p=reject" once you have validated that legitimate messages pass authentication.', 'robotstxt-smtp' ); + } + + + return $result; + } + + /** + * Performs an MX lookup for the provided domain and compares the results with the SMTP host. + * + * @param string $domain Domain to inspect. + * @param string $smtp_host Normalized SMTP host. + * + * @return array + */ + private function analyze_mx_records( string $domain, string $smtp_host ): array { + $result = array( + 'domain' => $domain, + 'records' => array(), + 'errors' => array(), + 'matches_smtp_host' => false, + ); + + if ( '' === $domain ) { + return $result; + } + + if ( ! function_exists( 'dns_get_record' ) ) { + $result['errors'][] = __( 'MX lookups are not available because the DNS functions are disabled on this server.', 'robotstxt-smtp' ); + + return $result; + } + + $records = $this->safe_dns_lookup( $domain, DNS_MX, 2 ); + + if ( false === $records ) { + $result['errors'][] = __( 'The DNS lookup for MX records failed. Please try again later.', 'robotstxt-smtp' ); + + return $result; + } + + foreach ( $records as $record ) { + if ( empty( $record['target'] ) ) { + continue; + } + + $priority = isset( $record['pri'] ) ? (int) $record['pri'] : null; + $display_target = rtrim( (string) $record['target'], '.' ); + $normalized = $this->normalize_hostname( $display_target ); + $resolves = $this->hostname_resolves( $normalized ); + $matches_host = '' !== $smtp_host && $normalized === $smtp_host; + + $result['records'][] = array( + 'priority' => $priority, + 'display_target' => $display_target, + 'normalized_target' => $normalized, + 'resolves' => $resolves, + 'matches_host' => $matches_host, + ); + + if ( $matches_host ) { + $result['matches_smtp_host'] = true; + } + } + + usort( + $result['records'], + static function ( array $a, array $b ): int { + $priority_a = $a['priority'] ?? PHP_INT_MAX; + $priority_b = $b['priority'] ?? PHP_INT_MAX; + + if ( $priority_a === $priority_b ) { + return strcmp( $a['display_target'], $b['display_target'] ); + } + + return $priority_a <=> $priority_b; + } + ); + + + return $result; + } + + /** + * Determines whether a hostname resolves to an address record. + * + * @param string $hostname Hostname to inspect. + * + * @return bool|null True when it resolves, false when it does not, null when unknown. + */ + private function hostname_resolves( string $hostname ): ?bool { + if ( '' === $hostname ) { + return null; + } + + $candidates = array( $hostname, $hostname . '.' ); + + if ( function_exists( 'checkdnsrr' ) ) { + foreach ( $candidates as $candidate ) { + if ( checkdnsrr( $candidate, 'A' ) || checkdnsrr( $candidate, 'AAAA' ) ) { + return true; + } + } + } + + if ( function_exists( 'dns_get_record' ) ) { + $types = DNS_A; + + if ( defined( 'DNS_AAAA' ) ) { + $types |= DNS_AAAA; + } + + $had_error = false; + + foreach ( $candidates as $candidate ) { + $records = $this->safe_dns_lookup( $candidate, $types, 2 ); + + if ( false === $records ) { + $had_error = true; + continue; + } + + if ( ! empty( $records ) ) { + return true; + } + } + + if ( $had_error ) { + return null; + } + + return false; + } + + return null; + } + + /** + * Provides the default settings. + * + * @return array Default settings. + */ + public static function get_default_settings(): array { + return array( + 'host' => '', + 'username' => '', + 'password' => '', + 'from_email' => '', + 'from_name' => get_bloginfo( 'name', 'display' ), + 'reply_to_email' => '', + 'reply_to_name' => '', + 'security' => 'none', + 'port' => 25, + 'amazon_ses_access_key' => '', + 'amazon_ses_secret_key' => '', + 'amazon_ses_region' => '', + 'logs_enabled' => false, + 'logs_retention_mode' => 'count', + 'logs_retention_count' => 1024, + 'logs_retention_days' => 28, + 'stats_retention_days' => 28, + 'rate_limit_per_second' => 0, + 'rate_limit_per_hour' => 0, + 'rate_limit_per_day' => 0, + ); + } + + /** + * Returns the available security types. + * + * @return array Security type labels keyed by value. + */ + private function get_security_options(): array { + return array( + 'none' => esc_html__( 'None', 'robotstxt-smtp' ), + 'ssl' => esc_html__( 'SSL', 'robotstxt-smtp' ), + 'tls' => esc_html__( 'TLS', 'robotstxt-smtp' ), + ); + } + + /** + * Handles the submission of the test email form. + * + * @return void + */ + public function handle_test_email(): void { + $nonce_value = filter_input( INPUT_POST, 'robotstxt_smtp_test_email_nonce', FILTER_UNSAFE_RAW ); + + // Halt the request when the nonce is missing or invalid to stop forged test submissions. + if ( ! is_string( $nonce_value ) || ! wp_verify_nonce( wp_unslash( $nonce_value ), 'robotstxt_smtp_test_email' ) ) { + wp_die( esc_html__( 'The link you followed has expired.', 'robotstxt-smtp' ) ); + } + + $scope = self::SCOPE_SITE; + + $context_raw = filter_input( INPUT_POST, 'robotstxt_smtp_context', FILTER_UNSAFE_RAW ); + + if ( is_string( $context_raw ) && '' !== $context_raw ) { + // Sanitize the submitted scope before using it to determine capabilities. + $context = sanitize_text_field( wp_unslash( $context_raw ) ); + + if ( self::SCOPE_NETWORK === $context ) { + $scope = self::SCOPE_NETWORK; + } + } + + $this->ensure_capability( $scope ); + $this->set_scope( $scope ); + + $recipient = ''; + + $recipient_raw = filter_input( INPUT_POST, 'robotstxt_smtp_test_email', FILTER_UNSAFE_RAW ); + + if ( is_string( $recipient_raw ) && '' !== $recipient_raw ) { + // Sanitize the recipient email address before attempting to send mail. + $recipient = sanitize_email( wp_unslash( $recipient_raw ) ); + } + + $result = $this->send_test_email_for_scope( $scope, $recipient, 'manual' ); + + $this->persist_test_result( $result ); + $this->redirect_after_test( ! empty( $result['success'] ) ? 'success' : 'error', (string) $result['recipient'], $scope ); + } + + /** + * Handles the updated_option hook for the site-level configuration. + * + * @param string $option Option name that was updated. + * @param mixed $old_value Previous option value. + * @param mixed $value New option value. + * + * @return void + */ + public function handle_settings_option_updated( string $option, $old_value, $value ): void { + unset( $old_value, $value ); + + if ( self::OPTION_NAME !== $option ) { + return; + } + + if ( ! is_admin() ) { + return; + } + + $nonce = filter_input( INPUT_POST, '_wpnonce', FILTER_UNSAFE_RAW ); + + if ( ! is_string( $nonce ) ) { + return; + } + + $nonce = sanitize_text_field( wp_unslash( $nonce ) ); + + if ( ! wp_verify_nonce( $nonce, self::SITE_SETTINGS_GROUP . '-options' ) ) { + return; + } + + $option_page = filter_input( INPUT_POST, 'option_page', FILTER_UNSAFE_RAW ); + + if ( ! is_string( $option_page ) ) { + return; + } + + $option_page = sanitize_key( wp_unslash( $option_page ) ); + + if ( self::SITE_SETTINGS_GROUP !== $option_page ) { + return; + } + + if ( ! current_user_can( self::CAPABILITY ) ) { + return; + } + + $this->cached_settings = null; + $this->site_settings_option_updated = true; + + $result = $this->send_test_email_for_scope( self::SCOPE_SITE, null, 'auto' ); + $this->persist_test_result( $result ); + } + + /** + * Sends the automatic test email when the site settings were submitted but + * the stored option value did not change. + * + * @return void + */ + public function maybe_send_pending_site_test(): void { + if ( ! $this->site_settings_submitted || $this->site_settings_option_updated ) { + return; + } + + if ( ! is_admin() ) { + return; + } + + $this->cached_settings = null; + + $result = $this->send_test_email_for_scope( self::SCOPE_SITE, null, 'auto' ); + $this->persist_test_result( $result ); + + $this->site_settings_submitted = false; + $this->site_settings_option_updated = false; + } + + + /** + * Sends a test email using the stored configuration for the provided scope. + * + * @param string $scope Scope identifier (site or network). + * @param string|null $recipient Optional recipient email address. + * @param string $context Context identifier (manual|auto). + * + * @return array Result data for the attempted email. + */ + private function send_test_email_for_scope( string $scope, ?string $recipient = null, string $context = 'manual' ): array { + $this->ensure_capability( $scope ); + $this->set_scope( $scope ); + + $resolved_recipient = $this->resolve_test_recipient( $recipient ); + $cache_key = 'robotstxt_smtp_test_' . md5( $scope . $resolved_recipient . $context ); + + $result = array( + 'success' => false, + 'recipient' => $resolved_recipient, + 'timestamp' => current_time( 'mysql' ), + 'settings' => $this->get_settings_for_display(), + 'debug_log' => array(), + 'mail_data' => array(), + 'error' => '', + 'error_data' => null, + 'context' => $context, + ); + + if ( empty( $resolved_recipient ) ) { + $result['error'] = __( 'A valid recipient email address is required.', 'robotstxt-smtp' ); + + return $result; + } + + $debug_log = array(); + $failure = null; + + $debug_action = static function ( PHPMailer $phpmailer ) use ( &$debug_log ): void { + // phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase + $phpmailer->SMTPDebug = 2; + $phpmailer->Debugoutput = static function ( string $message, int $level ) use ( &$debug_log ): void { + $debug_log[] = '[' . $level . '] ' . $message; + }; + // phpcs:enable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase + }; + + $failure_filter = static function ( WP_Error $error ) use ( &$failure ) { + $failure = $error; + return $error; + }; + + add_action( 'phpmailer_init', $debug_action, 20 ); + add_filter( 'wp_mail_failed', $failure_filter ); + + $subject = __( 'ROBOTSTXT SMTP Test Email', 'robotstxt-smtp' ); + $body = sprintf( + /* translators: %s: Site name. */ + __( 'This is a test email sent from %s using the ROBOTSTXT SMTP settings.', 'robotstxt-smtp' ), + get_bloginfo( 'name', 'display' ) + ); + + $headers = array( 'Content-Type: text/plain; charset=UTF-8' ); + + $sent = wp_mail( $resolved_recipient, $subject, $body, $headers ); + + remove_action( 'phpmailer_init', $debug_action, 20 ); + remove_filter( 'wp_mail_failed', $failure_filter ); + + if ( is_wp_error( $sent ) ) { + $result['success'] = false; + + if ( empty( $result['error'] ) ) { + $result['error'] = $sent->get_error_message(); + } + + if ( null === $result['error_data'] ) { + $result['error_data'] = $sent->get_error_data(); + } + } else { + $result['success'] = (bool) $sent; + } + + // Redact authentication credentials from debug log before storing. + $debug_log = array_map( array( $this, 'redact_smtp_credentials' ), $debug_log ); + $result['debug_log'] = $debug_log; + $result['mail_data'] = array( + 'subject' => $subject, + 'body' => $body, + 'headers' => $headers, + ); + + if ( $failure instanceof WP_Error ) { + $result['error'] = $failure->get_error_message(); + $result['error_data'] = $failure->get_error_data(); + } + + if ( ! $result['success'] && empty( $result['error'] ) ) { + $result['error'] = __( 'The test email could not be sent.', 'robotstxt-smtp' ); + } + + + return $result; + } + + /** + * Determines the recipient address to use for a test email. + * + * @param string|null $recipient Recipient provided by the user. + * + * @return string Sanitized recipient email address or an empty string when unavailable. + */ + private function resolve_test_recipient( ?string $recipient ): string { + if ( ! empty( $recipient ) ) { + $recipient = sanitize_email( $recipient ); + + if ( ! empty( $recipient ) && is_email( $recipient ) ) { + return $recipient; + } + } + + $current_user = wp_get_current_user(); + if ( $current_user instanceof WP_User && ! empty( $current_user->user_email ) ) { + $candidate = sanitize_email( $current_user->user_email ); + if ( ! empty( $candidate ) && is_email( $candidate ) ) { + return $candidate; + } + } + + $admin_email = sanitize_email( get_bloginfo( 'admin_email' ) ); + if ( ! empty( $admin_email ) && is_email( $admin_email ) ) { + return $admin_email; + } + + return ''; + } + + /** + * Displays the admin notice after sending a test email. + * + * @return void + */ + public function display_test_email_notice(): void { + if ( ! is_admin() ) { + return; + } + + $page = filter_input( INPUT_GET, 'page', FILTER_UNSAFE_RAW ); + + if ( null === $page ) { + return; + } + + $page = sanitize_key( $page ); + + if ( '' === $page || ! in_array( $page, array( self::TEST_PAGE_SLUG, self::PAGE_SLUG, self::NETWORK_PAGE_SLUG ), true ) ) { + return; + } + + $result = get_transient( $this->get_test_result_transient_key() ); + + if ( false === $result ) { + return; + } + + delete_transient( $this->get_test_result_transient_key() ); + + $class = ! empty( $result['success'] ) ? 'notice notice-success' : 'notice notice-error'; + + $context = isset( $result['context'] ) ? (string) $result['context'] : 'manual'; + + if ( 'auto' === $context ) { + $status = ! empty( $result['success'] ) + ? __( 'The SMTP configuration appears to be working correctly.', 'robotstxt-smtp' ) + : __( 'The SMTP configuration could not be verified.', 'robotstxt-smtp' ); + } else { + $status = ! empty( $result['success'] ) ? __( 'Test email sent successfully.', 'robotstxt-smtp' ) : __( 'Test email failed to send.', 'robotstxt-smtp' ); + } + ?> +
+

+ +

+ +

+ + +

+ +

+ + +

+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+										
+										
+
+ +
+ user_email ) ) { + $recipient = $current_user->user_email; + } + } + + if ( empty( $recipient ) ) { + $recipient = sanitize_email( get_bloginfo( 'admin_email' ) ); + } + + ?> +
+

+
+ + + + + + + + + + + + +
+ + */ + private function get_settings_for_display(): array { + $settings = $this->get_settings(); + + if ( ! empty( $settings['password'] ) ) { + $settings['password'] = str_repeat( '\u2022', 8 ); + } + + return $settings; + } + + /** + * Persists the test result for later display. + * + * @param array $result Result data. + * + * @return void + */ + private function persist_test_result( array $result ): void { + set_transient( $this->get_test_result_transient_key(), $result, MINUTE_IN_SECONDS * 10 ); + } + + /** + * Builds the transient key for the current user. + * + * @return string + */ + private function get_test_result_transient_key(): string { + return 'robotstxt_smtp_test_result_' . get_current_user_id(); + } + + /** + * Redirects the user back to the settings page after sending the test email. + * + * @param string $status The status string (success|error). + * @param string $recipient The recipient email address. + * @param string $scope Scope identifier (site or network). + * + * @return void + */ + private function redirect_after_test( string $status, string $recipient, string $scope ): void { + $redirect = add_query_arg( + array( + 'page' => self::TEST_PAGE_SLUG, + 'robotstxt_smtp_test' => $status, + 'robotstxt_smtp_recipient' => $recipient, + 'robotstxt_smtp_result_nonce' => wp_create_nonce( 'robotstxt_smtp_test_result' ), + ), + $this->get_admin_url_for_scope( $scope, 'admin.php' ) + ); + + wp_safe_redirect( $redirect ); + exit; + } + + /** + * Renders the statistics page. + * + * @return void + */ + public function render_stats_page(): void { + $scope = $this->get_current_admin_scope(); + + $this->ensure_capability( $scope ); + $this->set_scope( $scope ); + + // Get date range (default: last 30 days). + $days_raw = filter_input( INPUT_GET, 'days', FILTER_UNSAFE_RAW ); + $days = $days_raw ? absint( $days_raw ) : 30; + $days = max( 1, min( 365, $days ) ); // Between 1 and 365 days. + $end_date = current_time( 'Y-m-d' ); + $start_date = gmdate( 'Y-m-d', strtotime( "-{$days} days", strtotime( $end_date ) ) ); + + $stats = Statistics::get_instance(); + + // Determine if we're in multisite and should show per-site stats. + $is_multisite = ROBOTSTXT_SMTP_IS_MULTISITE; + $show_per_site = $is_multisite && self::SCOPE_NETWORK === $scope; + $current_blog_id = get_current_blog_id(); + + if ( $show_per_site ) { + // Network admin: show network stats and per-site breakdown. + $total_emails = $stats->get_total( $start_date, $end_date, null ); + $daily_stats = $stats->get_stats( $start_date, $end_date, null ); + $stats_by_blog = $stats->get_stats_by_blog( $start_date, $end_date ); + } else { + // Site admin or non-multisite: show current site stats only. + $total_emails = $stats->get_total( $start_date, $end_date, $current_blog_id ); + $daily_stats = $stats->get_stats( $start_date, $end_date, $current_blog_id ); + $stats_by_blog = array(); + } + + // Prepare daily chart data. + $chart_labels = array(); + $chart_data = array(); + $daily_map = array(); + + // Map daily stats by date. + foreach ( $daily_stats as $stat ) { + $date = $stat->date; + if ( ! isset( $daily_map[ $date ] ) ) { + $daily_map[ $date ] = 0; + } + $daily_map[ $date ] += (int) $stat->emails_sent; + } + + // Fill in all dates in range (even if zero). + $current_date = $start_date; + while ( $current_date <= $end_date ) { + $chart_labels[] = gmdate( 'M j', strtotime( $current_date ) ); + $chart_data[] = isset( $daily_map[ $current_date ] ) ? $daily_map[ $current_date ] : 0; + $current_date = gmdate( 'Y-m-d', strtotime( '+1 day', strtotime( $current_date ) ) ); + } + + ?> +
+

+ +
+
+ + + + +
+
+ +
+

+

+ + +

+

+ +

+
+ +
+

+
+ +
+
+ + +
+

+ + + + + + + + + + + blog_id ); + switch_to_blog( $blog_id ); + $blog_name = get_bloginfo( 'name' ); + $blog_url = get_home_url(); + restore_current_blog(); + ?> + + + + + + + +
+ + + + total_emails ) ) ); ?>
+
+ +
+ + + + $expected_codes Expected success codes. - * - * @return array - */ - public function execute_command( string $name, string $command_string, array $expected_codes = array( 250 ) ): array { - $this->last_command_timed_out = false; - $this->reset_error_state(); - - $expected = ! empty( $expected_codes ) ? array_map( 'intval', $expected_codes ) : array( 250 ); - - $success = parent::sendCommand( $name, $command_string, $expected ); - - if ( ! $success ) { - $this->last_command_timed_out = $this->error_indicates_timeout( parent::getError() ); - } - - return array( - 'success' => $success, - 'reply' => $this->getLastReply(), - 'timed_out' => $this->last_command_timed_out, - ); - } - - /** - * Indicates whether the last command timed out. - * - * @return bool - */ - public function did_last_command_timeout(): bool { - return $this->last_command_timed_out; - } - - /** - * Initiates STARTTLS while tracking timeout state. - * - * @return bool - */ - public function startTLS(): bool { - $this->last_command_timed_out = false; - $this->reset_error_state(); - - $result = parent::startTLS(); - - if ( ! $result ) { - $this->last_command_timed_out = $this->error_indicates_timeout( parent::getError() ); - } - - return $result; - } - - /** - * Clears the stored error state. - */ - private function reset_error_state(): void { - parent::setError( '' ); - } - - /** - * Determines whether an error array represents a timeout. - * - * @param array $error Error details. - * - * @return bool - */ - private function error_indicates_timeout( array $error ): bool { - foreach ( array( 'error', 'detail', 'smtp_code_ex' ) as $key ) { - if ( empty( $error[ $key ] ) ) { - continue; - } - - $value = (string) $error[ $key ]; - - if ( false !== stripos( $value, 'timed out' ) || false !== stripos( $value, 'timed-out' ) ) { - return true; - } - } - - return false; - } -} + $expected_codes Expected success codes. + * + * @return array + */ + public function execute_command( string $name, string $command_string, array $expected_codes = array( 250 ) ): array { + $this->last_command_timed_out = false; + $this->reset_error_state(); + + $expected = ! empty( $expected_codes ) ? array_map( 'intval', $expected_codes ) : array( 250 ); + + $success = parent::sendCommand( $name, $command_string, $expected ); + + if ( ! $success ) { + $this->last_command_timed_out = $this->error_indicates_timeout( parent::getError() ); + } + + return array( + 'success' => $success, + 'reply' => $this->getLastReply(), + 'timed_out' => $this->last_command_timed_out, + ); + } + + /** + * Indicates whether the last command timed out. + * + * @return bool + */ + public function did_last_command_timeout(): bool { + return $this->last_command_timed_out; + } + + /** + * Initiates STARTTLS while tracking timeout state. + * + * @return bool + */ + public function startTLS(): bool { + $this->last_command_timed_out = false; + $this->reset_error_state(); + + $result = parent::startTLS(); + + if ( ! $result ) { + $this->last_command_timed_out = $this->error_indicates_timeout( parent::getError() ); + } + + return $result; + } + + /** + * Clears the stored error state. + */ + private function reset_error_state(): void { + parent::setError( '' ); + } + + /** + * Determines whether an error array represents a timeout. + * + * @param array $error Error details. + * + * @return bool + */ + private function error_indicates_timeout( array $error ): bool { + foreach ( array( 'error', 'detail', 'smtp_code_ex' ) as $key ) { + if ( empty( $error[ $key ] ) ) { + continue; + } + + $value = (string) $error[ $key ]; + + if ( false !== stripos( $value, 'timed out' ) || false !== stripos( $value, 'timed-out' ) ) { + return true; + } + } + + return false; + } +} diff --git a/includes/class-statistics.php b/includes/class-statistics.php new file mode 100644 index 0000000..db9d116 --- /dev/null +++ b/includes/class-statistics.php @@ -0,0 +1,287 @@ +maybe_create_table(); + } + + /** + * Gets the full table name with WordPress prefix. + * + * @return string + */ + public static function get_table_name(): string { + global $wpdb; + return $wpdb->base_prefix . self::TABLE_NAME; + } + + /** + * Creates the statistics table if it doesn't exist. + * + * @return void + */ + private function maybe_create_table(): void { + $installed_version = get_site_option( self::DB_VERSION_OPTION, '0' ); + + if ( version_compare( $installed_version, self::DB_VERSION, '>=' ) ) { + return; + } + + global $wpdb; + $table_name = self::get_table_name(); + $charset_collate = $wpdb->get_charset_collate(); + + $sql = "CREATE TABLE {$table_name} ( + id bigint(20) unsigned NOT NULL AUTO_INCREMENT, + blog_id bigint(20) unsigned NOT NULL DEFAULT 1, + date date NOT NULL, + emails_sent bigint(20) unsigned NOT NULL DEFAULT 0, + PRIMARY KEY (id), + UNIQUE KEY blog_date (blog_id, date), + KEY date_idx (date), + KEY blog_id_idx (blog_id) + ) {$charset_collate};"; + + require_once ABSPATH . 'wp-admin/includes/upgrade.php'; + dbDelta( $sql ); + + update_site_option( self::DB_VERSION_OPTION, self::DB_VERSION ); + } + + /** + * Increments the email counter for today. + * + * @param int|null $blog_id Blog ID (defaults to current blog). + * + * @return bool True on success, false on failure. + */ + public function increment_today( ?int $blog_id = null ): bool { + global $wpdb; + + if ( null === $blog_id ) { + $blog_id = get_current_blog_id(); + } + + $table_name = self::get_table_name(); + $today = current_time( 'Y-m-d' ); + + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching + $result = $wpdb->query( + $wpdb->prepare( + "INSERT INTO {$table_name} (blog_id, date, emails_sent) + VALUES (%d, %s, 1) + ON DUPLICATE KEY UPDATE emails_sent = emails_sent + 1", + $blog_id, + $today + ) + ); + + return false !== $result; + } + + /** + * Gets statistics for a specific date range. + * + * @param string $start_date Start date (Y-m-d format). + * @param string $end_date End date (Y-m-d format). + * @param int|null $blog_id Blog ID (null for all sites). + * + * @return array Array of statistics objects. + */ + public function get_stats( string $start_date, string $end_date, ?int $blog_id = null ): array { + global $wpdb; + + $table_name = self::get_table_name(); + + if ( null !== $blog_id ) { + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching + $results = $wpdb->get_results( + $wpdb->prepare( + "SELECT blog_id, date, emails_sent + FROM {$table_name} + WHERE blog_id = %d + AND date BETWEEN %s AND %s + ORDER BY date ASC", + $blog_id, + $start_date, + $end_date + ) + ); + } else { + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching + $results = $wpdb->get_results( + $wpdb->prepare( + "SELECT blog_id, date, emails_sent + FROM {$table_name} + WHERE date BETWEEN %s AND %s + ORDER BY date ASC, blog_id ASC", + $start_date, + $end_date + ) + ); + } + + return is_array( $results ) ? $results : array(); + } + + /** + * Gets total emails sent for a date range. + * + * @param string $start_date Start date (Y-m-d format). + * @param string $end_date End date (Y-m-d format). + * @param int|null $blog_id Blog ID (null for all sites). + * + * @return int Total emails sent. + */ + public function get_total( string $start_date, string $end_date, ?int $blog_id = null ): int { + global $wpdb; + + $table_name = self::get_table_name(); + + if ( null !== $blog_id ) { + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching + $total = $wpdb->get_var( + $wpdb->prepare( + "SELECT SUM(emails_sent) + FROM {$table_name} + WHERE blog_id = %d + AND date BETWEEN %s AND %s", + $blog_id, + $start_date, + $end_date + ) + ); + } else { + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching + $total = $wpdb->get_var( + $wpdb->prepare( + "SELECT SUM(emails_sent) + FROM {$table_name} + WHERE date BETWEEN %s AND %s", + $start_date, + $end_date + ) + ); + } + + return absint( $total ); + } + + /** + * Gets statistics aggregated by blog for multisite. + * + * @param string $start_date Start date (Y-m-d format). + * @param string $end_date End date (Y-m-d format). + * + * @return array Array with blog_id and total_emails. + */ + public function get_stats_by_blog( string $start_date, string $end_date ): array { + global $wpdb; + + $table_name = self::get_table_name(); + + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching + $results = $wpdb->get_results( + $wpdb->prepare( + "SELECT blog_id, SUM(emails_sent) as total_emails + FROM {$table_name} + WHERE date BETWEEN %s AND %s + GROUP BY blog_id + ORDER BY total_emails DESC", + $start_date, + $end_date + ) + ); + + return is_array( $results ) ? $results : array(); + } + + /** + * Deletes statistics older than specified days. + * + * @param int $days Number of days to retain. + * + * @return int Number of rows deleted. + */ + public function cleanup_old_stats( int $days ): int { + global $wpdb; + + $table_name = self::get_table_name(); + $cutoff_date = gmdate( 'Y-m-d', strtotime( "-{$days} days" ) ); + + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching + $deleted = $wpdb->query( + $wpdb->prepare( + "DELETE FROM {$table_name} WHERE date < %s", + $cutoff_date + ) + ); + + return absint( $deleted ); + } +} diff --git a/languages/robotstxt-smtp-ca.mo b/languages/robotstxt-smtp-ca.mo new file mode 100644 index 0000000000000000000000000000000000000000..fda437aec7adef5d6d7af3a7f77213ff53454df4 GIT binary patch literal 33316 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 LrLA~sPg4Fn{gZ\n" +"Language-Team: Catalan\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Manual\n" + +#: includes/class-plugin.php:165 includes/class-settings-page.php:381 +#: includes/class-settings-page.php:446 includes/class-settings-page.php:2691 +msgid "SMTP Logs" +msgstr "Registres SMTP" + +#: includes/class-plugin.php:166 +msgid "SMTP Log" +msgstr "Registre SMTP" + +#: includes/class-plugin.php:457 +msgid "OpenSSL PHP extension is not loaded" +msgstr "L'extensió PHP OpenSSL no està carregada" + +#: includes/class-plugin.php:459 +msgid "AES-256-GCM cipher is not supported by OpenSSL" +msgstr "El xifratge AES-256-GCM no està suportat per OpenSSL" + +#: includes/class-plugin.php:463 +msgid "AUTH_KEY is not defined in wp-config.php" +msgstr "AUTH_KEY no està definida a wp-config.php" + +#: includes/class-plugin.php:467 +msgid "AUTH_SALT is not defined in wp-config.php" +msgstr "AUTH_SALT no està definida a wp-config.php" + +#: includes/class-plugin.php:486 +msgid "ROBOTSTXT SMTP: Credential Encryption Unavailable" +msgstr "ROBOTSTXT SMTP: Xifratge de credencials no disponible" + +#: includes/class-plugin.php:489 +msgid "" +"Your SMTP credentials are currently stored without encryption because the " +"following requirements are not met:" +msgstr "" +"Les teves credencials SMTP actualment s'emmagatzemen sense xifrar perquè no es compleixen " +"els següents requisits:" + +#. translators: %s: Link to WordPress security keys documentation +#: includes/class-plugin.php:500 +#, php-format +msgid "" +"To enable credential encryption, please ensure OpenSSL is installed and %s " +"are defined in your wp-config.php file." +msgstr "" +"Per activar el xifratge de credencials, assegura't que OpenSSL estigui instal·lat i %s " +"estiguin definides al teu arxiu wp-config.php." + +#: includes/class-plugin.php:501 +msgid "WordPress authentication keys" +msgstr "claus d'autenticació de WordPress" + +#: includes/class-plugin.php:507 +msgid "Dismiss for 7 days" +msgstr "Descartar durant 7 dies" + +#. translators: %d: rate limit per second +#: includes/class-plugin.php:1147 +#, php-format +msgid "Rate limit exceeded: Maximum %d emails per second." +msgstr "Límit de taxa excedit: Màxim %d emails per segon." + +#. translators: %d: rate limit per hour +#: includes/class-plugin.php:1163 +#, php-format +msgid "Rate limit exceeded: Maximum %d emails per hour." +msgstr "Límit de taxa excedit: Màxim %d emails per hora." + +#. translators: %d: rate limit per day +#: includes/class-plugin.php:1179 +#, php-format +msgid "Rate limit exceeded: Maximum %d emails per 24 hours." +msgstr "Límit de taxa excedit: Màxim %d emails per 24 hores." + +#: includes/class-settings-page.php:246 +msgid "You do not have permission to access this page." +msgstr "No tens permisos per accedir a aquesta pàgina." + +#. Plugin Name of the plugin/theme +#: includes/class-settings-page.php:344 includes/class-settings-page.php:354 +#: includes/class-settings-page.php:409 includes/class-settings-page.php:419 +#: includes/class-settings-page.php:1081 includes/class-settings-page.php:1106 +msgid "SMTP (by ROBOTSTXT)" +msgstr "SMTP (by ROBOTSTXT)" + +#: includes/class-settings-page.php:345 includes/class-settings-page.php:410 +msgid "SMTP" +msgstr "SMTP" + +#: includes/class-settings-page.php:355 includes/class-settings-page.php:420 +msgid "Settings" +msgstr "Configuració" + +#: includes/class-settings-page.php:363 includes/class-settings-page.php:428 +#: includes/class-settings-page.php:1277 +msgid "SMTP Test" +msgstr "Prova SMTP" + +#: includes/class-settings-page.php:364 includes/class-settings-page.php:429 +msgid "Test" +msgstr "Prova" + +#: includes/class-settings-page.php:372 includes/class-settings-page.php:437 +#: includes/class-settings-page.php:1344 +msgid "SMTP Tools" +msgstr "Eines SMTP" + +#: includes/class-settings-page.php:373 includes/class-settings-page.php:438 +msgid "Tools" +msgstr "Eines" + +#: includes/class-settings-page.php:382 includes/class-settings-page.php:447 +msgid "Logs" +msgstr "Registres" + +#: includes/class-settings-page.php:390 includes/class-settings-page.php:455 +#: includes/class-settings-page.php:5809 +msgid "Email Statistics" +msgstr "Estadístiques d'email" + +#: includes/class-settings-page.php:391 includes/class-settings-page.php:456 +msgid "Statistics" +msgstr "Estadístiques" + +#: includes/class-settings-page.php:496 +msgid "SMTP Server Configuration" +msgstr "Configuració del servidor SMTP" + +#: includes/class-settings-page.php:505 includes/class-settings-page.php:1174 +msgid "Email Log Settings" +msgstr "Configuració de registres d'email" + +#: includes/class-settings-page.php:514 +msgid "Statistics Settings" +msgstr "Configuració d'estadístiques" + +#: includes/class-settings-page.php:523 includes/class-settings-page.php:1181 +msgid "Rate Limiting" +msgstr "Limitació de taxa" + +#: includes/class-settings-page.php:640 +msgid "Emails per second" +msgstr "Emails per segon" + +#: includes/class-settings-page.php:646 +msgid "Emails per hour" +msgstr "Emails per hora" + +#: includes/class-settings-page.php:652 +msgid "Emails per day (24 hours)" +msgstr "Emails per dia (24 hores)" + +#: includes/class-settings-page.php:670 +msgid "" +"Rate limits are automatically configured from your Amazon SES account quotas." +msgstr "" +"Els límits de taxa es configuren automàticament des de les quotes del teu compte d'Amazon SES." + +#. translators: %s: Time elapsed since quotas were fetched +#: includes/class-settings-page.php:685 +#, php-format +msgid "Last updated from Amazon SES: %s ago" +msgstr "Última actualització des d'Amazon SES: fa %s" + +#: includes/class-settings-page.php:690 +msgid "Quotas not yet fetched from Amazon SES." +msgstr "Quotes encara no obtingudes des d'Amazon SES." + +#: includes/class-settings-page.php:715 +msgid "Refresh Quotas Now" +msgstr "Actualitzar quotes ara" + +#: includes/class-settings-page.php:723 +msgid "" +"Configure rate limits to control how many emails can be sent per time " +"period. Set to 0 for unlimited." +msgstr "" +"Configura límits de taxa per controlar quants emails es poden enviar per període de temps. " +"Estableix a 0 per il·limitat." + +#: includes/class-settings-page.php:747 includes/class-settings-page.php:798 +#: includes/class-settings-page.php:848 +msgid "Unlimited" +msgstr "Il·limitat" + +#: includes/class-settings-page.php:749 +msgid "Automatically set from Amazon SES MaxSendRate quota." +msgstr "Establert automàticament des de la quota MaxSendRate d'Amazon SES." + +#: includes/class-settings-page.php:754 includes/class-settings-page.php:805 +#: includes/class-settings-page.php:855 +msgid "Not available" +msgstr "No disponible" + +#: includes/class-settings-page.php:756 includes/class-settings-page.php:807 +#: includes/class-settings-page.php:857 +msgid "Unable to fetch quota from Amazon SES. Check IAM permissions." +msgstr "No es pot obtenir la quota des d'Amazon SES. Verifica els permisos IAM." + +#: includes/class-settings-page.php:773 +msgid "Maximum emails per second. 0 = unlimited." +msgstr "Màxim d'emails per segon. 0 = il·limitat." + +#: includes/class-settings-page.php:800 +msgid "" +"Automatically calculated as 90% of maximum throughput (MaxSendRate × 3600 × " +"0.9)." +msgstr "" +"Calculat automàticament com el 90% del rendiment màxim (MaxSendRate × 3600 × " +"0.9)." + +#: includes/class-settings-page.php:824 +msgid "Maximum emails per hour (rolling window). 0 = unlimited." +msgstr "Màxim d'emails per hora (finestra mòbil). 0 = il·limitat." + +#: includes/class-settings-page.php:850 +msgid "Automatically set from Amazon SES Max24HourSend quota." +msgstr "Establert automàticament des de la quota Max24HourSend d'Amazon SES." + +#: includes/class-settings-page.php:874 +msgid "" +"Maximum emails that can be sent per 24-hour period (rolling window). 0 = " +"unlimited." +msgstr "" +"Màxim d'emails que es poden enviar per període de 24 hores (finestra mòbil). 0 = " +"il·limitat." + +#: includes/class-settings-page.php:891 includes/class-settings-page.php:1687 +msgid "Host" +msgstr "Servidor" + +#: includes/class-settings-page.php:897 +msgid "Username" +msgstr "Nom d'usuari" + +#: includes/class-settings-page.php:903 +msgid "Password" +msgstr "Contrasenya" + +#: includes/class-settings-page.php:909 +msgid "From Email" +msgstr "Email remitent" + +#: includes/class-settings-page.php:915 +msgid "From Name" +msgstr "Nom remitent" + +#: includes/class-settings-page.php:921 +msgid "Reply-To Email" +msgstr "Email de resposta" + +#: includes/class-settings-page.php:927 +msgid "Reply-To Name" +msgstr "Nom de resposta" + +#: includes/class-settings-page.php:933 +msgid "Security Type" +msgstr "Tipus de seguretat" + +#: includes/class-settings-page.php:939 +msgid "Port" +msgstr "Port" + +#: includes/class-settings-page.php:967 +msgid "Enable logging" +msgstr "Activar registre" + +#: includes/class-settings-page.php:973 +msgid "Retention mode" +msgstr "Mode de retenció" + +#: includes/class-settings-page.php:978 +msgid "Maximum stored emails" +msgstr "Màxim d'emails emmagatzemats" + +#: includes/class-settings-page.php:984 includes/class-settings-page.php:1000 +msgid "Retention in days" +msgstr "Retenció en dies" + +#: includes/class-settings-page.php:1043 includes/class-settings-page.php:1159 +msgid "" +"Amazon SES integration is active. To configure SMTP manually, deactivate the " +"Amazon SES add-on." +msgstr "" +"La integració d'Amazon SES està activa. Per configurar SMTP manualment, desactiva el " +"complement d'Amazon SES." + +#: includes/class-settings-page.php:1049 +msgid "Configure the SMTP server used to deliver outgoing emails." +msgstr "Configura el servidor SMTP utilitzat per lliurar emails sortints." + +#: includes/class-settings-page.php:1058 +msgid "Control how email delivery logs are stored and pruned." +msgstr "Controla com s'emmagatzemen i netegen els registres de lliurament d'email." + +#: includes/class-settings-page.php:1067 +msgid "Configure how long email statistics are retained in the database." +msgstr "Configura quant de temps es retenen les estadístiques d'email a la base de dades." + +#: includes/class-settings-page.php:1086 includes/class-settings-page.php:1189 +msgid "Save Changes" +msgstr "Desar canvis" + +#: includes/class-settings-page.php:1121 +msgid "Settings saved." +msgstr "Configuració desada." + +#: includes/class-settings-page.php:1130 +msgid "Configuration scope" +msgstr "Àmbit de configuració" + +#: includes/class-settings-page.php:1131 +msgid "" +"Choose whether to manage the SMTP credentials globally or per individual " +"site." +msgstr "" +"Tria si gestionar les credencials SMTP globalment o per lloc individual." + +#: includes/class-settings-page.php:1135 +msgid "Mode" +msgstr "Mode" + +#: includes/class-settings-page.php:1140 +msgid "Global network configuration" +msgstr "Configuració global de xarxa" + +#: includes/class-settings-page.php:1145 +msgid "Configure each site individually" +msgstr "Configurar cada lloc individualment" + +#: includes/class-settings-page.php:1148 +msgid "" +"When configured globally, all sites in the network will reuse the settings " +"below." +msgstr "" +"Quan es configura globalment, tots els llocs de la xarxa reutilitzaran la configuració " +"de sota." + +#: includes/class-settings-page.php:1156 +msgid "Global SMTP settings" +msgstr "Configuració SMTP global" + +#: includes/class-settings-page.php:1164 +msgid "" +"These credentials are stored for later use but are only applied when the " +"global configuration mode is enabled." +msgstr "" +"Aquestes credencials s'emmagatzemen per a ús posterior però només s'apliquen quan el " +"mode de configuració global està activat." + +#: includes/class-settings-page.php:1204 +msgid "Network settings are only available on multisite installations." +msgstr "La configuració de xarxa només està disponible en instal·lacions multilloc." + +#: includes/class-settings-page.php:1213 includes/class-settings-page.php:3392 +#: includes/class-settings-page.php:5267 +msgid "The link you followed has expired." +msgstr "L'enllaç que has seguit ha caducat." + +#: includes/class-settings-page.php:1280 +msgid "" +"The network configuration is currently disabled. Tests will use the site-" +"specific settings stored below." +msgstr "" +"La configuració de xarxa està actualment desactivada. Les proves usaran la configuració " +"específica del lloc emmagatzemada a sota." + +#: includes/class-settings-page.php:1319 +msgid "Automatic MX Lookup" +msgstr "Cerca automàtica de MX" + +#: includes/class-settings-page.php:1320 +msgid "" +"Detects the domain from the configured sender address, retrieves its MX " +"records, and compares them with the SMTP host." +msgstr "" +"Detecta el domini des de l'adreça del remitent configurada, obté els seus registres MX " +"i els compara amb el servidor SMTP." + +#: includes/class-settings-page.php:1324 +msgid "SPF, DKIM, and DMARC Validation" +msgstr "Validació de SPF, DKIM i DMARC" + +#: includes/class-settings-page.php:1325 +msgid "" +"Checks common DNS TXT records for the sender domain to help you verify email " +"authentication." +msgstr "" +"Verifica registres TXT DNS comuns per al domini del remitent per ajudar-te a verificar " +"l'autenticació d'email." + +#: includes/class-settings-page.php:1329 +msgid "Extended SMTP Diagnostics" +msgstr "Diagnòstics SMTP estesos" + +#: includes/class-settings-page.php:1330 +msgid "" +"Reuses the configured SMTP connection to inspect the server greeting, TLS " +"support, available authentication mechanisms, and EHLO/HELO response codes." +msgstr "" +"Reutilitza la connexió SMTP configurada per inspeccionar la salutació del servidor, suport TLS, " +"mecanismes d'autenticació disponibles i codis de resposta EHLO/HELO." + +#: includes/class-settings-page.php:1334 +msgid "Blacklist Lookup" +msgstr "Cerca en llistes negres" + +#: includes/class-settings-page.php:1335 +msgid "" +"Checks the SMTP host IP address against well-known DNS-based reputation " +"lists. Use the feature responsibly and respect each provider's terms of use." +msgstr "" +"Verifica l'adreça IP del servidor SMTP contra llistes de reputació basades en DNS conegudes. " +"Usa la funció responsablement i respecta els termes d'ús de cada proveïdor." + +#: includes/class-settings-page.php:1348 +msgid "" +"The network configuration is currently disabled. Tools will use the site-" +"specific settings stored below." +msgstr "" +"La configuració de xarxa està actualment desactivada. Les eines usaran la configuració " +"específica del lloc emmagatzemada a sota." + +#. translators: %s: Human-readable timestamp of the last check. +#: includes/class-settings-page.php:1382 +#, php-format +msgid "Last checked: %s" +msgstr "Última comprovació: %s" + +#: includes/class-settings-page.php:1391 +msgid "Run checks again" +msgstr "Executar comprovacions de nou" + +#: includes/class-settings-page.php:1400 +msgid "There are no results yet. Click the button below to run this check." +msgstr "Encara no hi ha resultats. Fes clic al botó de sota per executar aquesta comprovació." + +#: includes/class-settings-page.php:1405 +msgid "Run checks" +msgstr "Executar comprovacions" + +#: includes/class-settings-page.php:1649 +msgid "" +"Configure a \"From Email\" address in the settings to analyze the MX records." +msgstr "" +"Configura una adreça \"Email remitent\" a la configuració per analitzar els registres MX." + +#: includes/class-settings-page.php:1655 +msgid "Domain:" +msgstr "Domini:" + +#: includes/class-settings-page.php:1658 +msgid "Configured SMTP host:" +msgstr "Servidor SMTP configurat:" + +#: includes/class-settings-page.php:1659 +msgid "Not configured" +msgstr "No configurat" + +#: includes/class-settings-page.php:1663 +msgid "The MX lookup could not be completed:" +msgstr "La cerca MX no s'ha pogut completar:" + +#. translators: %s: Domain name extracted from the sender email address. +#: includes/class-settings-page.php:1676 +#, php-format +msgid "No MX records were found for %s." +msgstr "No s'han trobat registres MX per a %s." + +#: includes/class-settings-page.php:1686 +msgid "Priority" +msgstr "Prioritat" + +#: includes/class-settings-page.php:1688 +msgid "Resolves" +msgstr "Resol" + +#: includes/class-settings-page.php:1689 +msgid "Matches SMTP host" +msgstr "Coincideix amb servidor SMTP" + +#: includes/class-settings-page.php:1700 includes/class-settings-page.php:1713 +msgid "Yes" +msgstr "Sí" + +#: includes/class-settings-page.php:1702 includes/class-settings-page.php:1715 +msgid "No" +msgstr "No" + +#: includes/class-settings-page.php:1704 +msgid "Unknown" +msgstr "Desconegut" + +#: includes/class-settings-page.php:1735 +msgid "Some MX records could not be resolved to an A or AAAA record:" +msgstr "Alguns registres MX no s'han pogut resoldre a un registre A o AAAA:" + +#. translators: %s: Configured SMTP host. +#: includes/class-settings-page.php:1751 +#, php-format +msgid "" +"At least one MX record points to %s, which matches the configured SMTP host." +msgstr "" +"Almenys un registre MX apunta a %s, que coincideix amb el servidor SMTP configurat." + +#. translators: %s: Configured SMTP host. +#: includes/class-settings-page.php:1763 +#, php-format +msgid "None of the MX records point to %s, which is the configured SMTP host." +msgstr "Cap dels registres MX apunta a %s, que és el servidor SMTP configurat." + +#: includes/class-settings-page.php:1772 +msgid "Configure an SMTP host to compare it against the MX records." +msgstr "Configura un servidor SMTP per comparar-lo contra els registres MX." + +#: includes/class-settings-page.php:1805 +msgid "Configure an SMTP host in the settings to run the diagnostics." +msgstr "Configura un servidor SMTP a la configuració per executar els diagnòstics." + +#: includes/class-settings-page.php:1839 +msgid "Server:" +msgstr "Servidor:" + +#: includes/class-settings-page.php:1842 +msgid "Configured security:" +msgstr "Seguretat configurada:" + +#: includes/class-settings-page.php:1848 +msgid "Server banner:" +msgstr "Banner del servidor:" + +#. translators: %s: SMTP server response code. +#: includes/class-settings-page.php:1856 +#, php-format +msgid "code %s" +msgstr "codi %s" + +#: includes/class-settings-page.php:1866 +msgid "TLS status" +msgstr "Estat TLS" + +#: includes/class-settings-page.php:1871 +msgid "The connection uses implicit TLS (SMTPS)." +msgstr "La connexió usa TLS implícit (SMTPS)." + +#: includes/class-settings-page.php:1873 +msgid "The STARTTLS negotiation succeeded and the connection is encrypted." +msgstr "La negociació STARTTLS ha tingut èxit i la connexió està xifrada." + +#: includes/class-settings-page.php:1875 +msgid "The server accepted the TLS negotiation." +msgstr "El servidor ha acceptat la negociació TLS." + +#: includes/class-settings-page.php:1878 +msgid "TLS is not active for this connection." +msgstr "TLS no està actiu per a aquesta connexió." + +#: includes/class-settings-page.php:1885 +msgid "STARTTLS response:" +msgstr "Resposta STARTTLS:" + +#: includes/class-settings-page.php:1899 +msgid "Authentication mechanisms" +msgstr "Mecanismes d'autenticació" + +#: includes/class-settings-page.php:1907 +msgid "The server did not announce authentication mechanisms." +msgstr "El servidor no ha anunciat mecanismes d'autenticació." + +#: includes/class-settings-page.php:1910 +msgid "EHLO response" +msgstr "Resposta EHLO" + +#: includes/class-settings-page.php:1913 includes/class-settings-page.php:1929 +#: includes/class-settings-page.php:1944 +msgid "Status code:" +msgstr "Codi d'estat:" + +#: includes/class-settings-page.php:1926 +msgid "EHLO after STARTTLS" +msgstr "EHLO després de STARTTLS" + +#: includes/class-settings-page.php:1941 +msgid "HELO response" +msgstr "Resposta HELO" + +#: includes/class-settings-page.php:1959 +msgid "View raw transcript" +msgstr "Veure transcripció completa" + +#: includes/class-settings-page.php:2029 +msgid "A valid SMTP host is required to run diagnostics." +msgstr "Es requereix un servidor SMTP vàlid per executar els diagnòstics." + +#: includes/class-settings-page.php:2085 +msgid "Unknown error" +msgstr "Error desconegut" + +#. translators: 1: Error message. 2: Error code. +#: includes/class-settings-page.php:2090 +#, php-format +msgid "Connection failed: %1$s (%2$d)." +msgstr "Ha fallat la connexió: %1$s (%2$d)." + +#: includes/class-settings-page.php:2111 +msgid "The server greeting returned an unexpected status code." +msgstr "La salutació del servidor ha retornat un codi d'estat inesperat." + +#: includes/class-settings-page.php:2125 +msgid "The EHLO response could not be parsed." +msgstr "No s'ha pogut analitzar la resposta EHLO." + +#: includes/class-settings-page.php:2127 +msgid "The server did not accept the EHLO command." +msgstr "El servidor no ha acceptat la comanda EHLO." + +#: includes/class-settings-page.php:2132 +msgid "The server did not advertise STARTTLS support." +msgstr "El servidor no ha anunciat suport per a STARTTLS." + +#: includes/class-settings-page.php:2151 +msgid "The TLS negotiation failed after STARTTLS." +msgstr "La negociació TLS ha fallat després de STARTTLS." + +#: includes/class-settings-page.php:2157 +msgid "" +"The server supports STARTTLS. Enable TLS in the configuration to protect the " +"connection." +msgstr "" +"El servidor suporta STARTTLS. Activa TLS a la configuració per protegir la " +"connexió." + +#: includes/class-settings-page.php:2161 +msgid "No authentication mechanisms were advertised by the server." +msgstr "El servidor no ha anunciat mecanismes d'autenticació." + +#: includes/class-settings-page.php:2172 +msgid "The legacy HELO command did not return a successful status code." +msgstr "La comanda HELO heretada no ha retornat un codi d'estat exitós." + +#: includes/class-settings-page.php:2180 +msgid "The connection is not encrypted. Credentials may travel in plain text." +msgstr "La connexió no està xifrada. Les credencials poden viatjar en text pla." + +#: includes/class-settings-page.php:2356 +msgid "" +"Configure a \"From Email\" address in the settings to analyze SPF, DKIM, and " +"DMARC records." +msgstr "" +"Configura una adreça \"Email remitent\" a la configuració per analitzar registres SPF, DKIM " +"i DMARC." + +#: includes/class-settings-page.php:2374 +msgid "SPF" +msgstr "SPF" + +#: includes/class-settings-page.php:2386 +msgid "No SPF record was found for the sender domain." +msgstr "No s'ha trobat registre SPF per al domini del remitent." + +#: includes/class-settings-page.php:2410 +msgid "DKIM" +msgstr "DKIM" + +#: includes/class-settings-page.php:2422 +msgid "A DKIM record was found for the default selector." +msgstr "S'ha trobat un registre DKIM per al selector per defecte." + +#: includes/class-settings-page.php:2429 +msgid "" +"No DKIM record was found for the default selector. Confirm the selector " +"provided by your email service and publish the corresponding TXT record." +msgstr "" +"No s'ha trobat registre DKIM per al selector per defecte. Confirma el selector " +"proporcionat pel teu servei d'email i publica el registre TXT corresponent." + +#: includes/class-settings-page.php:2433 +msgid "DMARC" +msgstr "DMARC" + +#: includes/class-settings-page.php:2445 +msgid "No DMARC record was found for the sender domain." +msgstr "No s'ha trobat registre DMARC per al domini del remitent." + +#. translators: %s: DMARC policy value. +#: includes/class-settings-page.php:2455 +#, php-format +msgid "Published policy: %s" +msgstr "Política publicada: %s" + +#: includes/class-settings-page.php:2472 +msgid "The DMARC policy enforces protection for the domain." +msgstr "La política DMARC aplica protecció per al domini." + +#: includes/class-settings-page.php:2515 +msgid "" +"IPv6 addresses are currently not checked because most DNSBL providers only " +"publish IPv4 data. Verify IPv6 reputation manually with your email service." +msgstr "" +"Les adreces IPv6 actualment no es verifiquen perquè la majoria de proveïdors DNSBL només " +"publiquen dades IPv4. Verifica la reputació IPv6 manualment amb el teu servei d'email." + +#: includes/class-settings-page.php:2523 +msgid "" +"The SMTP host did not resolve to any IPv4 addresses. Configure a valid host " +"or allow DNS lookups on the server to perform blacklist checks." +msgstr "" +"El servidor SMTP no ha resolt a cap adreça IPv4. Configura un servidor vàlid " +"o permet cerques DNS al servidor per realitzar comprovacions de llistes negres." + +#. translators: %s: IP address used for the blacklist lookup. +#: includes/class-settings-page.php:2533 +#, php-format +msgid "IP address: %s" +msgstr "Adreça IP: %s" + +#: includes/class-settings-page.php:2552 +msgid "Provider" +msgstr "Proveïdor" + +#: includes/class-settings-page.php:2553 includes/class-settings-page.php:3115 +#: includes/class-settings-page.php:3290 +msgid "Status" +msgstr "Estat" + +#: includes/class-settings-page.php:2554 +msgid "Impact" +msgstr "Impacte" + +#: includes/class-settings-page.php:2555 +msgid "Details" +msgstr "Detalls" + +#: includes/class-settings-page.php:2556 +msgid "Removal guidance" +msgstr "Guia d'eliminació" + +#: includes/class-settings-page.php:2569 +msgid "Unavailable" +msgstr "No disponible" + +#: includes/class-settings-page.php:2571 +msgid "Listed" +msgstr "Llistat" + +#: includes/class-settings-page.php:2573 +msgid "Not listed" +msgstr "No llistat" + +#: includes/class-settings-page.php:2584 +msgid "Response:" +msgstr "Resposta:" + +#: includes/class-settings-page.php:2596 +msgid "No additional TXT details were returned by the provider." +msgstr "El proveïdor no ha retornat detalls TXT addicionals." + +#: includes/class-settings-page.php:2599 +msgid "The IP address is not currently listed by this provider." +msgstr "L'adreça IP no està actualment llistada per aquest proveïdor." + +#: includes/class-settings-page.php:2608 +msgid "Open removal request page" +msgstr "Obrir pàgina de sol·licitud d'eliminació" + +#: includes/class-settings-page.php:2695 +msgid "The link you followed has expired. Please try again." +msgstr "L'enllaç que has seguit ha caducat. Si us plau, intenta de nou." + +#: includes/class-settings-page.php:2701 +msgid "All log entries were removed." +msgstr "S'han eliminat totes les entrades de registre." + +#: includes/class-settings-page.php:2707 +msgid "" +"Log entries are stored per site. The table below reflects the currently " +"selected site." +msgstr "" +"Les entrades de registre s'emmagatzemen per lloc. La taula de sota reflecteix el lloc " +"actualment seleccionat." + +#: includes/class-settings-page.php:2713 +msgid "" +"Logging is currently disabled. Enable it in the settings page to store new " +"emails." +msgstr "" +"El registre està actualment desactivat. Activa'l a la pàgina de configuració per emmagatzemar nous " +"emails." + +#: includes/class-settings-page.php:3054 +msgid "From date" +msgstr "Des de data" + +#: includes/class-settings-page.php:3058 +msgid "To date" +msgstr "Fins a data" + +#: includes/class-settings-page.php:3062 includes/class-settings-page.php:3118 +#: includes/class-settings-page.php:3306 +msgid "Subject" +msgstr "Assumpte" + +#: includes/class-settings-page.php:3066 includes/class-settings-page.php:3117 +#: includes/class-settings-page.php:3302 +msgid "To" +msgstr "Per a" + +#: includes/class-settings-page.php:3070 +msgid "Results per page" +msgstr "Resultats per pàgina" + +#: includes/class-settings-page.php:3078 +msgid "Apply filters" +msgstr "Aplicar filtres" + +#: includes/class-settings-page.php:3081 +msgid "Reset" +msgstr "Restablir" + +#: includes/class-settings-page.php:3092 +msgid "Are you sure you want to delete all log entries?" +msgstr "Estàs segur que vols eliminar totes les entrades de registre?" + +#: includes/class-settings-page.php:3094 +msgid "Clear Logs" +msgstr "Netejar registres" + +#: includes/class-settings-page.php:3107 +msgid "No email logs have been stored yet." +msgstr "Encara no s'han emmagatzemat registres d'email." + +#: includes/class-settings-page.php:3114 includes/class-settings-page.php:3286 +msgid "Date" +msgstr "Data" + +#: includes/class-settings-page.php:3116 includes/class-settings-page.php:3298 +msgid "From" +msgstr "De" + +#: includes/class-settings-page.php:3119 +msgid "Actions" +msgstr "Accions" + +#: includes/class-settings-page.php:3127 includes/class-settings-page.php:3209 +msgid "(No subject)" +msgstr "(Sense assumpte)" + +#: includes/class-settings-page.php:3157 +msgid "View details" +msgstr "Veure detalls" + +#: includes/class-settings-page.php:3172 +msgid "«" +msgstr "«" + +#: includes/class-settings-page.php:3173 +msgid "»" +msgstr "»" + +#: includes/class-settings-page.php:3198 +msgid "The requested log entry could not be found." +msgstr "No s'ha pogut trobar l'entrada de registre sol·licitada." + +#: includes/class-settings-page.php:3281 +msgid "Back to list" +msgstr "Tornar al llistat" + +#: includes/class-settings-page.php:3310 +msgid "Error message" +msgstr "Missatge d'error" + +#: includes/class-settings-page.php:3316 +msgid "No error recorded." +msgstr "No s'ha registrat cap error." + +#: includes/class-settings-page.php:3324 +msgid "Headers" +msgstr "Capçaleres" + +#: includes/class-settings-page.php:3325 +msgid "No headers stored for this email." +msgstr "No s'han emmagatzemat capçaleres per a aquest email." + +#: includes/class-settings-page.php:3327 +msgid "Attachments" +msgstr "Adjunts" + +#: includes/class-settings-page.php:3335 +msgid "No attachments were logged for this email." +msgstr "No s'han registrat adjunts per a aquest email." + +#: includes/class-settings-page.php:3338 +msgid "Message content" +msgstr "Contingut del missatge" + +#: includes/class-settings-page.php:3342 +msgid "This email did not include any content." +msgstr "Aquest email no incloïa cap contingut." + +#: includes/class-settings-page.php:3345 +msgid "SMTP debug log" +msgstr "Registre de depuració SMTP" + +#: includes/class-settings-page.php:3348 +msgid "Show SMTP conversation" +msgstr "Mostrar conversa SMTP" + +#: includes/class-settings-page.php:3352 +msgid "No SMTP debug output was stored for this email." +msgstr "No s'ha emmagatzemat sortida de depuració SMTP per a aquest email." + +#: includes/class-settings-page.php:3370 +msgid "Failed" +msgstr "Fallat" + +#: includes/class-settings-page.php:3377 +msgid "Sent" +msgstr "Enviat" + +#. translators: 1: Example SMTP host. 2: Example SMTP host. +#: includes/class-settings-page.php:3445 +#, php-format +msgid "" +"Use the fully qualified address of your SMTP server, for example %1$s or " +"%2$s." +msgstr "" +"Usa l'adreça completa del teu servidor SMTP, per exemple %1$s o " +"%2$s." + +#: includes/class-settings-page.php:3470 +msgid "" +"Usually this is the full email address or dedicated SMTP user provided by " +"your email service." +msgstr "" +"Usualment aquesta és l'adreça d'email completa o l'usuari SMTP dedicat proporcionat pel " +"teu servei d'email." + +#: includes/class-settings-page.php:3482 +msgid "Leave empty to keep the current password." +msgstr "Deixar buit per mantenir la contrasenya actual." + +#: includes/class-settings-page.php:3493 +msgid "" +"Enter the password or app-specific password for the SMTP user. Leave empty " +"to retain the existing value." +msgstr "" +"Introdueix la contrasenya o contrasenya específica d'aplicació per a l'usuari SMTP. Deixa buit " +"per mantenir el valor existent." + +#: includes/class-settings-page.php:3513 +msgid "" +"This address will be used as the default sender for emails sent by " +"WordPress, for example notifications@example.com." +msgstr "" +"Aquesta adreça s'usarà com a remitent per defecte per a emails enviats per " +"WordPress, per exemple notificacions@example.com." + +#: includes/class-settings-page.php:3532 +msgid "" +"Recipients will see this name alongside the email address, such as \"Support " +"Team\" or the site title." +msgstr "" +"Els destinataris veuran aquest nom al costat de l'adreça d'email, com ara \"Equip de " +"suport\" o el títol del lloc." + +#: includes/class-settings-page.php:3552 +msgid "" +"Optional. Email address where replies should be sent. If empty, replies will " +"go to the From Email address." +msgstr "" +"Opcional. Adreça d'email on han d'enviar-se les respostes. Si està buit, les respostes aniran " +"a l'adreça Email remitent." + +#: includes/class-settings-page.php:3571 +msgid "" +"Optional. Name that will appear with the Reply-To address. If empty, the " +"From Name will be used." +msgstr "" +"Opcional. Nom que apareixerà amb l'adreça de resposta. Si està buit, s'usarà el " +"Nom remitent." + +#: includes/class-settings-page.php:3589 +msgid "" +"Choose the encryption method recommended by your provider. The default ports " +"are 25 for None, 465 for SSL, and 587 for TLS." +msgstr "" +"Tria el mètode de xifratge recomanat pel teu proveïdor. Els ports per defecte " +"són 25 per a Cap, 465 per a SSL i 587 per a TLS." + +#: includes/class-settings-page.php:3610 +msgid "" +"Set the port required by your SMTP server. Common values are 25 (None), 465 " +"(SSL), and 587 (TLS)." +msgstr "" +"Estableix el port requerit pel teu servidor SMTP. Els valors comuns són 25 (Cap), 465 " +"(SSL) i 587 (TLS)." + +#: includes/class-settings-page.php:3630 +msgid "Store a copy of every sent email in the logs." +msgstr "Emmagatzemar una còpia de cada email enviat als registres." + +#: includes/class-settings-page.php:3632 +msgid "" +"Logged emails are saved as private posts under SMTP Logs so you can review " +"the content or clear them at any time." +msgstr "" +"Els emails registrats es desen com a entrades privades a Registres SMTP perquè puguis revisar " +"el contingut o netejar-los en qualsevol moment." + +#: includes/class-settings-page.php:3653 +msgid "Limit by number of emails" +msgstr "Limitar per nombre d'emails" + +#: includes/class-settings-page.php:3663 +msgid "Limit by age (in days)" +msgstr "Limitar per antiguitat (en dies)" + +#: includes/class-settings-page.php:3666 +msgid "" +"Select how the log cleaner should decide which entries to remove: by keeping " +"a fixed number or by removing items older than a number of days." +msgstr "" +"Selecciona com el netejador de registres ha de decidir quines entrades eliminar: mantenint " +"un nombre fix o eliminant elements més antics que un nombre de dies." + +#: includes/class-settings-page.php:3686 +msgid "" +"Maximum number of emails to keep when using the count-based retention mode." +msgstr "" +"Nombre màxim d'emails a mantenir quan s'usa el mode de retenció basat en recompte." + +#: includes/class-settings-page.php:3706 +msgid "" +"Number of days to keep log entries when using the time-based retention mode." +msgstr "" +"Nombre de dies per mantenir entrades de registre quan s'usa el mode de retenció basat en temps." + +#: includes/class-settings-page.php:3727 +msgid "" +"Number of days to keep email statistics. Statistics older than this will be " +"automatically deleted daily. Minimum: 1 day, Maximum: 365 days." +msgstr "" +"Nombre de dies per mantenir estadístiques d'email. Les estadístiques més antigues que això " +"s'eliminaran automàticament diàriament. Mínim: 1 dia, Màxim: 365 dies." + +#: includes/class-settings-page.php:3848 +msgid "" +"The \"From Email\" address is not valid. Please provide a valid email " +"address." +msgstr "" +"L'adreça \"Email remitent\" no és vàlida. Si us plau, proporciona una adreça d'email " +"vàlida." + +#: includes/class-settings-page.php:3865 +msgid "" +"The \"Reply-To Email\" address is not valid. Please provide a valid email " +"address." +msgstr "" +"L'adreça \"Email de resposta\" no és vàlida. Si us plau, proporciona una adreça d'email " +"vàlida." + +#: includes/class-settings-page.php:3885 +msgid "" +"The AWS Access Key format is invalid. It should start with AKIA followed by " +"16 alphanumeric characters." +msgstr "" +"El format de la clau d'accés AWS és invàlid. Ha de començar amb AKIA seguit de " +"16 caràcters alfanumèrics." + +#: includes/class-settings-page.php:3900 +msgid "" +"The AWS Secret Key format is invalid. It should be 40 characters of base64-" +"encoded data." +msgstr "" +"El format de la clau secreta AWS és invàlid. Ha de ser de 40 caràcters codificats en " +"base64." + +#. translators: %d: Invalid port number entered by user +#: includes/class-settings-page.php:3948 +#, php-format +msgid "" +"The port number \"%d\" is invalid. Port must be between 1 and 65535. Using " +"default port 25." +msgstr "" +"El número de port \"%d\" és invàlid. El port ha d'estar entre 1 i 65535. Usant " +"port per defecte 25." + +#. translators: %s: IP address +#: includes/class-settings-page.php:4102 +#, php-format +msgid "" +"The SMTP hostname resolves to a private IP address (%s) which is not allowed " +"for security reasons. If you need to connect to a local SMTP server in " +"development, add this to wp-config.php: " +"define( 'ROBOTSTXT_SMTP_ALLOW_PRIVATE_IPS', true );" +msgstr "" +"El nom del servidor SMTP resol a una adreça IP privada (%s) que no està permesa " +"per raons de seguretat. Si necessites connectar-te a un servidor SMTP local en " +"desenvolupament, afegeix això a wp-config.php: " +"define( 'ROBOTSTXT_SMTP_ALLOW_PRIVATE_IPS', true );" + +#: includes/class-settings-page.php:4292 +msgid "The sender domain could not be determined." +msgstr "No s'ha pogut determinar el domini del remitent." + +#: includes/class-settings-page.php:4298 includes/class-settings-page.php:4588 +#: includes/class-settings-page.php:4988 includes/class-settings-page.php:5037 +msgid "" +"DNS lookups are not available because the DNS functions are disabled on this " +"server." +msgstr "" +"Les cerques DNS no estan disponibles perquè les funcions DNS estan desactivades en aquest " +"servidor." + +#: includes/class-settings-page.php:4329 +msgid "" +"Blacklist lookups are not available because the DNS functions are disabled " +"on this server." +msgstr "" +"Les cerques en llistes negres no estan disponibles perquè les funcions DNS estan desactivades " +"en aquest servidor." + +#: includes/class-settings-page.php:4374 +msgid "Spamhaus ZEN" +msgstr "Spamhaus ZEN" + +#: includes/class-settings-page.php:4376 +msgid "" +"High — major inbox providers rely on Spamhaus and a listing can block most " +"traffic." +msgstr "" +"Alt — els principals proveïdors de safates d'entrada confien en Spamhaus i una inclusió pot bloquejar la majoria del " +"trànsit." + +#: includes/class-settings-page.php:4378 +msgid "" +"Investigate and resolve the root cause, then use the Spamhaus Blocklist " +"Removal Center to request delisting." +msgstr "" +"Investiga i resol la causa arrel, després usa el Centre d'eliminació de llistes de bloqueig de Spamhaus " +"per sol·licitar l'eliminació." + +#: includes/class-settings-page.php:4382 +msgid "SpamCop" +msgstr "SpamCop" + +#: includes/class-settings-page.php:4384 +msgid "" +"Medium — many shared hosts and spam filters consult SpamCop when scoring " +"messages." +msgstr "" +"Mitjà — molts hosts compartits i filtres de spam consulten SpamCop en puntuar " +"missatges." + +#: includes/class-settings-page.php:4386 +msgid "" +"Ensure no unsolicited traffic is sent and follow the SpamCop blocklist " +"removal instructions." +msgstr "" +"Assegura't que no s'enviï trànsit no sol·licitat i segueix les instruccions d'eliminació de la llista de bloqueig de " +"SpamCop." + +#: includes/class-settings-page.php:4390 +msgid "Barracuda Reputation Block List" +msgstr "Llista de bloqueig de reputació Barracuda" + +#: includes/class-settings-page.php:4392 +msgid "" +"Medium — Barracuda appliances and some hosted filters can defer or reject " +"messages." +msgstr "" +"Mitjà — els dispositius Barracuda i alguns filtres allotjats poden diferir o rebutjar " +"missatges." + +#: includes/class-settings-page.php:4394 +msgid "" +"Review the Barracuda reputation lookup and submit a delisting request after " +"addressing any spam complaints." +msgstr "" +"Revisa la cerca de reputació de Barracuda i envia una sol·licitud d'eliminació després " +"d'abordar qualsevol queixa de spam." + +#: includes/class-settings-page.php:4502 +msgid "The IP address could not be normalized for the DNSBL lookup." +msgstr "L'adreça IP no s'ha pogut normalitzar per a la cerca DNSBL." + +#. translators: %s: DNSBL provider name. +#. translators: %s: Domain queried for the DKIM record lookup. +#. translators: %s: Domain queried for the DMARC record lookup. +#: includes/class-settings-page.php:4513 includes/class-settings-page.php:4998 +#: includes/class-settings-page.php:5047 +#, php-format +msgid "The DNS lookup for %s failed. Please try again later." +msgstr "La cerca DNS per a %s ha fallat. Si us plau, intenta-ho de nou més tard." + +#: includes/class-settings-page.php:4584 +msgid "" +"Unable to determine whether the SMTP host is authorized in the SPF record." +msgstr "" +"No es pot determinar si el servidor SMTP està autoritzat al registre SPF." + +#: includes/class-settings-page.php:4596 +msgid "The DNS lookup for TXT records failed. Please try again later." +msgstr "La cerca DNS de registres TXT ha fallat. Si us plau, intenta-ho de nou més tard." + +#: includes/class-settings-page.php:4614 +msgid "The domain does not publish an SPF record." +msgstr "El domini no publica un registre SPF." + +#: includes/class-settings-page.php:4621 +msgid "Configure an SMTP host to verify its presence in the SPF record." +msgstr "Configura un servidor SMTP per verificar la seva presència al registre SPF." + +#. translators: %s: Included SPF domain. +#: includes/class-settings-page.php:4677 +#, php-format +msgid "The SPF record includes %s, which matches the configured SMTP host." +msgstr "El registre SPF inclou %s, que coincideix amb el servidor SMTP configurat." + +#. translators: %s: Hostname authorized via the SPF "a" mechanism. +#: includes/class-settings-page.php:4690 includes/class-settings-page.php:4701 +#, php-format +msgid "The SPF record authorizes %s via the \"a\" mechanism." +msgstr "El registre SPF autoritza %s a través del mecanisme \"a\"." + +#. translators: %s: Hostname authorized via the SPF "mx" mechanism. +#: includes/class-settings-page.php:4714 includes/class-settings-page.php:4724 +#, php-format +msgid "The SPF record authorizes %s via the \"mx\" mechanism." +msgstr "El registre SPF autoritza %s a través del mecanisme \"mx\"." + +#. translators: %1$s: IP address. %2$s: SPF mechanism. +#: includes/class-settings-page.php:4739 includes/class-settings-page.php:4760 +#, php-format +msgid "The SPF record authorizes the SMTP host IP %1$s via %2$s." +msgstr "El registre SPF autoritza la IP del servidor SMTP %1$s a través de %2$s." + +#: includes/class-settings-page.php:4779 +msgid "" +"The SMTP host was not found in the SPF record. Add it to avoid delivery " +"issues." +msgstr "" +"El servidor SMTP no s'ha trobat al registre SPF. Afegeix-lo per evitar problemes de lliurament." + +#: includes/class-settings-page.php:4782 +msgid "" +"The SPF record contains IP ranges, but the SMTP host IP could not be " +"resolved." +msgstr "" +"El registre SPF conté rangs d'IP, però la IP del servidor SMTP no s'ha pogut " +"resoldre." + +#: includes/class-settings-page.php:4785 +msgid "The SPF record does not explicitly reference the configured SMTP host." +msgstr "El registre SPF no fa referència explícitament al servidor SMTP configurat." + +#: includes/class-settings-page.php:5075 +msgid "" +"The DMARC policy is set to \"p=none\". Increase it to \"p=quarantine\" or " +"\"p=reject\" to protect the domain." +msgstr "" +"La política DMARC està establerta a \"p=none\". Augmenta-la a \"p=quarantine\" o " +"\"p=reject\" per protegir el domini." + +#: includes/class-settings-page.php:5077 +msgid "" +"Consider moving the DMARC policy to \"p=reject\" once you have validated " +"that legitimate messages pass authentication." +msgstr "" +"Considera moure la política DMARC a \"p=reject\" un cop hagis validat " +"que els missatges legítims passen l'autenticació." + +#: includes/class-settings-page.php:5105 +msgid "" +"MX lookups are not available because the DNS functions are disabled on this " +"server." +msgstr "" +"Les cerques MX no estan disponibles perquè les funcions DNS estan desactivades en aquest " +"servidor." + +#: includes/class-settings-page.php:5113 +msgid "The DNS lookup for MX records failed. Please try again later." +msgstr "La cerca DNS de registres MX ha fallat. Si us plau, intenta-ho de nou més tard." + +#: includes/class-settings-page.php:5251 +msgid "None" +msgstr "Cap" + +#: includes/class-settings-page.php:5252 +msgid "SSL" +msgstr "SSL" + +#: includes/class-settings-page.php:5253 +msgid "TLS" +msgstr "TLS" + +#: includes/class-settings-page.php:5410 +msgid "A valid recipient email address is required." +msgstr "Es requereix una adreça d'email de destinatari vàlida." + +#: includes/class-settings-page.php:5435 +msgid "ROBOTSTXT SMTP Test Email" +msgstr "Email de prova ROBOTSTXT SMTP" + +#. translators: %s: Site name. +#: includes/class-settings-page.php:5438 +#, php-format +msgid "This is a test email sent from %s using the ROBOTSTXT SMTP settings." +msgstr "Aquest és un email de prova enviat des de %s usant la configuració de ROBOTSTXT SMTP." + +#: includes/class-settings-page.php:5478 +msgid "The test email could not be sent." +msgstr "No s'ha pogut enviar l'email de prova." + +#: includes/class-settings-page.php:5553 +msgid "The SMTP configuration appears to be working correctly." +msgstr "La configuració SMTP sembla estar funcionant correctament." + +#: includes/class-settings-page.php:5554 +msgid "The SMTP configuration could not be verified." +msgstr "No s'ha pogut verificar la configuració SMTP." + +#: includes/class-settings-page.php:5556 +msgid "Test email sent successfully." +msgstr "Email de prova enviat correctament." + +#: includes/class-settings-page.php:5556 +msgid "Test email failed to send." +msgstr "Ha fallat l'enviament de l'email de prova." + +#. translators: %s: Recipient email address. +#: includes/class-settings-page.php:5566 +#, php-format +msgid "Recipient: %s" +msgstr "Destinatari: %s" + +#. translators: %s: Timestamp of the test. +#: includes/class-settings-page.php:5577 +#, php-format +msgid "Timestamp: %s" +msgstr "Marca de temps: %s" + +#: includes/class-settings-page.php:5588 +msgid "Error details" +msgstr "Detalls de l'error" + +#: includes/class-settings-page.php:5594 +msgid "Settings used" +msgstr "Configuració utilitzada" + +#: includes/class-settings-page.php:5600 +msgid "Email payload" +msgstr "Contingut de l'email" + +#: includes/class-settings-page.php:5606 +msgid "SMTP debug output" +msgstr "Sortida de depuració SMTP" + +#: includes/class-settings-page.php:5659 includes/class-settings-page.php:5684 +msgid "Send Test Email" +msgstr "Enviar email de prova" + +#: includes/class-settings-page.php:5668 +msgid "Recipient email address" +msgstr "Adreça d'email del destinatari" + +#: includes/class-settings-page.php:5679 +msgid "Leave blank to send the test email to your account email address." +msgstr "Deixar en blanc per enviar l'email de prova a l'adreça d'email del teu compte." + +#: includes/class-settings-page.php:5814 +msgid "Show last:" +msgstr "Mostrar últims:" + +#: includes/class-settings-page.php:5816 +msgid "7 days" +msgstr "7 dies" + +#: includes/class-settings-page.php:5817 +msgid "14 days" +msgstr "14 dies" + +#: includes/class-settings-page.php:5818 +msgid "30 days" +msgstr "30 dies" + +#: includes/class-settings-page.php:5819 +msgid "60 days" +msgstr "60 dies" + +#: includes/class-settings-page.php:5820 +msgid "90 days" +msgstr "90 dies" + +#: includes/class-settings-page.php:5822 +msgid "Update" +msgstr "Actualitzar" + +#: includes/class-settings-page.php:5827 +msgid "Summary" +msgstr "Resum" + +#: includes/class-settings-page.php:5829 +msgid "Total emails sent:" +msgstr "Total d'emails enviats:" + +#. translators: 1: start date, 2: end date +#: includes/class-settings-page.php:5836 +#, php-format +msgid "Period: %1$s to %2$s" +msgstr "Període: %1$s a %2$s" + +#: includes/class-settings-page.php:5845 +msgid "Emails Sent Per Day" +msgstr "Emails enviats per dia" + +#: includes/class-settings-page.php:5853 +msgid "Emails by Site" +msgstr "Emails per lloc" + +#: includes/class-settings-page.php:5857 +msgid "Blog ID" +msgstr "ID del lloc" + +#: includes/class-settings-page.php:5858 +msgid "Site Name" +msgstr "Nom del lloc" + +#: includes/class-settings-page.php:5859 includes/class-settings-page.php:5898 +msgid "Emails Sent" +msgstr "Emails enviats" + +#. translators: %s: plugin name. +#: robotstxt-smtp.php:108 +#, php-format +msgid "The %s plugin requires the PHPMailer library to be available." +msgstr "El plugin %s requereix que la biblioteca PHPMailer estigui disponible." + +#: robotstxt-smtp.php:109 +msgid "ROBOTSTXT SMTP" +msgstr "ROBOTSTXT SMTP" + +#: robotstxt-updater.php:362 +msgid "Security check failed" +msgstr "Ha fallat la comprovació de seguretat" + +#: robotstxt-updater.php:367 +msgid "You do not have sufficient permissions to access this page." +msgstr "No tens permisos suficients per accedir a aquesta pàgina." + +#. Plugin URI of the plugin/theme +msgid "https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp" +msgstr "https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp" + +#. Description of the plugin/theme +msgid "Configure WordPress to send emails through SMTP with detailed controls." +msgstr "Configura WordPress per enviar emails a través d'SMTP amb controls detallats." + +#. Author of the plugin/theme +msgid "ROBOTSTXT" +msgstr "ROBOTSTXT" + +#. Author URI of the plugin/theme +msgid "https://www.robotstxt.es/" +msgstr "https://www.robotstxt.es/" diff --git a/languages/robotstxt-smtp-es_ES.mo b/languages/robotstxt-smtp-es_ES.mo new file mode 100644 index 0000000000000000000000000000000000000000..32c2f6756f003882d30559aaf2802017012407e6 GIT binary patch literal 33741 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 literal 0 HcmV?d00001 diff --git a/languages/robotstxt-smtp-es_ES.po b/languages/robotstxt-smtp-es_ES.po new file mode 100644 index 0000000..edde949 --- /dev/null +++ b/languages/robotstxt-smtp-es_ES.po @@ -0,0 +1,1479 @@ +#, fuzzy +msgid "" +msgstr "" +"Language: es_ES\n" +"Project-Id-Version: SMTP (by ROBOTSTXT)\n" +"POT-Creation-Date: 2026-01-29 10:03+0100\n" +"PO-Revision-Date: 2026-01-29 10:30+0100\n" +"Last-Translator: ROBOTSTXT \n" +"Language-Team: Spanish\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Manual\n" + +#: includes/class-plugin.php:165 includes/class-settings-page.php:381 +#: includes/class-settings-page.php:446 includes/class-settings-page.php:2691 +msgid "SMTP Logs" +msgstr "Registros SMTP" + +#: includes/class-plugin.php:166 +msgid "SMTP Log" +msgstr "Registro SMTP" + +#: includes/class-plugin.php:457 +msgid "OpenSSL PHP extension is not loaded" +msgstr "La extensión PHP OpenSSL no está cargada" + +#: includes/class-plugin.php:459 +msgid "AES-256-GCM cipher is not supported by OpenSSL" +msgstr "El cifrado AES-256-GCM no está soportado por OpenSSL" + +#: includes/class-plugin.php:463 +msgid "AUTH_KEY is not defined in wp-config.php" +msgstr "AUTH_KEY no está definida en wp-config.php" + +#: includes/class-plugin.php:467 +msgid "AUTH_SALT is not defined in wp-config.php" +msgstr "AUTH_SALT no está definida en wp-config.php" + +#: includes/class-plugin.php:486 +msgid "ROBOTSTXT SMTP: Credential Encryption Unavailable" +msgstr "ROBOTSTXT SMTP: Cifrado de credenciales no disponible" + +#: includes/class-plugin.php:489 +msgid "" +"Your SMTP credentials are currently stored without encryption because the " +"following requirements are not met:" +msgstr "" +"Tus credenciales SMTP actualmente se almacenan sin cifrar porque no se cumplen " +"los siguientes requisitos:" + +#. translators: %s: Link to WordPress security keys documentation +#: includes/class-plugin.php:500 +#, php-format +msgid "" +"To enable credential encryption, please ensure OpenSSL is installed and %s " +"are defined in your wp-config.php file." +msgstr "" +"Para activar el cifrado de credenciales, asegúrate de que OpenSSL esté instalado y %s " +"estén definidas en tu archivo wp-config.php." + +#: includes/class-plugin.php:501 +msgid "WordPress authentication keys" +msgstr "claves de autenticación de WordPress" + +#: includes/class-plugin.php:507 +msgid "Dismiss for 7 days" +msgstr "Descartar durante 7 días" + +#. translators: %d: rate limit per second +#: includes/class-plugin.php:1147 +#, php-format +msgid "Rate limit exceeded: Maximum %d emails per second." +msgstr "Límite de tasa excedido: Máximo %d emails por segundo." + +#. translators: %d: rate limit per hour +#: includes/class-plugin.php:1163 +#, php-format +msgid "Rate limit exceeded: Maximum %d emails per hour." +msgstr "Límite de tasa excedido: Máximo %d emails por hora." + +#. translators: %d: rate limit per day +#: includes/class-plugin.php:1179 +#, php-format +msgid "Rate limit exceeded: Maximum %d emails per 24 hours." +msgstr "Límite de tasa excedido: Máximo %d emails por 24 horas." + +#: includes/class-settings-page.php:246 +msgid "You do not have permission to access this page." +msgstr "No tienes permisos para acceder a esta página." + +#. Plugin Name of the plugin/theme +#: includes/class-settings-page.php:344 includes/class-settings-page.php:354 +#: includes/class-settings-page.php:409 includes/class-settings-page.php:419 +#: includes/class-settings-page.php:1081 includes/class-settings-page.php:1106 +msgid "SMTP (by ROBOTSTXT)" +msgstr "SMTP (by ROBOTSTXT)" + +#: includes/class-settings-page.php:345 includes/class-settings-page.php:410 +msgid "SMTP" +msgstr "SMTP" + +#: includes/class-settings-page.php:355 includes/class-settings-page.php:420 +msgid "Settings" +msgstr "Configuración" + +#: includes/class-settings-page.php:363 includes/class-settings-page.php:428 +#: includes/class-settings-page.php:1277 +msgid "SMTP Test" +msgstr "Prueba SMTP" + +#: includes/class-settings-page.php:364 includes/class-settings-page.php:429 +msgid "Test" +msgstr "Prueba" + +#: includes/class-settings-page.php:372 includes/class-settings-page.php:437 +#: includes/class-settings-page.php:1344 +msgid "SMTP Tools" +msgstr "Herramientas SMTP" + +#: includes/class-settings-page.php:373 includes/class-settings-page.php:438 +msgid "Tools" +msgstr "Herramientas" + +#: includes/class-settings-page.php:382 includes/class-settings-page.php:447 +msgid "Logs" +msgstr "Registros" + +#: includes/class-settings-page.php:390 includes/class-settings-page.php:455 +#: includes/class-settings-page.php:5809 +msgid "Email Statistics" +msgstr "Estadísticas de email" + +#: includes/class-settings-page.php:391 includes/class-settings-page.php:456 +msgid "Statistics" +msgstr "Estadísticas" + +#: includes/class-settings-page.php:496 +msgid "SMTP Server Configuration" +msgstr "Configuración del servidor SMTP" + +#: includes/class-settings-page.php:505 includes/class-settings-page.php:1174 +msgid "Email Log Settings" +msgstr "Configuración de registros de email" + +#: includes/class-settings-page.php:514 +msgid "Statistics Settings" +msgstr "Configuración de estadísticas" + +#: includes/class-settings-page.php:523 includes/class-settings-page.php:1181 +msgid "Rate Limiting" +msgstr "Limitación de tasa" + +#: includes/class-settings-page.php:640 +msgid "Emails per second" +msgstr "Emails por segundo" + +#: includes/class-settings-page.php:646 +msgid "Emails per hour" +msgstr "Emails por hora" + +#: includes/class-settings-page.php:652 +msgid "Emails per day (24 hours)" +msgstr "Emails por día (24 horas)" + +#: includes/class-settings-page.php:670 +msgid "" +"Rate limits are automatically configured from your Amazon SES account quotas." +msgstr "" +"Los límites de tasa se configuran automáticamente desde las cuotas de tu cuenta de Amazon SES." + +#. translators: %s: Time elapsed since quotas were fetched +#: includes/class-settings-page.php:685 +#, php-format +msgid "Last updated from Amazon SES: %s ago" +msgstr "Última actualización desde Amazon SES: hace %s" + +#: includes/class-settings-page.php:690 +msgid "Quotas not yet fetched from Amazon SES." +msgstr "Cuotas aún no obtenidas desde Amazon SES." + +#: includes/class-settings-page.php:715 +msgid "Refresh Quotas Now" +msgstr "Actualizar cuotas ahora" + +#: includes/class-settings-page.php:723 +msgid "" +"Configure rate limits to control how many emails can be sent per time " +"period. Set to 0 for unlimited." +msgstr "" +"Configura límites de tasa para controlar cuántos emails se pueden enviar por período de tiempo. " +"Establece en 0 para ilimitado." + +#: includes/class-settings-page.php:747 includes/class-settings-page.php:798 +#: includes/class-settings-page.php:848 +msgid "Unlimited" +msgstr "Ilimitado" + +#: includes/class-settings-page.php:749 +msgid "Automatically set from Amazon SES MaxSendRate quota." +msgstr "Establecido automáticamente desde la cuota MaxSendRate de Amazon SES." + +#: includes/class-settings-page.php:754 includes/class-settings-page.php:805 +#: includes/class-settings-page.php:855 +msgid "Not available" +msgstr "No disponible" + +#: includes/class-settings-page.php:756 includes/class-settings-page.php:807 +#: includes/class-settings-page.php:857 +msgid "Unable to fetch quota from Amazon SES. Check IAM permissions." +msgstr "No se puede obtener la cuota desde Amazon SES. Verifica los permisos IAM." + +#: includes/class-settings-page.php:773 +msgid "Maximum emails per second. 0 = unlimited." +msgstr "Máximo de emails por segundo. 0 = ilimitado." + +#: includes/class-settings-page.php:800 +msgid "" +"Automatically calculated as 90% of maximum throughput (MaxSendRate × 3600 × " +"0.9)." +msgstr "" +"Calculado automáticamente como el 90% del rendimiento máximo (MaxSendRate × 3600 × " +"0.9)." + +#: includes/class-settings-page.php:824 +msgid "Maximum emails per hour (rolling window). 0 = unlimited." +msgstr "Máximo de emails por hora (ventana móvil). 0 = ilimitado." + +#: includes/class-settings-page.php:850 +msgid "Automatically set from Amazon SES Max24HourSend quota." +msgstr "Establecido automáticamente desde la cuota Max24HourSend de Amazon SES." + +#: includes/class-settings-page.php:874 +msgid "" +"Maximum emails that can be sent per 24-hour period (rolling window). 0 = " +"unlimited." +msgstr "" +"Máximo de emails que se pueden enviar por período de 24 horas (ventana móvil). 0 = " +"ilimitado." + +#: includes/class-settings-page.php:891 includes/class-settings-page.php:1687 +msgid "Host" +msgstr "Servidor" + +#: includes/class-settings-page.php:897 +msgid "Username" +msgstr "Nombre de usuario" + +#: includes/class-settings-page.php:903 +msgid "Password" +msgstr "Contraseña" + +#: includes/class-settings-page.php:909 +msgid "From Email" +msgstr "Email remitente" + +#: includes/class-settings-page.php:915 +msgid "From Name" +msgstr "Nombre remitente" + +#: includes/class-settings-page.php:921 +msgid "Reply-To Email" +msgstr "Email de respuesta" + +#: includes/class-settings-page.php:927 +msgid "Reply-To Name" +msgstr "Nombre de respuesta" + +#: includes/class-settings-page.php:933 +msgid "Security Type" +msgstr "Tipo de seguridad" + +#: includes/class-settings-page.php:939 +msgid "Port" +msgstr "Puerto" + +#: includes/class-settings-page.php:967 +msgid "Enable logging" +msgstr "Activar registro" + +#: includes/class-settings-page.php:973 +msgid "Retention mode" +msgstr "Modo de retención" + +#: includes/class-settings-page.php:978 +msgid "Maximum stored emails" +msgstr "Máximo de emails almacenados" + +#: includes/class-settings-page.php:984 includes/class-settings-page.php:1000 +msgid "Retention in days" +msgstr "Retención en días" + +#: includes/class-settings-page.php:1043 includes/class-settings-page.php:1159 +msgid "" +"Amazon SES integration is active. To configure SMTP manually, deactivate the " +"Amazon SES add-on." +msgstr "" +"La integración de Amazon SES está activa. Para configurar SMTP manualmente, desactiva el " +"complemento de Amazon SES." + +#: includes/class-settings-page.php:1049 +msgid "Configure the SMTP server used to deliver outgoing emails." +msgstr "Configura el servidor SMTP utilizado para entregar emails salientes." + +#: includes/class-settings-page.php:1058 +msgid "Control how email delivery logs are stored and pruned." +msgstr "Controla cómo se almacenan y limpian los registros de entrega de email." + +#: includes/class-settings-page.php:1067 +msgid "Configure how long email statistics are retained in the database." +msgstr "Configura cuánto tiempo se retienen las estadísticas de email en la base de datos." + +#: includes/class-settings-page.php:1086 includes/class-settings-page.php:1189 +msgid "Save Changes" +msgstr "Guardar cambios" + +#: includes/class-settings-page.php:1121 +msgid "Settings saved." +msgstr "Configuración guardada." + +#: includes/class-settings-page.php:1130 +msgid "Configuration scope" +msgstr "Ámbito de configuración" + +#: includes/class-settings-page.php:1131 +msgid "" +"Choose whether to manage the SMTP credentials globally or per individual " +"site." +msgstr "" +"Elige si gestionar las credenciales SMTP globalmente o por sitio individual." + +#: includes/class-settings-page.php:1135 +msgid "Mode" +msgstr "Modo" + +#: includes/class-settings-page.php:1140 +msgid "Global network configuration" +msgstr "Configuración global de red" + +#: includes/class-settings-page.php:1145 +msgid "Configure each site individually" +msgstr "Configurar cada sitio individualmente" + +#: includes/class-settings-page.php:1148 +msgid "" +"When configured globally, all sites in the network will reuse the settings " +"below." +msgstr "" +"Cuando se configura globalmente, todos los sitios de la red reutilizarán la configuración " +"de abajo." + +#: includes/class-settings-page.php:1156 +msgid "Global SMTP settings" +msgstr "Configuración SMTP global" + +#: includes/class-settings-page.php:1164 +msgid "" +"These credentials are stored for later use but are only applied when the " +"global configuration mode is enabled." +msgstr "" +"Estas credenciales se almacenan para uso posterior pero solo se aplican cuando el " +"modo de configuración global está activado." + +#: includes/class-settings-page.php:1204 +msgid "Network settings are only available on multisite installations." +msgstr "La configuración de red solo está disponible en instalaciones multisitio." + +#: includes/class-settings-page.php:1213 includes/class-settings-page.php:3392 +#: includes/class-settings-page.php:5267 +msgid "The link you followed has expired." +msgstr "El enlace que has seguido ha caducado." + +#: includes/class-settings-page.php:1280 +msgid "" +"The network configuration is currently disabled. Tests will use the site-" +"specific settings stored below." +msgstr "" +"La configuración de red está actualmente desactivada. Las pruebas usarán la configuración " +"específica del sitio almacenada abajo." + +#: includes/class-settings-page.php:1319 +msgid "Automatic MX Lookup" +msgstr "Búsqueda automática de MX" + +#: includes/class-settings-page.php:1320 +msgid "" +"Detects the domain from the configured sender address, retrieves its MX " +"records, and compares them with the SMTP host." +msgstr "" +"Detecta el dominio desde la dirección del remitente configurada, obtiene sus registros MX " +"y los compara con el servidor SMTP." + +#: includes/class-settings-page.php:1324 +msgid "SPF, DKIM, and DMARC Validation" +msgstr "Validación de SPF, DKIM y DMARC" + +#: includes/class-settings-page.php:1325 +msgid "" +"Checks common DNS TXT records for the sender domain to help you verify email " +"authentication." +msgstr "" +"Verifica registros TXT DNS comunes para el dominio del remitente para ayudarte a verificar la " +"autenticación de email." + +#: includes/class-settings-page.php:1329 +msgid "Extended SMTP Diagnostics" +msgstr "Diagnósticos SMTP extendidos" + +#: includes/class-settings-page.php:1330 +msgid "" +"Reuses the configured SMTP connection to inspect the server greeting, TLS " +"support, available authentication mechanisms, and EHLO/HELO response codes." +msgstr "" +"Reutiliza la conexión SMTP configurada para inspeccionar el saludo del servidor, soporte TLS, " +"mecanismos de autenticación disponibles y códigos de respuesta EHLO/HELO." + +#: includes/class-settings-page.php:1334 +msgid "Blacklist Lookup" +msgstr "Búsqueda en listas negras" + +#: includes/class-settings-page.php:1335 +msgid "" +"Checks the SMTP host IP address against well-known DNS-based reputation " +"lists. Use the feature responsibly and respect each provider's terms of use." +msgstr "" +"Verifica la dirección IP del servidor SMTP contra listas de reputación basadas en DNS conocidas. " +"Usa la función responsablemente y respeta los términos de uso de cada proveedor." + +#: includes/class-settings-page.php:1348 +msgid "" +"The network configuration is currently disabled. Tools will use the site-" +"specific settings stored below." +msgstr "" +"La configuración de red está actualmente desactivada. Las herramientas usarán la configuración " +"específica del sitio almacenada abajo." + +#. translators: %s: Human-readable timestamp of the last check. +#: includes/class-settings-page.php:1382 +#, php-format +msgid "Last checked: %s" +msgstr "Última comprobación: %s" + +#: includes/class-settings-page.php:1391 +msgid "Run checks again" +msgstr "Ejecutar comprobaciones de nuevo" + +#: includes/class-settings-page.php:1400 +msgid "There are no results yet. Click the button below to run this check." +msgstr "Aún no hay resultados. Haz clic en el botón de abajo para ejecutar esta comprobación." + +#: includes/class-settings-page.php:1405 +msgid "Run checks" +msgstr "Ejecutar comprobaciones" + +#: includes/class-settings-page.php:1649 +msgid "" +"Configure a \"From Email\" address in the settings to analyze the MX records." +msgstr "" +"Configura una dirección \"Email remitente\" en la configuración para analizar los registros MX." + +#: includes/class-settings-page.php:1655 +msgid "Domain:" +msgstr "Dominio:" + +#: includes/class-settings-page.php:1658 +msgid "Configured SMTP host:" +msgstr "Servidor SMTP configurado:" + +#: includes/class-settings-page.php:1659 +msgid "Not configured" +msgstr "No configurado" + +#: includes/class-settings-page.php:1663 +msgid "The MX lookup could not be completed:" +msgstr "La búsqueda MX no se pudo completar:" + +#. translators: %s: Domain name extracted from the sender email address. +#: includes/class-settings-page.php:1676 +#, php-format +msgid "No MX records were found for %s." +msgstr "No se encontraron registros MX para %s." + +#: includes/class-settings-page.php:1686 +msgid "Priority" +msgstr "Prioridad" + +#: includes/class-settings-page.php:1688 +msgid "Resolves" +msgstr "Resuelve" + +#: includes/class-settings-page.php:1689 +msgid "Matches SMTP host" +msgstr "Coincide con servidor SMTP" + +#: includes/class-settings-page.php:1700 includes/class-settings-page.php:1713 +msgid "Yes" +msgstr "Sí" + +#: includes/class-settings-page.php:1702 includes/class-settings-page.php:1715 +msgid "No" +msgstr "No" + +#: includes/class-settings-page.php:1704 +msgid "Unknown" +msgstr "Desconocido" + +#: includes/class-settings-page.php:1735 +msgid "Some MX records could not be resolved to an A or AAAA record:" +msgstr "Algunos registros MX no se pudieron resolver a un registro A o AAAA:" + +#. translators: %s: Configured SMTP host. +#: includes/class-settings-page.php:1751 +#, php-format +msgid "" +"At least one MX record points to %s, which matches the configured SMTP host." +msgstr "" +"Al menos un registro MX apunta a %s, que coincide con el servidor SMTP configurado." + +#. translators: %s: Configured SMTP host. +#: includes/class-settings-page.php:1763 +#, php-format +msgid "None of the MX records point to %s, which is the configured SMTP host." +msgstr "Ninguno de los registros MX apunta a %s, que es el servidor SMTP configurado." + +#: includes/class-settings-page.php:1772 +msgid "Configure an SMTP host to compare it against the MX records." +msgstr "Configura un servidor SMTP para compararlo contra los registros MX." + +#: includes/class-settings-page.php:1805 +msgid "Configure an SMTP host in the settings to run the diagnostics." +msgstr "Configura un servidor SMTP en la configuración para ejecutar los diagnósticos." + +#: includes/class-settings-page.php:1839 +msgid "Server:" +msgstr "Servidor:" + +#: includes/class-settings-page.php:1842 +msgid "Configured security:" +msgstr "Seguridad configurada:" + +#: includes/class-settings-page.php:1848 +msgid "Server banner:" +msgstr "Banner del servidor:" + +#. translators: %s: SMTP server response code. +#: includes/class-settings-page.php:1856 +#, php-format +msgid "code %s" +msgstr "código %s" + +#: includes/class-settings-page.php:1866 +msgid "TLS status" +msgstr "Estado TLS" + +#: includes/class-settings-page.php:1871 +msgid "The connection uses implicit TLS (SMTPS)." +msgstr "La conexión usa TLS implícito (SMTPS)." + +#: includes/class-settings-page.php:1873 +msgid "The STARTTLS negotiation succeeded and the connection is encrypted." +msgstr "La negociación STARTTLS tuvo éxito y la conexión está cifrada." + +#: includes/class-settings-page.php:1875 +msgid "The server accepted the TLS negotiation." +msgstr "El servidor aceptó la negociación TLS." + +#: includes/class-settings-page.php:1878 +msgid "TLS is not active for this connection." +msgstr "TLS no está activo para esta conexión." + +#: includes/class-settings-page.php:1885 +msgid "STARTTLS response:" +msgstr "Respuesta STARTTLS:" + +#: includes/class-settings-page.php:1899 +msgid "Authentication mechanisms" +msgstr "Mecanismos de autenticación" + +#: includes/class-settings-page.php:1907 +msgid "The server did not announce authentication mechanisms." +msgstr "El servidor no anunció mecanismos de autenticación." + +#: includes/class-settings-page.php:1910 +msgid "EHLO response" +msgstr "Respuesta EHLO" + +#: includes/class-settings-page.php:1913 includes/class-settings-page.php:1929 +#: includes/class-settings-page.php:1944 +msgid "Status code:" +msgstr "Código de estado:" + +#: includes/class-settings-page.php:1926 +msgid "EHLO after STARTTLS" +msgstr "EHLO después de STARTTLS" + +#: includes/class-settings-page.php:1941 +msgid "HELO response" +msgstr "Respuesta HELO" + +#: includes/class-settings-page.php:1959 +msgid "View raw transcript" +msgstr "Ver transcripción completa" + +#: includes/class-settings-page.php:2029 +msgid "A valid SMTP host is required to run diagnostics." +msgstr "Se requiere un servidor SMTP válido para ejecutar los diagnósticos." + +#: includes/class-settings-page.php:2085 +msgid "Unknown error" +msgstr "Error desconocido" + +#. translators: 1: Error message. 2: Error code. +#: includes/class-settings-page.php:2090 +#, php-format +msgid "Connection failed: %1$s (%2$d)." +msgstr "Falló la conexión: %1$s (%2$d)." + +#: includes/class-settings-page.php:2111 +msgid "The server greeting returned an unexpected status code." +msgstr "El saludo del servidor devolvió un código de estado inesperado." + +#: includes/class-settings-page.php:2125 +msgid "The EHLO response could not be parsed." +msgstr "No se pudo analizar la respuesta EHLO." + +#: includes/class-settings-page.php:2127 +msgid "The server did not accept the EHLO command." +msgstr "El servidor no aceptó el comando EHLO." + +#: includes/class-settings-page.php:2132 +msgid "The server did not advertise STARTTLS support." +msgstr "El servidor no anunció soporte para STARTTLS." + +#: includes/class-settings-page.php:2151 +msgid "The TLS negotiation failed after STARTTLS." +msgstr "La negociación TLS falló después de STARTTLS." + +#: includes/class-settings-page.php:2157 +msgid "" +"The server supports STARTTLS. Enable TLS in the configuration to protect the " +"connection." +msgstr "" +"El servidor soporta STARTTLS. Activa TLS en la configuración para proteger la " +"conexión." + +#: includes/class-settings-page.php:2161 +msgid "No authentication mechanisms were advertised by the server." +msgstr "El servidor no anunció mecanismos de autenticación." + +#: includes/class-settings-page.php:2172 +msgid "The legacy HELO command did not return a successful status code." +msgstr "El comando HELO heredado no devolvió un código de estado exitoso." + +#: includes/class-settings-page.php:2180 +msgid "The connection is not encrypted. Credentials may travel in plain text." +msgstr "La conexión no está cifrada. Las credenciales pueden viajar en texto plano." + +#: includes/class-settings-page.php:2356 +msgid "" +"Configure a \"From Email\" address in the settings to analyze SPF, DKIM, and " +"DMARC records." +msgstr "" +"Configura una dirección \"Email remitente\" en la configuración para analizar registros SPF, DKIM " +"y DMARC." + +#: includes/class-settings-page.php:2374 +msgid "SPF" +msgstr "SPF" + +#: includes/class-settings-page.php:2386 +msgid "No SPF record was found for the sender domain." +msgstr "No se encontró registro SPF para el dominio del remitente." + +#: includes/class-settings-page.php:2410 +msgid "DKIM" +msgstr "DKIM" + +#: includes/class-settings-page.php:2422 +msgid "A DKIM record was found for the default selector." +msgstr "Se encontró un registro DKIM para el selector por defecto." + +#: includes/class-settings-page.php:2429 +msgid "" +"No DKIM record was found for the default selector. Confirm the selector " +"provided by your email service and publish the corresponding TXT record." +msgstr "" +"No se encontró registro DKIM para el selector por defecto. Confirma el selector " +"proporcionado por tu servicio de email y publica el registro TXT correspondiente." + +#: includes/class-settings-page.php:2433 +msgid "DMARC" +msgstr "DMARC" + +#: includes/class-settings-page.php:2445 +msgid "No DMARC record was found for the sender domain." +msgstr "No se encontró registro DMARC para el dominio del remitente." + +#. translators: %s: DMARC policy value. +#: includes/class-settings-page.php:2455 +#, php-format +msgid "Published policy: %s" +msgstr "Política publicada: %s" + +#: includes/class-settings-page.php:2472 +msgid "The DMARC policy enforces protection for the domain." +msgstr "La política DMARC aplica protección para el dominio." + +#: includes/class-settings-page.php:2515 +msgid "" +"IPv6 addresses are currently not checked because most DNSBL providers only " +"publish IPv4 data. Verify IPv6 reputation manually with your email service." +msgstr "" +"Las direcciones IPv6 actualmente no se verifican porque la mayoría de proveedores DNSBL solo " +"publican datos IPv4. Verifica la reputación IPv6 manualmente con tu servicio de email." + +#: includes/class-settings-page.php:2523 +msgid "" +"The SMTP host did not resolve to any IPv4 addresses. Configure a valid host " +"or allow DNS lookups on the server to perform blacklist checks." +msgstr "" +"El servidor SMTP no resolvió a ninguna dirección IPv4. Configura un servidor válido " +"o permite búsquedas DNS en el servidor para realizar comprobaciones de listas negras." + +#. translators: %s: IP address used for the blacklist lookup. +#: includes/class-settings-page.php:2533 +#, php-format +msgid "IP address: %s" +msgstr "Dirección IP: %s" + +#: includes/class-settings-page.php:2552 +msgid "Provider" +msgstr "Proveedor" + +#: includes/class-settings-page.php:2553 includes/class-settings-page.php:3115 +#: includes/class-settings-page.php:3290 +msgid "Status" +msgstr "Estado" + +#: includes/class-settings-page.php:2554 +msgid "Impact" +msgstr "Impacto" + +#: includes/class-settings-page.php:2555 +msgid "Details" +msgstr "Detalles" + +#: includes/class-settings-page.php:2556 +msgid "Removal guidance" +msgstr "Guía de eliminación" + +#: includes/class-settings-page.php:2569 +msgid "Unavailable" +msgstr "No disponible" + +#: includes/class-settings-page.php:2571 +msgid "Listed" +msgstr "Listado" + +#: includes/class-settings-page.php:2573 +msgid "Not listed" +msgstr "No listado" + +#: includes/class-settings-page.php:2584 +msgid "Response:" +msgstr "Respuesta:" + +#: includes/class-settings-page.php:2596 +msgid "No additional TXT details were returned by the provider." +msgstr "El proveedor no devolvió detalles TXT adicionales." + +#: includes/class-settings-page.php:2599 +msgid "The IP address is not currently listed by this provider." +msgstr "La dirección IP no está actualmente listada por este proveedor." + +#: includes/class-settings-page.php:2608 +msgid "Open removal request page" +msgstr "Abrir página de solicitud de eliminación" + +#: includes/class-settings-page.php:2695 +msgid "The link you followed has expired. Please try again." +msgstr "El enlace que has seguido ha caducado. Por favor, intenta de nuevo." + +#: includes/class-settings-page.php:2701 +msgid "All log entries were removed." +msgstr "Se eliminaron todas las entradas de registro." + +#: includes/class-settings-page.php:2707 +msgid "" +"Log entries are stored per site. The table below reflects the currently " +"selected site." +msgstr "" +"Las entradas de registro se almacenan por sitio. La tabla de abajo refleja el sitio " +"actualmente seleccionado." + +#: includes/class-settings-page.php:2713 +msgid "" +"Logging is currently disabled. Enable it in the settings page to store new " +"emails." +msgstr "" +"El registro está actualmente desactivado. Actívalo en la página de configuración para almacenar nuevos " +"emails." + +#: includes/class-settings-page.php:3054 +msgid "From date" +msgstr "Desde fecha" + +#: includes/class-settings-page.php:3058 +msgid "To date" +msgstr "Hasta fecha" + +#: includes/class-settings-page.php:3062 includes/class-settings-page.php:3118 +#: includes/class-settings-page.php:3306 +msgid "Subject" +msgstr "Asunto" + +#: includes/class-settings-page.php:3066 includes/class-settings-page.php:3117 +#: includes/class-settings-page.php:3302 +msgid "To" +msgstr "Para" + +#: includes/class-settings-page.php:3070 +msgid "Results per page" +msgstr "Resultados por página" + +#: includes/class-settings-page.php:3078 +msgid "Apply filters" +msgstr "Aplicar filtros" + +#: includes/class-settings-page.php:3081 +msgid "Reset" +msgstr "Restablecer" + +#: includes/class-settings-page.php:3092 +msgid "Are you sure you want to delete all log entries?" +msgstr "¿Estás seguro de que quieres eliminar todas las entradas de registro?" + +#: includes/class-settings-page.php:3094 +msgid "Clear Logs" +msgstr "Limpiar registros" + +#: includes/class-settings-page.php:3107 +msgid "No email logs have been stored yet." +msgstr "Aún no se han almacenado registros de email." + +#: includes/class-settings-page.php:3114 includes/class-settings-page.php:3286 +msgid "Date" +msgstr "Fecha" + +#: includes/class-settings-page.php:3116 includes/class-settings-page.php:3298 +msgid "From" +msgstr "De" + +#: includes/class-settings-page.php:3119 +msgid "Actions" +msgstr "Acciones" + +#: includes/class-settings-page.php:3127 includes/class-settings-page.php:3209 +msgid "(No subject)" +msgstr "(Sin asunto)" + +#: includes/class-settings-page.php:3157 +msgid "View details" +msgstr "Ver detalles" + +#: includes/class-settings-page.php:3172 +msgid "«" +msgstr "«" + +#: includes/class-settings-page.php:3173 +msgid "»" +msgstr "»" + +#: includes/class-settings-page.php:3198 +msgid "The requested log entry could not be found." +msgstr "No se pudo encontrar la entrada de registro solicitada." + +#: includes/class-settings-page.php:3281 +msgid "Back to list" +msgstr "Volver al listado" + +#: includes/class-settings-page.php:3310 +msgid "Error message" +msgstr "Mensaje de error" + +#: includes/class-settings-page.php:3316 +msgid "No error recorded." +msgstr "No se registró ningún error." + +#: includes/class-settings-page.php:3324 +msgid "Headers" +msgstr "Cabeceras" + +#: includes/class-settings-page.php:3325 +msgid "No headers stored for this email." +msgstr "No se almacenaron cabeceras para este email." + +#: includes/class-settings-page.php:3327 +msgid "Attachments" +msgstr "Adjuntos" + +#: includes/class-settings-page.php:3335 +msgid "No attachments were logged for this email." +msgstr "No se registraron adjuntos para este email." + +#: includes/class-settings-page.php:3338 +msgid "Message content" +msgstr "Contenido del mensaje" + +#: includes/class-settings-page.php:3342 +msgid "This email did not include any content." +msgstr "Este email no incluía ningún contenido." + +#: includes/class-settings-page.php:3345 +msgid "SMTP debug log" +msgstr "Registro de depuración SMTP" + +#: includes/class-settings-page.php:3348 +msgid "Show SMTP conversation" +msgstr "Mostrar conversación SMTP" + +#: includes/class-settings-page.php:3352 +msgid "No SMTP debug output was stored for this email." +msgstr "No se almacenó salida de depuración SMTP para este email." + +#: includes/class-settings-page.php:3370 +msgid "Failed" +msgstr "Fallado" + +#: includes/class-settings-page.php:3377 +msgid "Sent" +msgstr "Enviado" + +#. translators: 1: Example SMTP host. 2: Example SMTP host. +#: includes/class-settings-page.php:3445 +#, php-format +msgid "" +"Use the fully qualified address of your SMTP server, for example %1$s or " +"%2$s." +msgstr "" +"Usa la dirección completa de tu servidor SMTP, por ejemplo %1$s o " +"%2$s." + +#: includes/class-settings-page.php:3470 +msgid "" +"Usually this is the full email address or dedicated SMTP user provided by " +"your email service." +msgstr "" +"Usualmente esta es la dirección de email completa o el usuario SMTP dedicado proporcionado por " +"tu servicio de email." + +#: includes/class-settings-page.php:3482 +msgid "Leave empty to keep the current password." +msgstr "Dejar vacío para mantener la contraseña actual." + +#: includes/class-settings-page.php:3493 +msgid "" +"Enter the password or app-specific password for the SMTP user. Leave empty " +"to retain the existing value." +msgstr "" +"Introduce la contraseña o contraseña específica de aplicación para el usuario SMTP. Deja vacío " +"para mantener el valor existente." + +#: includes/class-settings-page.php:3513 +msgid "" +"This address will be used as the default sender for emails sent by " +"WordPress, for example notifications@example.com." +msgstr "" +"Esta dirección se usará como remitente por defecto para emails enviados por " +"WordPress, por ejemplo notificaciones@example.com." + +#: includes/class-settings-page.php:3532 +msgid "" +"Recipients will see this name alongside the email address, such as \"Support " +"Team\" or the site title." +msgstr "" +"Los destinatarios verán este nombre junto a la dirección de email, como \"Equipo de " +"soporte\" o el título del sitio." + +#: includes/class-settings-page.php:3552 +msgid "" +"Optional. Email address where replies should be sent. If empty, replies will " +"go to the From Email address." +msgstr "" +"Opcional. Dirección de email donde deben enviarse las respuestas. Si está vacío, las respuestas irán " +"a la dirección Email remitente." + +#: includes/class-settings-page.php:3571 +msgid "" +"Optional. Name that will appear with the Reply-To address. If empty, the " +"From Name will be used." +msgstr "" +"Opcional. Nombre que aparecerá con la dirección de respuesta. Si está vacío, se usará el " +"Nombre remitente." + +#: includes/class-settings-page.php:3589 +msgid "" +"Choose the encryption method recommended by your provider. The default ports " +"are 25 for None, 465 for SSL, and 587 for TLS." +msgstr "" +"Elige el método de cifrado recomendado por tu proveedor. Los puertos por defecto " +"son 25 para Ninguno, 465 para SSL y 587 para TLS." + +#: includes/class-settings-page.php:3610 +msgid "" +"Set the port required by your SMTP server. Common values are 25 (None), 465 " +"(SSL), and 587 (TLS)." +msgstr "" +"Establece el puerto requerido por tu servidor SMTP. Los valores comunes son 25 (Ninguno), 465 " +"(SSL) y 587 (TLS)." + +#: includes/class-settings-page.php:3630 +msgid "Store a copy of every sent email in the logs." +msgstr "Almacenar una copia de cada email enviado en los registros." + +#: includes/class-settings-page.php:3632 +msgid "" +"Logged emails are saved as private posts under SMTP Logs so you can review " +"the content or clear them at any time." +msgstr "" +"Los emails registrados se guardan como entradas privadas en Registros SMTP para que puedas revisar " +"el contenido o limpiarlos en cualquier momento." + +#: includes/class-settings-page.php:3653 +msgid "Limit by number of emails" +msgstr "Limitar por número de emails" + +#: includes/class-settings-page.php:3663 +msgid "Limit by age (in days)" +msgstr "Limitar por antigüedad (en días)" + +#: includes/class-settings-page.php:3666 +msgid "" +"Select how the log cleaner should decide which entries to remove: by keeping " +"a fixed number or by removing items older than a number of days." +msgstr "" +"Selecciona cómo el limpiador de registros debe decidir qué entradas eliminar: manteniendo " +"un número fijo o eliminando elementos más antiguos que un número de días." + +#: includes/class-settings-page.php:3686 +msgid "" +"Maximum number of emails to keep when using the count-based retention mode." +msgstr "" +"Número máximo de emails a mantener cuando se usa el modo de retención basado en recuento." + +#: includes/class-settings-page.php:3706 +msgid "" +"Number of days to keep log entries when using the time-based retention mode." +msgstr "" +"Número de días para mantener entradas de registro cuando se usa el modo de retención basado en tiempo." + +#: includes/class-settings-page.php:3727 +msgid "" +"Number of days to keep email statistics. Statistics older than this will be " +"automatically deleted daily. Minimum: 1 day, Maximum: 365 days." +msgstr "" +"Número de días para mantener estadísticas de email. Las estadísticas más antiguas que esto se " +"eliminarán automáticamente diariamente. Mínimo: 1 día, Máximo: 365 días." + +#: includes/class-settings-page.php:3848 +msgid "" +"The \"From Email\" address is not valid. Please provide a valid email " +"address." +msgstr "" +"La dirección \"Email remitente\" no es válida. Por favor, proporciona una dirección de email " +"válida." + +#: includes/class-settings-page.php:3865 +msgid "" +"The \"Reply-To Email\" address is not valid. Please provide a valid email " +"address." +msgstr "" +"La dirección \"Email de respuesta\" no es válida. Por favor, proporciona una dirección de email " +"válida." + +#: includes/class-settings-page.php:3885 +msgid "" +"The AWS Access Key format is invalid. It should start with AKIA followed by " +"16 alphanumeric characters." +msgstr "" +"El formato de la clave de acceso AWS es inválido. Debe empezar con AKIA seguido de " +"16 caracteres alfanuméricos." + +#: includes/class-settings-page.php:3900 +msgid "" +"The AWS Secret Key format is invalid. It should be 40 characters of base64-" +"encoded data." +msgstr "" +"El formato de la clave secreta AWS es inválido. Debe ser de 40 caracteres codificados en " +"base64." + +#. translators: %d: Invalid port number entered by user +#: includes/class-settings-page.php:3948 +#, php-format +msgid "" +"The port number \"%d\" is invalid. Port must be between 1 and 65535. Using " +"default port 25." +msgstr "" +"El número de puerto \"%d\" es inválido. El puerto debe estar entre 1 y 65535. Usando " +"puerto por defecto 25." + +#. translators: %s: IP address +#: includes/class-settings-page.php:4102 +#, php-format +msgid "" +"The SMTP hostname resolves to a private IP address (%s) which is not allowed " +"for security reasons. If you need to connect to a local SMTP server in " +"development, add this to wp-config.php: " +"define( 'ROBOTSTXT_SMTP_ALLOW_PRIVATE_IPS', true );" +msgstr "" +"El nombre del servidor SMTP resuelve a una dirección IP privada (%s) que no está permitida " +"por razones de seguridad. Si necesitas conectarte a un servidor SMTP local en " +"desarrollo, añade esto a wp-config.php: " +"define( 'ROBOTSTXT_SMTP_ALLOW_PRIVATE_IPS', true );" + +#: includes/class-settings-page.php:4292 +msgid "The sender domain could not be determined." +msgstr "No se pudo determinar el dominio del remitente." + +#: includes/class-settings-page.php:4298 includes/class-settings-page.php:4588 +#: includes/class-settings-page.php:4988 includes/class-settings-page.php:5037 +msgid "" +"DNS lookups are not available because the DNS functions are disabled on this " +"server." +msgstr "" +"Las búsquedas DNS no están disponibles porque las funciones DNS están desactivadas en este " +"servidor." + +#: includes/class-settings-page.php:4329 +msgid "" +"Blacklist lookups are not available because the DNS functions are disabled " +"on this server." +msgstr "" +"Las búsquedas en listas negras no están disponibles porque las funciones DNS están desactivadas " +"en este servidor." + +#: includes/class-settings-page.php:4374 +msgid "Spamhaus ZEN" +msgstr "Spamhaus ZEN" + +#: includes/class-settings-page.php:4376 +msgid "" +"High — major inbox providers rely on Spamhaus and a listing can block most " +"traffic." +msgstr "" +"Alto — los principales proveedores de bandejas de entrada confían en Spamhaus y una inclusión puede bloquear la mayoría del " +"tráfico." + +#: includes/class-settings-page.php:4378 +msgid "" +"Investigate and resolve the root cause, then use the Spamhaus Blocklist " +"Removal Center to request delisting." +msgstr "" +"Investiga y resuelve la causa raíz, luego usa el Centro de eliminación de listas de bloqueo de Spamhaus " +"para solicitar la eliminación." + +#: includes/class-settings-page.php:4382 +msgid "SpamCop" +msgstr "SpamCop" + +#: includes/class-settings-page.php:4384 +msgid "" +"Medium — many shared hosts and spam filters consult SpamCop when scoring " +"messages." +msgstr "" +"Medio — muchos hosts compartidos y filtros de spam consultan SpamCop al puntuar " +"mensajes." + +#: includes/class-settings-page.php:4386 +msgid "" +"Ensure no unsolicited traffic is sent and follow the SpamCop blocklist " +"removal instructions." +msgstr "" +"Asegúrate de que no se envíe tráfico no solicitado y sigue las instrucciones de eliminación de la lista de bloqueo de " +"SpamCop." + +#: includes/class-settings-page.php:4390 +msgid "Barracuda Reputation Block List" +msgstr "Lista de bloqueo de reputación Barracuda" + +#: includes/class-settings-page.php:4392 +msgid "" +"Medium — Barracuda appliances and some hosted filters can defer or reject " +"messages." +msgstr "" +"Medio — los dispositivos Barracuda y algunos filtros alojados pueden diferir o rechazar " +"mensajes." + +#: includes/class-settings-page.php:4394 +msgid "" +"Review the Barracuda reputation lookup and submit a delisting request after " +"addressing any spam complaints." +msgstr "" +"Revisa la búsqueda de reputación de Barracuda y envía una solicitud de eliminación después de " +"abordar cualquier queja de spam." + +#: includes/class-settings-page.php:4502 +msgid "The IP address could not be normalized for the DNSBL lookup." +msgstr "La dirección IP no se pudo normalizar para la búsqueda DNSBL." + +#. translators: %s: DNSBL provider name. +#. translators: %s: Domain queried for the DKIM record lookup. +#. translators: %s: Domain queried for the DMARC record lookup. +#: includes/class-settings-page.php:4513 includes/class-settings-page.php:4998 +#: includes/class-settings-page.php:5047 +#, php-format +msgid "The DNS lookup for %s failed. Please try again later." +msgstr "La búsqueda DNS para %s falló. Por favor, inténtalo de nuevo más tarde." + +#: includes/class-settings-page.php:4584 +msgid "" +"Unable to determine whether the SMTP host is authorized in the SPF record." +msgstr "" +"No se puede determinar si el servidor SMTP está autorizado en el registro SPF." + +#: includes/class-settings-page.php:4596 +msgid "The DNS lookup for TXT records failed. Please try again later." +msgstr "La búsqueda DNS de registros TXT falló. Por favor, inténtalo de nuevo más tarde." + +#: includes/class-settings-page.php:4614 +msgid "The domain does not publish an SPF record." +msgstr "El dominio no publica un registro SPF." + +#: includes/class-settings-page.php:4621 +msgid "Configure an SMTP host to verify its presence in the SPF record." +msgstr "Configura un servidor SMTP para verificar su presencia en el registro SPF." + +#. translators: %s: Included SPF domain. +#: includes/class-settings-page.php:4677 +#, php-format +msgid "The SPF record includes %s, which matches the configured SMTP host." +msgstr "El registro SPF incluye %s, que coincide con el servidor SMTP configurado." + +#. translators: %s: Hostname authorized via the SPF "a" mechanism. +#: includes/class-settings-page.php:4690 includes/class-settings-page.php:4701 +#, php-format +msgid "The SPF record authorizes %s via the \"a\" mechanism." +msgstr "El registro SPF autoriza %s a través del mecanismo \"a\"." + +#. translators: %s: Hostname authorized via the SPF "mx" mechanism. +#: includes/class-settings-page.php:4714 includes/class-settings-page.php:4724 +#, php-format +msgid "The SPF record authorizes %s via the \"mx\" mechanism." +msgstr "El registro SPF autoriza %s a través del mecanismo \"mx\"." + +#. translators: %1$s: IP address. %2$s: SPF mechanism. +#: includes/class-settings-page.php:4739 includes/class-settings-page.php:4760 +#, php-format +msgid "The SPF record authorizes the SMTP host IP %1$s via %2$s." +msgstr "El registro SPF autoriza la IP del servidor SMTP %1$s a través de %2$s." + +#: includes/class-settings-page.php:4779 +msgid "" +"The SMTP host was not found in the SPF record. Add it to avoid delivery " +"issues." +msgstr "" +"El servidor SMTP no se encontró en el registro SPF. Añádelo para evitar problemas de entrega." + +#: includes/class-settings-page.php:4782 +msgid "" +"The SPF record contains IP ranges, but the SMTP host IP could not be " +"resolved." +msgstr "" +"El registro SPF contiene rangos de IP, pero la IP del servidor SMTP no se pudo " +"resolver." + +#: includes/class-settings-page.php:4785 +msgid "The SPF record does not explicitly reference the configured SMTP host." +msgstr "El registro SPF no hace referencia explícitamente al servidor SMTP configurado." + +#: includes/class-settings-page.php:5075 +msgid "" +"The DMARC policy is set to \"p=none\". Increase it to \"p=quarantine\" or " +"\"p=reject\" to protect the domain." +msgstr "" +"La política DMARC está establecida en \"p=none\". Auméntala a \"p=quarantine\" o " +"\"p=reject\" para proteger el dominio." + +#: includes/class-settings-page.php:5077 +msgid "" +"Consider moving the DMARC policy to \"p=reject\" once you have validated " +"that legitimate messages pass authentication." +msgstr "" +"Considera mover la política DMARC a \"p=reject\" una vez que hayas validado " +"que los mensajes legítimos pasan la autenticación." + +#: includes/class-settings-page.php:5105 +msgid "" +"MX lookups are not available because the DNS functions are disabled on this " +"server." +msgstr "" +"Las búsquedas MX no están disponibles porque las funciones DNS están desactivadas en este " +"servidor." + +#: includes/class-settings-page.php:5113 +msgid "The DNS lookup for MX records failed. Please try again later." +msgstr "La búsqueda DNS de registros MX falló. Por favor, inténtalo de nuevo más tarde." + +#: includes/class-settings-page.php:5251 +msgid "None" +msgstr "Ninguno" + +#: includes/class-settings-page.php:5252 +msgid "SSL" +msgstr "SSL" + +#: includes/class-settings-page.php:5253 +msgid "TLS" +msgstr "TLS" + +#: includes/class-settings-page.php:5410 +msgid "A valid recipient email address is required." +msgstr "Se requiere una dirección de email de destinatario válida." + +#: includes/class-settings-page.php:5435 +msgid "ROBOTSTXT SMTP Test Email" +msgstr "Email de prueba ROBOTSTXT SMTP" + +#. translators: %s: Site name. +#: includes/class-settings-page.php:5438 +#, php-format +msgid "This is a test email sent from %s using the ROBOTSTXT SMTP settings." +msgstr "Este es un email de prueba enviado desde %s usando la configuración de ROBOTSTXT SMTP." + +#: includes/class-settings-page.php:5478 +msgid "The test email could not be sent." +msgstr "No se pudo enviar el email de prueba." + +#: includes/class-settings-page.php:5553 +msgid "The SMTP configuration appears to be working correctly." +msgstr "La configuración SMTP parece estar funcionando correctamente." + +#: includes/class-settings-page.php:5554 +msgid "The SMTP configuration could not be verified." +msgstr "No se pudo verificar la configuración SMTP." + +#: includes/class-settings-page.php:5556 +msgid "Test email sent successfully." +msgstr "Email de prueba enviado correctamente." + +#: includes/class-settings-page.php:5556 +msgid "Test email failed to send." +msgstr "Falló el envío del email de prueba." + +#. translators: %s: Recipient email address. +#: includes/class-settings-page.php:5566 +#, php-format +msgid "Recipient: %s" +msgstr "Destinatario: %s" + +#. translators: %s: Timestamp of the test. +#: includes/class-settings-page.php:5577 +#, php-format +msgid "Timestamp: %s" +msgstr "Marca de tiempo: %s" + +#: includes/class-settings-page.php:5588 +msgid "Error details" +msgstr "Detalles del error" + +#: includes/class-settings-page.php:5594 +msgid "Settings used" +msgstr "Configuración utilizada" + +#: includes/class-settings-page.php:5600 +msgid "Email payload" +msgstr "Contenido del email" + +#: includes/class-settings-page.php:5606 +msgid "SMTP debug output" +msgstr "Salida de depuración SMTP" + +#: includes/class-settings-page.php:5659 includes/class-settings-page.php:5684 +msgid "Send Test Email" +msgstr "Enviar email de prueba" + +#: includes/class-settings-page.php:5668 +msgid "Recipient email address" +msgstr "Dirección de email del destinatario" + +#: includes/class-settings-page.php:5679 +msgid "Leave blank to send the test email to your account email address." +msgstr "Dejar en blanco para enviar el email de prueba a la dirección de email de tu cuenta." + +#: includes/class-settings-page.php:5814 +msgid "Show last:" +msgstr "Mostrar últimos:" + +#: includes/class-settings-page.php:5816 +msgid "7 days" +msgstr "7 días" + +#: includes/class-settings-page.php:5817 +msgid "14 days" +msgstr "14 días" + +#: includes/class-settings-page.php:5818 +msgid "30 days" +msgstr "30 días" + +#: includes/class-settings-page.php:5819 +msgid "60 days" +msgstr "60 días" + +#: includes/class-settings-page.php:5820 +msgid "90 days" +msgstr "90 días" + +#: includes/class-settings-page.php:5822 +msgid "Update" +msgstr "Actualizar" + +#: includes/class-settings-page.php:5827 +msgid "Summary" +msgstr "Resumen" + +#: includes/class-settings-page.php:5829 +msgid "Total emails sent:" +msgstr "Total de emails enviados:" + +#. translators: 1: start date, 2: end date +#: includes/class-settings-page.php:5836 +#, php-format +msgid "Period: %1$s to %2$s" +msgstr "Período: %1$s a %2$s" + +#: includes/class-settings-page.php:5845 +msgid "Emails Sent Per Day" +msgstr "Emails enviados por día" + +#: includes/class-settings-page.php:5853 +msgid "Emails by Site" +msgstr "Emails por sitio" + +#: includes/class-settings-page.php:5857 +msgid "Blog ID" +msgstr "ID del sitio" + +#: includes/class-settings-page.php:5858 +msgid "Site Name" +msgstr "Nombre del sitio" + +#: includes/class-settings-page.php:5859 includes/class-settings-page.php:5898 +msgid "Emails Sent" +msgstr "Emails enviados" + +#. translators: %s: plugin name. +#: robotstxt-smtp.php:108 +#, php-format +msgid "The %s plugin requires the PHPMailer library to be available." +msgstr "El plugin %s requiere que la biblioteca PHPMailer esté disponible." + +#: robotstxt-smtp.php:109 +msgid "ROBOTSTXT SMTP" +msgstr "ROBOTSTXT SMTP" + +#: robotstxt-updater.php:362 +msgid "Security check failed" +msgstr "Falló la comprobación de seguridad" + +#: robotstxt-updater.php:367 +msgid "You do not have sufficient permissions to access this page." +msgstr "No tienes permisos suficientes para acceder a esta página." + +#. Plugin URI of the plugin/theme +msgid "https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp" +msgstr "https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp" + +#. Description of the plugin/theme +msgid "Configure WordPress to send emails through SMTP with detailed controls." +msgstr "Configura WordPress para enviar emails a través de SMTP con controles detallados." + +#. Author of the plugin/theme +msgid "ROBOTSTXT" +msgstr "ROBOTSTXT" + +#. Author URI of the plugin/theme +msgid "https://www.robotstxt.es/" +msgstr "https://www.robotstxt.es/" diff --git a/languages/robotstxt-smtp.pot b/languages/robotstxt-smtp.pot new file mode 100644 index 0000000..65adfc3 --- /dev/null +++ b/languages/robotstxt-smtp.pot @@ -0,0 +1,1374 @@ +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: SMTP (by ROBOTSTXT)\n" +"POT-Creation-Date: 2026-01-29 10:03+0100\n" +"PO-Revision-Date: 2026-01-29 10:02+0100\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" +"X-Generator: Poedit 3.8\n" +"X-Poedit-Basepath: ..\n" +"X-Poedit-Flags-xgettext: --add-comments=translators:\n" +"X-Poedit-WPHeader: robotstxt-smtp.php\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: " +"__;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;_nx_noop:3c,1,2;__ngettext_noop:1,2\n" +"X-Poedit-SearchPath-0: .\n" +"X-Poedit-SearchPathExcluded-0: *.min.js\n" + +#: includes/class-plugin.php:165 includes/class-settings-page.php:381 +#: includes/class-settings-page.php:446 includes/class-settings-page.php:2691 +msgid "SMTP Logs" +msgstr "" + +#: includes/class-plugin.php:166 +msgid "SMTP Log" +msgstr "" + +#: includes/class-plugin.php:457 +msgid "OpenSSL PHP extension is not loaded" +msgstr "" + +#: includes/class-plugin.php:459 +msgid "AES-256-GCM cipher is not supported by OpenSSL" +msgstr "" + +#: includes/class-plugin.php:463 +msgid "AUTH_KEY is not defined in wp-config.php" +msgstr "" + +#: includes/class-plugin.php:467 +msgid "AUTH_SALT is not defined in wp-config.php" +msgstr "" + +#: includes/class-plugin.php:486 +msgid "ROBOTSTXT SMTP: Credential Encryption Unavailable" +msgstr "" + +#: includes/class-plugin.php:489 +msgid "" +"Your SMTP credentials are currently stored without encryption because the " +"following requirements are not met:" +msgstr "" + +#. translators: %s: Link to WordPress security keys documentation +#: includes/class-plugin.php:500 +#, php-format +msgid "" +"To enable credential encryption, please ensure OpenSSL is installed and %s " +"are defined in your wp-config.php file." +msgstr "" + +#: includes/class-plugin.php:501 +msgid "WordPress authentication keys" +msgstr "" + +#: includes/class-plugin.php:507 +msgid "Dismiss for 7 days" +msgstr "" + +#. translators: %d: rate limit per second +#: includes/class-plugin.php:1147 +#, php-format +msgid "Rate limit exceeded: Maximum %d emails per second." +msgstr "" + +#. translators: %d: rate limit per hour +#: includes/class-plugin.php:1163 +#, php-format +msgid "Rate limit exceeded: Maximum %d emails per hour." +msgstr "" + +#. translators: %d: rate limit per day +#: includes/class-plugin.php:1179 +#, php-format +msgid "Rate limit exceeded: Maximum %d emails per 24 hours." +msgstr "" + +#: includes/class-settings-page.php:246 +msgid "You do not have permission to access this page." +msgstr "" + +#. Plugin Name of the plugin/theme +#: includes/class-settings-page.php:344 includes/class-settings-page.php:354 +#: includes/class-settings-page.php:409 includes/class-settings-page.php:419 +#: includes/class-settings-page.php:1081 includes/class-settings-page.php:1106 +msgid "SMTP (by ROBOTSTXT)" +msgstr "" + +#: includes/class-settings-page.php:345 includes/class-settings-page.php:410 +msgid "SMTP" +msgstr "" + +#: includes/class-settings-page.php:355 includes/class-settings-page.php:420 +msgid "Settings" +msgstr "" + +#: includes/class-settings-page.php:363 includes/class-settings-page.php:428 +#: includes/class-settings-page.php:1277 +msgid "SMTP Test" +msgstr "" + +#: includes/class-settings-page.php:364 includes/class-settings-page.php:429 +msgid "Test" +msgstr "" + +#: includes/class-settings-page.php:372 includes/class-settings-page.php:437 +#: includes/class-settings-page.php:1344 +msgid "SMTP Tools" +msgstr "" + +#: includes/class-settings-page.php:373 includes/class-settings-page.php:438 +msgid "Tools" +msgstr "" + +#: includes/class-settings-page.php:382 includes/class-settings-page.php:447 +msgid "Logs" +msgstr "" + +#: includes/class-settings-page.php:390 includes/class-settings-page.php:455 +#: includes/class-settings-page.php:5809 +msgid "Email Statistics" +msgstr "" + +#: includes/class-settings-page.php:391 includes/class-settings-page.php:456 +msgid "Statistics" +msgstr "" + +#: includes/class-settings-page.php:496 +msgid "SMTP Server Configuration" +msgstr "" + +#: includes/class-settings-page.php:505 includes/class-settings-page.php:1174 +msgid "Email Log Settings" +msgstr "" + +#: includes/class-settings-page.php:514 +msgid "Statistics Settings" +msgstr "" + +#: includes/class-settings-page.php:523 includes/class-settings-page.php:1181 +msgid "Rate Limiting" +msgstr "" + +#: includes/class-settings-page.php:640 +msgid "Emails per second" +msgstr "" + +#: includes/class-settings-page.php:646 +msgid "Emails per hour" +msgstr "" + +#: includes/class-settings-page.php:652 +msgid "Emails per day (24 hours)" +msgstr "" + +#: includes/class-settings-page.php:670 +msgid "" +"Rate limits are automatically configured from your Amazon SES account quotas." +msgstr "" + +#. translators: %s: Time elapsed since quotas were fetched +#: includes/class-settings-page.php:685 +#, php-format +msgid "Last updated from Amazon SES: %s ago" +msgstr "" + +#: includes/class-settings-page.php:690 +msgid "Quotas not yet fetched from Amazon SES." +msgstr "" + +#: includes/class-settings-page.php:715 +msgid "Refresh Quotas Now" +msgstr "" + +#: includes/class-settings-page.php:723 +msgid "" +"Configure rate limits to control how many emails can be sent per time " +"period. Set to 0 for unlimited." +msgstr "" + +#: includes/class-settings-page.php:747 includes/class-settings-page.php:798 +#: includes/class-settings-page.php:848 +msgid "Unlimited" +msgstr "" + +#: includes/class-settings-page.php:749 +msgid "Automatically set from Amazon SES MaxSendRate quota." +msgstr "" + +#: includes/class-settings-page.php:754 includes/class-settings-page.php:805 +#: includes/class-settings-page.php:855 +msgid "Not available" +msgstr "" + +#: includes/class-settings-page.php:756 includes/class-settings-page.php:807 +#: includes/class-settings-page.php:857 +msgid "Unable to fetch quota from Amazon SES. Check IAM permissions." +msgstr "" + +#: includes/class-settings-page.php:773 +msgid "Maximum emails per second. 0 = unlimited." +msgstr "" + +#: includes/class-settings-page.php:800 +msgid "" +"Automatically calculated as 90% of maximum throughput (MaxSendRate × 3600 × " +"0.9)." +msgstr "" + +#: includes/class-settings-page.php:824 +msgid "Maximum emails per hour (rolling window). 0 = unlimited." +msgstr "" + +#: includes/class-settings-page.php:850 +msgid "Automatically set from Amazon SES Max24HourSend quota." +msgstr "" + +#: includes/class-settings-page.php:874 +msgid "" +"Maximum emails that can be sent per 24-hour period (rolling window). 0 = " +"unlimited." +msgstr "" + +#: includes/class-settings-page.php:891 includes/class-settings-page.php:1687 +msgid "Host" +msgstr "" + +#: includes/class-settings-page.php:897 +msgid "Username" +msgstr "" + +#: includes/class-settings-page.php:903 +msgid "Password" +msgstr "" + +#: includes/class-settings-page.php:909 +msgid "From Email" +msgstr "" + +#: includes/class-settings-page.php:915 +msgid "From Name" +msgstr "" + +#: includes/class-settings-page.php:921 +msgid "Reply-To Email" +msgstr "" + +#: includes/class-settings-page.php:927 +msgid "Reply-To Name" +msgstr "" + +#: includes/class-settings-page.php:933 +msgid "Security Type" +msgstr "" + +#: includes/class-settings-page.php:939 +msgid "Port" +msgstr "" + +#: includes/class-settings-page.php:967 +msgid "Enable logging" +msgstr "" + +#: includes/class-settings-page.php:973 +msgid "Retention mode" +msgstr "" + +#: includes/class-settings-page.php:978 +msgid "Maximum stored emails" +msgstr "" + +#: includes/class-settings-page.php:984 includes/class-settings-page.php:1000 +msgid "Retention in days" +msgstr "" + +#: includes/class-settings-page.php:1043 includes/class-settings-page.php:1159 +msgid "" +"Amazon SES integration is active. To configure SMTP manually, deactivate the " +"Amazon SES add-on." +msgstr "" + +#: includes/class-settings-page.php:1049 +msgid "Configure the SMTP server used to deliver outgoing emails." +msgstr "" + +#: includes/class-settings-page.php:1058 +msgid "Control how email delivery logs are stored and pruned." +msgstr "" + +#: includes/class-settings-page.php:1067 +msgid "Configure how long email statistics are retained in the database." +msgstr "" + +#: includes/class-settings-page.php:1086 includes/class-settings-page.php:1189 +msgid "Save Changes" +msgstr "" + +#: includes/class-settings-page.php:1121 +msgid "Settings saved." +msgstr "" + +#: includes/class-settings-page.php:1130 +msgid "Configuration scope" +msgstr "" + +#: includes/class-settings-page.php:1131 +msgid "" +"Choose whether to manage the SMTP credentials globally or per individual " +"site." +msgstr "" + +#: includes/class-settings-page.php:1135 +msgid "Mode" +msgstr "" + +#: includes/class-settings-page.php:1140 +msgid "Global network configuration" +msgstr "" + +#: includes/class-settings-page.php:1145 +msgid "Configure each site individually" +msgstr "" + +#: includes/class-settings-page.php:1148 +msgid "" +"When configured globally, all sites in the network will reuse the settings " +"below." +msgstr "" + +#: includes/class-settings-page.php:1156 +msgid "Global SMTP settings" +msgstr "" + +#: includes/class-settings-page.php:1164 +msgid "" +"These credentials are stored for later use but are only applied when the " +"global configuration mode is enabled." +msgstr "" + +#: includes/class-settings-page.php:1204 +msgid "Network settings are only available on multisite installations." +msgstr "" + +#: includes/class-settings-page.php:1213 includes/class-settings-page.php:3392 +#: includes/class-settings-page.php:5267 +msgid "The link you followed has expired." +msgstr "" + +#: includes/class-settings-page.php:1280 +msgid "" +"The network configuration is currently disabled. Tests will use the site-" +"specific settings stored below." +msgstr "" + +#: includes/class-settings-page.php:1319 +msgid "Automatic MX Lookup" +msgstr "" + +#: includes/class-settings-page.php:1320 +msgid "" +"Detects the domain from the configured sender address, retrieves its MX " +"records, and compares them with the SMTP host." +msgstr "" + +#: includes/class-settings-page.php:1324 +msgid "SPF, DKIM, and DMARC Validation" +msgstr "" + +#: includes/class-settings-page.php:1325 +msgid "" +"Checks common DNS TXT records for the sender domain to help you verify email " +"authentication." +msgstr "" + +#: includes/class-settings-page.php:1329 +msgid "Extended SMTP Diagnostics" +msgstr "" + +#: includes/class-settings-page.php:1330 +msgid "" +"Reuses the configured SMTP connection to inspect the server greeting, TLS " +"support, available authentication mechanisms, and EHLO/HELO response codes." +msgstr "" + +#: includes/class-settings-page.php:1334 +msgid "Blacklist Lookup" +msgstr "" + +#: includes/class-settings-page.php:1335 +msgid "" +"Checks the SMTP host IP address against well-known DNS-based reputation " +"lists. Use the feature responsibly and respect each provider’s terms of use." +msgstr "" + +#: includes/class-settings-page.php:1348 +msgid "" +"The network configuration is currently disabled. Tools will use the site-" +"specific settings stored below." +msgstr "" + +#. translators: %s: Human-readable timestamp of the last check. +#: includes/class-settings-page.php:1382 +#, php-format +msgid "Last checked: %s" +msgstr "" + +#: includes/class-settings-page.php:1391 +msgid "Run checks again" +msgstr "" + +#: includes/class-settings-page.php:1400 +msgid "There are no results yet. Click the button below to run this check." +msgstr "" + +#: includes/class-settings-page.php:1405 +msgid "Run checks" +msgstr "" + +#: includes/class-settings-page.php:1649 +msgid "" +"Configure a \"From Email\" address in the settings to analyze the MX records." +msgstr "" + +#: includes/class-settings-page.php:1655 +msgid "Domain:" +msgstr "" + +#: includes/class-settings-page.php:1658 +msgid "Configured SMTP host:" +msgstr "" + +#: includes/class-settings-page.php:1659 +msgid "Not configured" +msgstr "" + +#: includes/class-settings-page.php:1663 +msgid "The MX lookup could not be completed:" +msgstr "" + +#. translators: %s: Domain name extracted from the sender email address. +#: includes/class-settings-page.php:1676 +#, php-format +msgid "No MX records were found for %s." +msgstr "" + +#: includes/class-settings-page.php:1686 +msgid "Priority" +msgstr "" + +#: includes/class-settings-page.php:1688 +msgid "Resolves" +msgstr "" + +#: includes/class-settings-page.php:1689 +msgid "Matches SMTP host" +msgstr "" + +#: includes/class-settings-page.php:1700 includes/class-settings-page.php:1713 +msgid "Yes" +msgstr "" + +#: includes/class-settings-page.php:1702 includes/class-settings-page.php:1715 +msgid "No" +msgstr "" + +#: includes/class-settings-page.php:1704 +msgid "Unknown" +msgstr "" + +#: includes/class-settings-page.php:1735 +msgid "Some MX records could not be resolved to an A or AAAA record:" +msgstr "" + +#. translators: %s: Configured SMTP host. +#: includes/class-settings-page.php:1751 +#, php-format +msgid "" +"At least one MX record points to %s, which matches the configured SMTP host." +msgstr "" + +#. translators: %s: Configured SMTP host. +#: includes/class-settings-page.php:1763 +#, php-format +msgid "None of the MX records point to %s, which is the configured SMTP host." +msgstr "" + +#: includes/class-settings-page.php:1772 +msgid "Configure an SMTP host to compare it against the MX records." +msgstr "" + +#: includes/class-settings-page.php:1805 +msgid "Configure an SMTP host in the settings to run the diagnostics." +msgstr "" + +#: includes/class-settings-page.php:1839 +msgid "Server:" +msgstr "" + +#: includes/class-settings-page.php:1842 +msgid "Configured security:" +msgstr "" + +#: includes/class-settings-page.php:1848 +msgid "Server banner:" +msgstr "" + +#. translators: %s: SMTP server response code. +#: includes/class-settings-page.php:1856 +#, php-format +msgid "code %s" +msgstr "" + +#: includes/class-settings-page.php:1866 +msgid "TLS status" +msgstr "" + +#: includes/class-settings-page.php:1871 +msgid "The connection uses implicit TLS (SMTPS)." +msgstr "" + +#: includes/class-settings-page.php:1873 +msgid "The STARTTLS negotiation succeeded and the connection is encrypted." +msgstr "" + +#: includes/class-settings-page.php:1875 +msgid "The server accepted the TLS negotiation." +msgstr "" + +#: includes/class-settings-page.php:1878 +msgid "TLS is not active for this connection." +msgstr "" + +#: includes/class-settings-page.php:1885 +msgid "STARTTLS response:" +msgstr "" + +#: includes/class-settings-page.php:1899 +msgid "Authentication mechanisms" +msgstr "" + +#: includes/class-settings-page.php:1907 +msgid "The server did not announce authentication mechanisms." +msgstr "" + +#: includes/class-settings-page.php:1910 +msgid "EHLO response" +msgstr "" + +#: includes/class-settings-page.php:1913 includes/class-settings-page.php:1929 +#: includes/class-settings-page.php:1944 +msgid "Status code:" +msgstr "" + +#: includes/class-settings-page.php:1926 +msgid "EHLO after STARTTLS" +msgstr "" + +#: includes/class-settings-page.php:1941 +msgid "HELO response" +msgstr "" + +#: includes/class-settings-page.php:1959 +msgid "View raw transcript" +msgstr "" + +#: includes/class-settings-page.php:2029 +msgid "A valid SMTP host is required to run diagnostics." +msgstr "" + +#: includes/class-settings-page.php:2085 +msgid "Unknown error" +msgstr "" + +#. translators: 1: Error message. 2: Error code. +#: includes/class-settings-page.php:2090 +#, php-format +msgid "Connection failed: %1$s (%2$d)." +msgstr "" + +#: includes/class-settings-page.php:2111 +msgid "The server greeting returned an unexpected status code." +msgstr "" + +#: includes/class-settings-page.php:2125 +msgid "The EHLO response could not be parsed." +msgstr "" + +#: includes/class-settings-page.php:2127 +msgid "The server did not accept the EHLO command." +msgstr "" + +#: includes/class-settings-page.php:2132 +msgid "The server did not advertise STARTTLS support." +msgstr "" + +#: includes/class-settings-page.php:2151 +msgid "The TLS negotiation failed after STARTTLS." +msgstr "" + +#: includes/class-settings-page.php:2157 +msgid "" +"The server supports STARTTLS. Enable TLS in the configuration to protect the " +"connection." +msgstr "" + +#: includes/class-settings-page.php:2161 +msgid "No authentication mechanisms were advertised by the server." +msgstr "" + +#: includes/class-settings-page.php:2172 +msgid "The legacy HELO command did not return a successful status code." +msgstr "" + +#: includes/class-settings-page.php:2180 +msgid "The connection is not encrypted. Credentials may travel in plain text." +msgstr "" + +#: includes/class-settings-page.php:2356 +msgid "" +"Configure a \"From Email\" address in the settings to analyze SPF, DKIM, and " +"DMARC records." +msgstr "" + +#: includes/class-settings-page.php:2374 +msgid "SPF" +msgstr "" + +#: includes/class-settings-page.php:2386 +msgid "No SPF record was found for the sender domain." +msgstr "" + +#: includes/class-settings-page.php:2410 +msgid "DKIM" +msgstr "" + +#: includes/class-settings-page.php:2422 +msgid "A DKIM record was found for the default selector." +msgstr "" + +#: includes/class-settings-page.php:2429 +msgid "" +"No DKIM record was found for the default selector. Confirm the selector " +"provided by your email service and publish the corresponding TXT record." +msgstr "" + +#: includes/class-settings-page.php:2433 +msgid "DMARC" +msgstr "" + +#: includes/class-settings-page.php:2445 +msgid "No DMARC record was found for the sender domain." +msgstr "" + +#. translators: %s: DMARC policy value. +#: includes/class-settings-page.php:2455 +#, php-format +msgid "Published policy: %s" +msgstr "" + +#: includes/class-settings-page.php:2472 +msgid "The DMARC policy enforces protection for the domain." +msgstr "" + +#: includes/class-settings-page.php:2515 +msgid "" +"IPv6 addresses are currently not checked because most DNSBL providers only " +"publish IPv4 data. Verify IPv6 reputation manually with your email service." +msgstr "" + +#: includes/class-settings-page.php:2523 +msgid "" +"The SMTP host did not resolve to any IPv4 addresses. Configure a valid host " +"or allow DNS lookups on the server to perform blacklist checks." +msgstr "" + +#. translators: %s: IP address used for the blacklist lookup. +#: includes/class-settings-page.php:2533 +#, php-format +msgid "IP address: %s" +msgstr "" + +#: includes/class-settings-page.php:2552 +msgid "Provider" +msgstr "" + +#: includes/class-settings-page.php:2553 includes/class-settings-page.php:3115 +#: includes/class-settings-page.php:3290 +msgid "Status" +msgstr "" + +#: includes/class-settings-page.php:2554 +msgid "Impact" +msgstr "" + +#: includes/class-settings-page.php:2555 +msgid "Details" +msgstr "" + +#: includes/class-settings-page.php:2556 +msgid "Removal guidance" +msgstr "" + +#: includes/class-settings-page.php:2569 +msgid "Unavailable" +msgstr "" + +#: includes/class-settings-page.php:2571 +msgid "Listed" +msgstr "" + +#: includes/class-settings-page.php:2573 +msgid "Not listed" +msgstr "" + +#: includes/class-settings-page.php:2584 +msgid "Response:" +msgstr "" + +#: includes/class-settings-page.php:2596 +msgid "No additional TXT details were returned by the provider." +msgstr "" + +#: includes/class-settings-page.php:2599 +msgid "The IP address is not currently listed by this provider." +msgstr "" + +#: includes/class-settings-page.php:2608 +msgid "Open removal request page" +msgstr "" + +#: includes/class-settings-page.php:2695 +msgid "The link you followed has expired. Please try again." +msgstr "" + +#: includes/class-settings-page.php:2701 +msgid "All log entries were removed." +msgstr "" + +#: includes/class-settings-page.php:2707 +msgid "" +"Log entries are stored per site. The table below reflects the currently " +"selected site." +msgstr "" + +#: includes/class-settings-page.php:2713 +msgid "" +"Logging is currently disabled. Enable it in the settings page to store new " +"emails." +msgstr "" + +#: includes/class-settings-page.php:3054 +msgid "From date" +msgstr "" + +#: includes/class-settings-page.php:3058 +msgid "To date" +msgstr "" + +#: includes/class-settings-page.php:3062 includes/class-settings-page.php:3118 +#: includes/class-settings-page.php:3306 +msgid "Subject" +msgstr "" + +#: includes/class-settings-page.php:3066 includes/class-settings-page.php:3117 +#: includes/class-settings-page.php:3302 +msgid "To" +msgstr "" + +#: includes/class-settings-page.php:3070 +msgid "Results per page" +msgstr "" + +#: includes/class-settings-page.php:3078 +msgid "Apply filters" +msgstr "" + +#: includes/class-settings-page.php:3081 +msgid "Reset" +msgstr "" + +#: includes/class-settings-page.php:3092 +msgid "Are you sure you want to delete all log entries?" +msgstr "" + +#: includes/class-settings-page.php:3094 +msgid "Clear Logs" +msgstr "" + +#: includes/class-settings-page.php:3107 +msgid "No email logs have been stored yet." +msgstr "" + +#: includes/class-settings-page.php:3114 includes/class-settings-page.php:3286 +msgid "Date" +msgstr "" + +#: includes/class-settings-page.php:3116 includes/class-settings-page.php:3298 +msgid "From" +msgstr "" + +#: includes/class-settings-page.php:3119 +msgid "Actions" +msgstr "" + +#: includes/class-settings-page.php:3127 includes/class-settings-page.php:3209 +msgid "(No subject)" +msgstr "" + +#: includes/class-settings-page.php:3157 +msgid "View details" +msgstr "" + +#: includes/class-settings-page.php:3172 +msgid "«" +msgstr "" + +#: includes/class-settings-page.php:3173 +msgid "»" +msgstr "" + +#: includes/class-settings-page.php:3198 +msgid "The requested log entry could not be found." +msgstr "" + +#: includes/class-settings-page.php:3281 +msgid "Back to list" +msgstr "" + +#: includes/class-settings-page.php:3310 +msgid "Error message" +msgstr "" + +#: includes/class-settings-page.php:3316 +msgid "No error recorded." +msgstr "" + +#: includes/class-settings-page.php:3324 +msgid "Headers" +msgstr "" + +#: includes/class-settings-page.php:3325 +msgid "No headers stored for this email." +msgstr "" + +#: includes/class-settings-page.php:3327 +msgid "Attachments" +msgstr "" + +#: includes/class-settings-page.php:3335 +msgid "No attachments were logged for this email." +msgstr "" + +#: includes/class-settings-page.php:3338 +msgid "Message content" +msgstr "" + +#: includes/class-settings-page.php:3342 +msgid "This email did not include any content." +msgstr "" + +#: includes/class-settings-page.php:3345 +msgid "SMTP debug log" +msgstr "" + +#: includes/class-settings-page.php:3348 +msgid "Show SMTP conversation" +msgstr "" + +#: includes/class-settings-page.php:3352 +msgid "No SMTP debug output was stored for this email." +msgstr "" + +#: includes/class-settings-page.php:3370 +msgid "Failed" +msgstr "" + +#: includes/class-settings-page.php:3377 +msgid "Sent" +msgstr "" + +#. translators: 1: Example SMTP host. 2: Example SMTP host. +#: includes/class-settings-page.php:3445 +#, php-format +msgid "" +"Use the fully qualified address of your SMTP server, for example %1$s or " +"%2$s." +msgstr "" + +#: includes/class-settings-page.php:3470 +msgid "" +"Usually this is the full email address or dedicated SMTP user provided by " +"your email service." +msgstr "" + +#: includes/class-settings-page.php:3482 +msgid "Leave empty to keep the current password." +msgstr "" + +#: includes/class-settings-page.php:3493 +msgid "" +"Enter the password or app-specific password for the SMTP user. Leave empty " +"to retain the existing value." +msgstr "" + +#: includes/class-settings-page.php:3513 +msgid "" +"This address will be used as the default sender for emails sent by " +"WordPress, for example notifications@example.com." +msgstr "" + +#: includes/class-settings-page.php:3532 +msgid "" +"Recipients will see this name alongside the email address, such as \"Support " +"Team\" or the site title." +msgstr "" + +#: includes/class-settings-page.php:3552 +msgid "" +"Optional. Email address where replies should be sent. If empty, replies will " +"go to the From Email address." +msgstr "" + +#: includes/class-settings-page.php:3571 +msgid "" +"Optional. Name that will appear with the Reply-To address. If empty, the " +"From Name will be used." +msgstr "" + +#: includes/class-settings-page.php:3589 +msgid "" +"Choose the encryption method recommended by your provider. The default ports " +"are 25 for None, 465 for SSL, and 587 for TLS." +msgstr "" + +#: includes/class-settings-page.php:3610 +msgid "" +"Set the port required by your SMTP server. Common values are 25 (None), 465 " +"(SSL), and 587 (TLS)." +msgstr "" + +#: includes/class-settings-page.php:3630 +msgid "Store a copy of every sent email in the logs." +msgstr "" + +#: includes/class-settings-page.php:3632 +msgid "" +"Logged emails are saved as private posts under SMTP Logs so you can review " +"the content or clear them at any time." +msgstr "" + +#: includes/class-settings-page.php:3653 +msgid "Limit by number of emails" +msgstr "" + +#: includes/class-settings-page.php:3663 +msgid "Limit by age (in days)" +msgstr "" + +#: includes/class-settings-page.php:3666 +msgid "" +"Select how the log cleaner should decide which entries to remove: by keeping " +"a fixed number or by removing items older than a number of days." +msgstr "" + +#: includes/class-settings-page.php:3686 +msgid "" +"Maximum number of emails to keep when using the count-based retention mode." +msgstr "" + +#: includes/class-settings-page.php:3706 +msgid "" +"Number of days to keep log entries when using the time-based retention mode." +msgstr "" + +#: includes/class-settings-page.php:3727 +msgid "" +"Number of days to keep email statistics. Statistics older than this will be " +"automatically deleted daily. Minimum: 1 day, Maximum: 365 days." +msgstr "" + +#: includes/class-settings-page.php:3848 +msgid "" +"The \"From Email\" address is not valid. Please provide a valid email " +"address." +msgstr "" + +#: includes/class-settings-page.php:3865 +msgid "" +"The \"Reply-To Email\" address is not valid. Please provide a valid email " +"address." +msgstr "" + +#: includes/class-settings-page.php:3885 +msgid "" +"The AWS Access Key format is invalid. It should start with AKIA followed by " +"16 alphanumeric characters." +msgstr "" + +#: includes/class-settings-page.php:3900 +msgid "" +"The AWS Secret Key format is invalid. It should be 40 characters of base64-" +"encoded data." +msgstr "" + +#. translators: %d: Invalid port number entered by user +#: includes/class-settings-page.php:3948 +#, php-format +msgid "" +"The port number \"%d\" is invalid. Port must be between 1 and 65535. Using " +"default port 25." +msgstr "" + +#. translators: %s: IP address +#: includes/class-settings-page.php:4102 +#, php-format +msgid "" +"The SMTP hostname resolves to a private IP address (%s) which is not allowed " +"for security reasons. If you need to connect to a local SMTP server in " +"development, add this to wp-config.php: " +"define( 'ROBOTSTXT_SMTP_ALLOW_PRIVATE_IPS', true );" +msgstr "" + +#: includes/class-settings-page.php:4292 +msgid "The sender domain could not be determined." +msgstr "" + +#: includes/class-settings-page.php:4298 includes/class-settings-page.php:4588 +#: includes/class-settings-page.php:4988 includes/class-settings-page.php:5037 +msgid "" +"DNS lookups are not available because the DNS functions are disabled on this " +"server." +msgstr "" + +#: includes/class-settings-page.php:4329 +msgid "" +"Blacklist lookups are not available because the DNS functions are disabled " +"on this server." +msgstr "" + +#: includes/class-settings-page.php:4374 +msgid "Spamhaus ZEN" +msgstr "" + +#: includes/class-settings-page.php:4376 +msgid "" +"High — major inbox providers rely on Spamhaus and a listing can block most " +"traffic." +msgstr "" + +#: includes/class-settings-page.php:4378 +msgid "" +"Investigate and resolve the root cause, then use the Spamhaus Blocklist " +"Removal Center to request delisting." +msgstr "" + +#: includes/class-settings-page.php:4382 +msgid "SpamCop" +msgstr "" + +#: includes/class-settings-page.php:4384 +msgid "" +"Medium — many shared hosts and spam filters consult SpamCop when scoring " +"messages." +msgstr "" + +#: includes/class-settings-page.php:4386 +msgid "" +"Ensure no unsolicited traffic is sent and follow the SpamCop blocklist " +"removal instructions." +msgstr "" + +#: includes/class-settings-page.php:4390 +msgid "Barracuda Reputation Block List" +msgstr "" + +#: includes/class-settings-page.php:4392 +msgid "" +"Medium — Barracuda appliances and some hosted filters can defer or reject " +"messages." +msgstr "" + +#: includes/class-settings-page.php:4394 +msgid "" +"Review the Barracuda reputation lookup and submit a delisting request after " +"addressing any spam complaints." +msgstr "" + +#: includes/class-settings-page.php:4502 +msgid "The IP address could not be normalized for the DNSBL lookup." +msgstr "" + +#. translators: %s: DNSBL provider name. +#. translators: %s: Domain queried for the DKIM record lookup. +#. translators: %s: Domain queried for the DMARC record lookup. +#: includes/class-settings-page.php:4513 includes/class-settings-page.php:4998 +#: includes/class-settings-page.php:5047 +#, php-format +msgid "The DNS lookup for %s failed. Please try again later." +msgstr "" + +#: includes/class-settings-page.php:4584 +msgid "" +"Unable to determine whether the SMTP host is authorized in the SPF record." +msgstr "" + +#: includes/class-settings-page.php:4596 +msgid "The DNS lookup for TXT records failed. Please try again later." +msgstr "" + +#: includes/class-settings-page.php:4614 +msgid "The domain does not publish an SPF record." +msgstr "" + +#: includes/class-settings-page.php:4621 +msgid "Configure an SMTP host to verify its presence in the SPF record." +msgstr "" + +#. translators: %s: Included SPF domain. +#: includes/class-settings-page.php:4677 +#, php-format +msgid "The SPF record includes %s, which matches the configured SMTP host." +msgstr "" + +#. translators: %s: Hostname authorized via the SPF "a" mechanism. +#: includes/class-settings-page.php:4690 includes/class-settings-page.php:4701 +#, php-format +msgid "The SPF record authorizes %s via the \"a\" mechanism." +msgstr "" + +#. translators: %s: Hostname authorized via the SPF "mx" mechanism. +#: includes/class-settings-page.php:4714 includes/class-settings-page.php:4724 +#, php-format +msgid "The SPF record authorizes %s via the \"mx\" mechanism." +msgstr "" + +#. translators: %1$s: IP address. %2$s: SPF mechanism. +#: includes/class-settings-page.php:4739 includes/class-settings-page.php:4760 +#, php-format +msgid "The SPF record authorizes the SMTP host IP %1$s via %2$s." +msgstr "" + +#: includes/class-settings-page.php:4779 +msgid "" +"The SMTP host was not found in the SPF record. Add it to avoid delivery " +"issues." +msgstr "" + +#: includes/class-settings-page.php:4782 +msgid "" +"The SPF record contains IP ranges, but the SMTP host IP could not be " +"resolved." +msgstr "" + +#: includes/class-settings-page.php:4785 +msgid "The SPF record does not explicitly reference the configured SMTP host." +msgstr "" + +#: includes/class-settings-page.php:5075 +msgid "" +"The DMARC policy is set to \"p=none\". Increase it to \"p=quarantine\" or " +"\"p=reject\" to protect the domain." +msgstr "" + +#: includes/class-settings-page.php:5077 +msgid "" +"Consider moving the DMARC policy to \"p=reject\" once you have validated " +"that legitimate messages pass authentication." +msgstr "" + +#: includes/class-settings-page.php:5105 +msgid "" +"MX lookups are not available because the DNS functions are disabled on this " +"server." +msgstr "" + +#: includes/class-settings-page.php:5113 +msgid "The DNS lookup for MX records failed. Please try again later." +msgstr "" + +#: includes/class-settings-page.php:5251 +msgid "None" +msgstr "" + +#: includes/class-settings-page.php:5252 +msgid "SSL" +msgstr "" + +#: includes/class-settings-page.php:5253 +msgid "TLS" +msgstr "" + +#: includes/class-settings-page.php:5410 +msgid "A valid recipient email address is required." +msgstr "" + +#: includes/class-settings-page.php:5435 +msgid "ROBOTSTXT SMTP Test Email" +msgstr "" + +#. translators: %s: Site name. +#: includes/class-settings-page.php:5438 +#, php-format +msgid "This is a test email sent from %s using the ROBOTSTXT SMTP settings." +msgstr "" + +#: includes/class-settings-page.php:5478 +msgid "The test email could not be sent." +msgstr "" + +#: includes/class-settings-page.php:5553 +msgid "The SMTP configuration appears to be working correctly." +msgstr "" + +#: includes/class-settings-page.php:5554 +msgid "The SMTP configuration could not be verified." +msgstr "" + +#: includes/class-settings-page.php:5556 +msgid "Test email sent successfully." +msgstr "" + +#: includes/class-settings-page.php:5556 +msgid "Test email failed to send." +msgstr "" + +#. translators: %s: Recipient email address. +#: includes/class-settings-page.php:5566 +#, php-format +msgid "Recipient: %s" +msgstr "" + +#. translators: %s: Timestamp of the test. +#: includes/class-settings-page.php:5577 +#, php-format +msgid "Timestamp: %s" +msgstr "" + +#: includes/class-settings-page.php:5588 +msgid "Error details" +msgstr "" + +#: includes/class-settings-page.php:5594 +msgid "Settings used" +msgstr "" + +#: includes/class-settings-page.php:5600 +msgid "Email payload" +msgstr "" + +#: includes/class-settings-page.php:5606 +msgid "SMTP debug output" +msgstr "" + +#: includes/class-settings-page.php:5659 includes/class-settings-page.php:5684 +msgid "Send Test Email" +msgstr "" + +#: includes/class-settings-page.php:5668 +msgid "Recipient email address" +msgstr "" + +#: includes/class-settings-page.php:5679 +msgid "Leave blank to send the test email to your account email address." +msgstr "" + +#: includes/class-settings-page.php:5814 +msgid "Show last:" +msgstr "" + +#: includes/class-settings-page.php:5816 +msgid "7 days" +msgstr "" + +#: includes/class-settings-page.php:5817 +msgid "14 days" +msgstr "" + +#: includes/class-settings-page.php:5818 +msgid "30 days" +msgstr "" + +#: includes/class-settings-page.php:5819 +msgid "60 days" +msgstr "" + +#: includes/class-settings-page.php:5820 +msgid "90 days" +msgstr "" + +#: includes/class-settings-page.php:5822 +msgid "Update" +msgstr "" + +#: includes/class-settings-page.php:5827 +msgid "Summary" +msgstr "" + +#: includes/class-settings-page.php:5829 +msgid "Total emails sent:" +msgstr "" + +#. translators: 1: start date, 2: end date +#: includes/class-settings-page.php:5836 +#, php-format +msgid "Period: %1$s to %2$s" +msgstr "" + +#: includes/class-settings-page.php:5845 +msgid "Emails Sent Per Day" +msgstr "" + +#: includes/class-settings-page.php:5853 +msgid "Emails by Site" +msgstr "" + +#: includes/class-settings-page.php:5857 +msgid "Blog ID" +msgstr "" + +#: includes/class-settings-page.php:5858 +msgid "Site Name" +msgstr "" + +#: includes/class-settings-page.php:5859 includes/class-settings-page.php:5898 +msgid "Emails Sent" +msgstr "" + +#. translators: %s: plugin name. +#: robotstxt-smtp.php:108 +#, php-format +msgid "The %s plugin requires the PHPMailer library to be available." +msgstr "" + +#: robotstxt-smtp.php:109 +msgid "ROBOTSTXT SMTP" +msgstr "" + +#: robotstxt-updater.php:362 +msgid "Security check failed" +msgstr "" + +#: robotstxt-updater.php:367 +msgid "You do not have sufficient permissions to access this page." +msgstr "" + +#. Plugin URI of the plugin/theme +msgid "https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp" +msgstr "" + +#. Description of the plugin/theme +msgid "Configure WordPress to send emails through SMTP with detailed controls." +msgstr "" + +#. Author of the plugin/theme +msgid "ROBOTSTXT" +msgstr "" + +#. Author URI of the plugin/theme +msgid "https://www.robotstxt.es/" +msgstr "" diff --git a/readme.txt b/readme.txt index 846650b..b119e12 100644 --- a/readme.txt +++ b/readme.txt @@ -1,84 +1,88 @@ -=== SMTP (by ROBOTSTXT) === -Contributors: robotstxt -Tags: smtp, email, mail -Requires at least: 6.0 -Tested up to: 6.9 -Requires PHP: 8.2 -Stable tag: 1.2.0 -License: GPLv3 or later -License URI: https://www.gnu.org/licenses/gpl-3.0.html - -Send every site email through a fully configurable SMTP server managed from the WordPress dashboard. - -== Description == - -SMTP (by ROBOTSTXT) replaces WordPress' native mail delivery with a secure SMTP connection and detailed guidance. The plugin is built for marketing teams, agencies, and technical departments that need a clear, complete solution ready for multisite installations. - -= Guided PHPMailer configuration = - -* Routes `wp_mail()` through PHPMailer in SMTP mode with support for credentials, custom ports, and the `None`, `SSL`, or `TLS` encryption methods. -* Adds inline help text with practical examples in every field: host, port, username, password, sender email, and sender name. -* Automatically changes the port when it matches the default value for the selected encryption type (25, 465, or 587). -* Lets you set default sender information for the site to keep a consistent identity across outgoing messages. - -= Tools for support and marketing teams = - -* **Settings → SMTP → Test** screen for sending manual test emails and confirming the connection to the server. -* **Tools** panel packed with diagnostics: automatic MX lookup, SPF/DKIM/DMARC checks, extended SMTP server diagnostics, and DNS reputation monitoring. -* Caches results from each tool for 24 hours (with a manual refresh option) to streamline recurring tasks for your team. - -= Comprehensive delivery logs = - -* Saves the subject, recipients, headers, content, and attachments for every email sent. -* Browse logs from **Settings → SMTP → Logs** with pagination and access to the details of each delivery. -* Configure automatic cleanup by maximum entries or age in days, plus an instant "Clear all" button to wipe the history. - -= Multisite-ready configuration = - -* Choose whether the configuration applies to the entire network or individually per site. -* Dedicated forms in both the network dashboard and each site to edit, test, and share credentials securely. - -== Installation == - -1. Upload the plugin folder to `wp-content/plugins/`. -2. Activate **SMTP (by ROBOTSTXT)** from the **Plugins** menu in the WordPress dashboard. -3. Open **Settings → SMTP** (or **Network Settings → SMTP** in multisite) to enter your connection details. - -== Frequently Asked Questions == - -= Do I need credentials to send email? = - -Enter a username and password only if your provider requires them. If the server accepts unauthenticated delivery, leave the fields blank and the plugin will send without credentials. - -= Which encryption should I use? = - -Select `None`, `SSL`, or `TLS` according to your provider's documentation. When you switch encryption, the plugin will automatically suggest the recommended port if you are using one of the standard values. - -= How can I review the emails that were sent? = - -Enable logging on the settings page and visit **Settings → SMTP → Logs** to open the paginated table of saved emails. From there you can inspect each entry, download attachments, and delete records. - -= Does it work on a multisite network? = - -Yes. From the network dashboard you can decide whether the configuration is global or site-specific. You can also run the tools and send test emails from the network or from each individual site. - -== Changelog == - -= 1.2.0 = - -* Logged failed email deliveries with status and error details in the log list and detail views. -* Captured the SMTP debug conversation for each email and surfaced it inside the log detail view. - -= 1.1.0 = - -* Added Amazon SES credential fields, regional selection, and live validation helpers that appear when the Amazon SES add-on is active. -* Introduced the `robotstxt_smtp_sanitized_options` filter so add-ons can adjust sanitized settings before they are stored. -* Routed SMTP test messages and regular WordPress emails through Amazon SES whenever the add-on supplies valid credentials. - -= 1.0.0 = - -* Contextual help guidance in every SMTP configuration field. -* Automatic port updates when selecting an encryption method with standard values. -* Advanced tools: MX analysis, SPF/DKIM/DMARC validation, extended SMTP diagnostics, and blacklist monitoring. -* Enhanced logging with automatic cleanup by limit or age. -* Updated documentation for the 1.0.0 release with WordPress 6.7 and PHP 8.2 support. +=== SMTP (by ROBOTSTXT) === +Contributors: javiercasares +Tags: smtp, email, mail +Requires at least: 6.5 +Tested up to: 6.9 +Stable tag: 2.0.0 +Requires PHP: 8.2 +Version: 2.0.0 +License: GPL-3.0-or-later +License URI: https://www.gnu.org/licenses/gpl-3.0.html + +Send every site email through a fully configurable SMTP server managed from the WordPress dashboard. + +== Description == + +SMTP (by ROBOTSTXT) replaces WordPress' native mail delivery with a secure SMTP connection and detailed guidance. The plugin is built for marketing teams, agencies, and technical departments that need a clear, complete solution ready for multisite installations. + += Guided PHPMailer configuration = + +* Routes `wp_mail()` through PHPMailer in SMTP mode with support for credentials, custom ports, and the `None`, `SSL`, or `TLS` encryption methods. +* Adds inline help text with practical examples in every field: host, port, username, password, sender email, and sender name. +* Automatically changes the port when it matches the default value for the selected encryption type (25, 465, or 587). +* Lets you set default sender information for the site to keep a consistent identity across outgoing messages. + += Tools for support and marketing teams = + +* **Settings → SMTP → Test** screen for sending manual test emails and confirming the connection to the server. +* **Tools** panel packed with diagnostics: automatic MX lookup, SPF/DKIM/DMARC checks, extended SMTP server diagnostics, and DNS reputation monitoring. +* Caches results from each tool for 24 hours (with a manual refresh option) to streamline recurring tasks for your team. + += Comprehensive delivery logs = + +* Saves the subject, recipients, headers, content, and attachments for every email sent. +* Browse logs from **Settings → SMTP → Logs** with pagination and access to the details of each delivery. +* Configure automatic cleanup by maximum entries or age in days, plus an instant "Clear all" button to wipe the history. + += Multisite-ready configuration = + +* Choose whether the configuration applies to the entire network or individually per site. +* Dedicated forms in both the network dashboard and each site to edit, test, and share credentials securely. + +== Installation == + +1. Upload the plugin folder to `wp-content/plugins/`. +2. Activate **SMTP (by ROBOTSTXT)** from the **Plugins** menu in the WordPress dashboard. +3. Open **Settings → SMTP** (or **Network Settings → SMTP** in multisite) to enter your connection details. + +== Frequently Asked Questions == + += Do I need credentials to send email? = + +Enter a username and password only if your provider requires them. If the server accepts unauthenticated delivery, leave the fields blank and the plugin will send without credentials. + += Which encryption should I use? = + +Select `None`, `SSL`, or `TLS` according to your provider's documentation. When you switch encryption, the plugin will automatically suggest the recommended port if you are using one of the standard values. + += How can I review the emails that were sent? = + +Enable logging on the settings page and visit **Settings → SMTP → Logs** to open the paginated table of saved emails. From there you can inspect each entry, download attachments, and delete records. + += Does it work on a multisite network? = + +Yes. From the network dashboard you can decide whether the configuration is global or site-specific. You can also run the tools and send test emails from the network or from each individual site. + +== Changelog == + += 2.0.0 = + +* Added Reply-To email and name configuration fields for custom reply addresses. +* Added email statistics tracking system with daily counters and visual charts. +* Added statistics page with Chart.js visualization and multisite support. +* Added statistics retention settings (configurable from 1 to 365 days). +* Implemented security improvements and password field enhancements. + += 1.1.0 = + +* Added Amazon SES credential fields, regional selection, and live validation helpers that appear when the Amazon SES add-on is active. +* Introduced the `robotstxt_smtp_sanitized_options` filter so add-ons can adjust sanitized settings before they are stored. +* Routed SMTP test messages and regular WordPress emails through Amazon SES whenever the add-on supplies valid credentials. + += 1.0.0 = + +* Contextual help guidance in every SMTP configuration field. +* Automatic port updates when selecting an encryption method with standard values. +* Advanced tools: MX analysis, SPF/DKIM/DMARC validation, extended SMTP diagnostics, and blacklist monitoring. +* Enhanced logging with automatic cleanup by limit or age. +* Updated documentation for the 1.0.0 release with WordPress 6.7 and PHP 8.2 support. diff --git a/robotstxt-smtp.php b/robotstxt-smtp.php index 230bd6d..f24c024 100644 --- a/robotstxt-smtp.php +++ b/robotstxt-smtp.php @@ -1,120 +1,131 @@ -id && 'plugins-network' !== $screen->id ) { - return; - } - - $message = sprintf( - /* translators: %s: plugin name. */ - esc_html__( 'The %s plugin requires the PHPMailer library to be available.', 'robotstxt-smtp' ), - esc_html__( 'ROBOTSTXT SMTP', 'robotstxt-smtp' ) - ); - ?> -
-

-
- run(); -} else { - robotstxt_smtp_register_dependency_notice(); -} +id && 'plugins-network' !== $screen->id ) { + return; + } + + $message = sprintf( + /* translators: %s: plugin name. */ + esc_html__( 'The %s plugin requires the PHPMailer library to be available.', 'robotstxt-smtp' ), + esc_html__( 'ROBOTSTXT SMTP', 'robotstxt-smtp' ) + ); + ?> +
+

+
+ run(); +} else { + robotstxt_smtp_register_dependency_notice(); +} + +// Initialize ROBOTSTXT updater (auto-configures from plugin headers). +require_once __DIR__ . '/robotstxt-updater.php'; +Robotstxt_Updater::init( __FILE__ ); diff --git a/robotstxt-updater.php b/robotstxt-updater.php new file mode 100644 index 0000000..2e26d14 --- /dev/null +++ b/robotstxt-updater.php @@ -0,0 +1,383 @@ +register(); + } + + /** + * Constructor. + * + * @param string $plugin_file_path Absolute path to the main plugin file. + */ + private function __construct( string $plugin_file_path ) { + $this->plugin_file_path = $plugin_file_path; + $this->plugin_basename = plugin_basename( $plugin_file_path ); + $this->plugin_slug = dirname( $this->plugin_basename ); + $this->plugin_data = $this->get_plugin_data(); + $this->json_url = $this->build_json_url(); + $this->cache_key = 'robotstxt_updater_' . md5( $this->plugin_basename ); + } + + /** + * Register WordPress hooks. + */ + private function register(): void { + add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'inject_update_info' ) ); + add_filter( 'plugins_api', array( $this, 'provide_plugin_details' ), 10, 3 ); + add_action( 'admin_init', array( $this, 'handle_cache_clear' ) ); + add_action( 'robotstxt_updater_clear_cache', array( $this, 'clear_cache' ) ); + } + + /** + * Get plugin headers. + * + * @return array Plugin data. + */ + private function get_plugin_data(): array { + if ( ! function_exists( 'get_plugin_data' ) ) { + require_once ABSPATH . 'wp-admin/includes/plugin.php'; + } + + return get_plugin_data( $this->plugin_file_path, false, false ); + } + + /** + * Build JSON URL from plugin headers. + * + * Tries to use "Gitea Plugin URI" header to construct the URL. + * Falls back to Plugin URI if Gitea URI is not available. + * + * @return string JSON URL. + */ + private function build_json_url(): string { + // Try Gitea Plugin URI (format: "OWNER/REPO" or full URL). + if ( ! empty( $this->plugin_data['Gitea Plugin URI'] ) ) { + $gitea_uri = $this->plugin_data['Gitea Plugin URI']; + + // If it's already a full URL, use it. + if ( str_starts_with( $gitea_uri, 'http' ) ) { + // Extract base URL and construct JSON path. + return rtrim( $gitea_uri, '/' ) . '/raw/branch/main/update.json'; + } + + // If it's in format "OWNER/REPO", construct full URL. + if ( preg_match( '#^[^/]+/[^/]+$#', $gitea_uri ) ) { + return "https://git.robotstxt.es/{$gitea_uri}/raw/branch/main/update.json"; + } + } + + // Fallback: try to extract from Plugin URI. + if ( ! empty( $this->plugin_data['PluginURI'] ) ) { + $plugin_uri = $this->plugin_data['PluginURI']; + if ( str_contains( $plugin_uri, 'git.robotstxt.es' ) ) { + return rtrim( $plugin_uri, '/' ) . '/raw/branch/main/update.json'; + } + } + + // Last resort: construct from plugin slug. + return "https://git.robotstxt.es/ROBOTSTXT/{$this->plugin_slug}/raw/branch/main/update.json"; + } + + /** + * Inject update info into WP's plugin update transient. + * + * @param object|mixed $transient The update_plugins transient. + * + * @return object The modified transient. + */ + public function inject_update_info( $transient ) { + if ( ! is_object( $transient ) ) { + $transient = new stdClass(); + } + + if ( empty( $transient->checked ) || ! is_array( $transient->checked ) ) { + return $transient; + } + + if ( empty( $transient->checked[ $this->plugin_basename ] ) ) { + return $transient; + } + + $current_version = $transient->checked[ $this->plugin_basename ]; + $remote = $this->get_remote_data(); + + if ( empty( $remote['version'] ) || empty( $remote['download_url'] ) ) { + return $transient; + } + + if ( ! $this->is_compatible( $remote ) ) { + return $transient; + } + + if ( version_compare( $remote['version'], $current_version, '>' ) ) { + $update = (object) array( + 'slug' => $remote['slug'] ?? $this->plugin_slug, + 'plugin' => $this->plugin_basename, + 'new_version' => $remote['version'], + 'url' => $remote['homepage'] ?? $this->plugin_data['PluginURI'] ?? '', + 'package' => $remote['download_url'], + 'tested' => $remote['tested'] ?? '', + 'requires' => $remote['requires'] ?? '', + 'requires_php' => $remote['requires_php'] ?? '', + ); + + $transient->response[ $this->plugin_basename ] = $update; + } + + return $transient; + } + + /** + * Provide "View details" modal content. + * + * @param false|object|array $result The result object or array. + * @param string $action The type of information being requested. + * @param object $args Plugin API arguments. + * + * @return false|object The plugin information object or false. + */ + public function provide_plugin_details( $result, string $action, object $args ) { + if ( 'plugin_information' !== $action ) { + return $result; + } + + if ( empty( $args->slug ) || $args->slug !== $this->plugin_slug ) { + return $result; + } + + $remote = $this->get_remote_data(); + + if ( empty( $remote['version'] ) ) { + return $result; + } + + return (object) array( + 'name' => $remote['name'] ?? $this->plugin_data['Name'] ?? $this->plugin_slug, + 'slug' => $remote['slug'] ?? $this->plugin_slug, + 'version' => $remote['version'], + 'author' => $remote['author'] ?? $this->plugin_data['Author'] ?? '', + 'homepage' => $remote['homepage'] ?? $this->plugin_data['PluginURI'] ?? '', + 'requires' => $remote['requires'] ?? '', + 'tested' => $remote['tested'] ?? '', + 'requires_php' => $remote['requires_php'] ?? '', + 'sections' => array( + 'description' => $remote['description'] ?? $this->plugin_data['Description'] ?? '', + 'changelog' => $remote['changelog'] ?? '', + ), + 'download_link' => $remote['download_url'] ?? '', + ); + } + + /** + * Get remote data with caching and HMAC signature verification. + * + * @return array Remote data. + */ + private function get_remote_data(): array { + $cached = get_site_transient( $this->cache_key ); + + // Verify HMAC signature if AUTH_SALT is defined and cache has signature. + if ( false !== $cached && defined( 'AUTH_SALT' ) && '' !== AUTH_SALT ) { + if ( is_array( $cached ) && isset( $cached['signature'], $cached['data'] ) ) { + $expected_sig = hash_hmac( 'sha256', $this->cache_key . serialize( $cached['data'] ), AUTH_SALT ); + + if ( hash_equals( $expected_sig, $cached['signature'] ) ) { + // Signature valid, return data. + return is_array( $cached['data'] ) ? $cached['data'] : array(); + } + + // Signature invalid, delete corrupted cache. + delete_site_transient( $this->cache_key ); + $cached = false; + } + } + + // If no valid cache, fetch fresh data. + if ( false === $cached ) { + $remote = $this->fetch_json(); + + // Store with HMAC signature if AUTH_SALT is available. + if ( defined( 'AUTH_SALT' ) && '' !== AUTH_SALT ) { + $payload = array( + 'data' => $remote ?: array(), + 'timestamp' => time(), + 'signature' => hash_hmac( 'sha256', $this->cache_key . serialize( $remote ?: array() ), AUTH_SALT ), + ); + set_site_transient( $this->cache_key, $payload, 6 * HOUR_IN_SECONDS ); + } else { + // Fallback to standard caching. + set_site_transient( $this->cache_key, $remote ?: array(), 6 * HOUR_IN_SECONDS ); + } + + return is_array( $remote ) ? $remote : array(); + } + + // Legacy cache format without signature (backward compatibility). + return is_array( $cached ) ? $cached : array(); + } + + /** + * Fetch JSON from remote URL. + * + * @return array Decoded JSON data. + */ + private function fetch_json(): array { + $response = wp_remote_get( + $this->json_url, + array( + 'timeout' => 10, + 'headers' => array( + 'Accept' => 'application/json', + ), + ) + ); + + if ( is_wp_error( $response ) ) { + return array(); + } + + $code = (int) wp_remote_retrieve_response_code( $response ); + if ( $code < 200 || $code >= 300 ) { + return array(); + } + + $body = wp_remote_retrieve_body( $response ); + $data = json_decode( $body, true ); + + return is_array( $data ) ? $data : array(); + } + + /** + * Check compatibility. + * + * @param array $remote Remote data. + * + * @return bool True if compatible. + */ + private function is_compatible( array $remote ): bool { + if ( ! empty( $remote['requires_php'] ) ) { + if ( version_compare( PHP_VERSION, $remote['requires_php'], '<' ) ) { + return false; + } + } + + if ( ! empty( $remote['requires'] ) ) { + if ( version_compare( get_bloginfo( 'version' ), $remote['requires'], '<' ) ) { + return false; + } + } + + return true; + } + + /** + * Handle manual cache clear via URL parameter. + */ + public function handle_cache_clear(): void { + // Check if this is a cache clear request first. + $clear_cache = filter_input( INPUT_GET, 'robotstxt_clear_update_cache', FILTER_UNSAFE_RAW ); + if ( null === $clear_cache ) { + return; + } + + // This is a cache clear request - now verify nonce. + $nonce_raw = filter_input( INPUT_GET, '_wpnonce', FILTER_UNSAFE_RAW ); + $nonce = $nonce_raw ? sanitize_text_field( wp_unslash( $nonce_raw ) ) : ''; + + if ( ! wp_verify_nonce( $nonce, 'robotstxt_clear_update_cache' ) ) { + wp_die( esc_html__( 'Security check failed', 'robotstxt-smtp' ) ); + } + + // Check permissions. + if ( ! current_user_can( 'update_plugins' ) ) { + wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'robotstxt-smtp' ) ); + } + + $this->clear_cache(); + wp_safe_redirect( remove_query_arg( array( 'robotstxt_clear_update_cache', '_wpnonce' ) ) ); + exit; + } + + /** + * Clear update cache. + */ + public function clear_cache(): void { + delete_site_transient( $this->cache_key ); + delete_site_transient( 'update_plugins' ); + } + } +} diff --git a/uninstall.php b/uninstall.php index 39915c0..177f2dd 100644 --- a/uninstall.php +++ b/uninstall.php @@ -1,155 +1,155 @@ -get_col( - $wpdb->prepare( - "SELECT meta_key FROM {$wpdb->sitemeta} WHERE meta_key LIKE %s OR meta_key LIKE %s", - $wpdb->esc_like( $stored_prefix ) . '%', - $wpdb->esc_like( $timeout_prefix ) . '%' - ) - ); - } else { - $stored_prefix = '_transient_' . $prefix; - $timeout_prefix = '_transient_timeout_' . $prefix; - $delete_callback = 'delete_transient'; - $timeout_prefix_length = strlen( '_transient_timeout_' ); - $stored_prefix_length = strlen( '_transient_' ); - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching - $matches = $wpdb->get_col( - $wpdb->prepare( - "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE %s OR option_name LIKE %s", - $wpdb->esc_like( $stored_prefix ) . '%', - $wpdb->esc_like( $timeout_prefix ) . '%' - ) - ); - } - - if ( empty( $matches ) ) { - return; - } - - foreach ( $matches as $option_name ) { - if ( ! is_string( $option_name ) ) { - continue; - } - - if ( str_starts_with( $option_name, $is_network ? '_site_transient_timeout_' : '_transient_timeout_' ) ) { - $transient_key = substr( $option_name, $timeout_prefix_length ); - } else { - $transient_key = substr( $option_name, $stored_prefix_length ); - } - - if ( '' === $transient_key ) { - continue; - } - - call_user_func( $delete_callback, $transient_key ); - } - } -} - -if ( ! function_exists( 'robotstxt_smtp_uninstall_delete_logs' ) ) { - /** - * Deletes all stored SMTP logs for the current site. - * - * @since 1.1.1 - * - * @return void - */ - function robotstxt_smtp_uninstall_delete_logs(): void { - do { - $logs = get_posts( - array( - 'post_type' => 'robotstxt_smtp_log', - 'post_status' => 'any', - 'fields' => 'ids', - 'posts_per_page' => 100, - 'orderby' => 'ID', - 'order' => 'ASC', - ) - ); - - foreach ( $logs as $log_id ) { - wp_delete_post( (int) $log_id, true ); - } - } while ( ! empty( $logs ) ); - } -} - -robotstxt_smtp_uninstall_cleanup_network(); - -if ( function_exists( 'is_multisite' ) && is_multisite() ) { - $sites = get_sites( array( 'fields' => 'ids' ) ); - - foreach ( $sites as $site_id ) { - switch_to_blog( (int) $site_id ); - robotstxt_smtp_uninstall_cleanup_site(); - restore_current_blog(); - } -} else { - robotstxt_smtp_uninstall_cleanup_site(); -} +get_col( + $wpdb->prepare( + "SELECT meta_key FROM {$wpdb->sitemeta} WHERE meta_key LIKE %s OR meta_key LIKE %s", + $wpdb->esc_like( $stored_prefix ) . '%', + $wpdb->esc_like( $timeout_prefix ) . '%' + ) + ); + } else { + $stored_prefix = '_transient_' . $prefix; + $timeout_prefix = '_transient_timeout_' . $prefix; + $delete_callback = 'delete_transient'; + $timeout_prefix_length = strlen( '_transient_timeout_' ); + $stored_prefix_length = strlen( '_transient_' ); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching + $matches = $wpdb->get_col( + $wpdb->prepare( + "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE %s OR option_name LIKE %s", + $wpdb->esc_like( $stored_prefix ) . '%', + $wpdb->esc_like( $timeout_prefix ) . '%' + ) + ); + } + + if ( empty( $matches ) ) { + return; + } + + foreach ( $matches as $option_name ) { + if ( ! is_string( $option_name ) ) { + continue; + } + + if ( str_starts_with( $option_name, $is_network ? '_site_transient_timeout_' : '_transient_timeout_' ) ) { + $transient_key = substr( $option_name, $timeout_prefix_length ); + } else { + $transient_key = substr( $option_name, $stored_prefix_length ); + } + + if ( '' === $transient_key ) { + continue; + } + + call_user_func( $delete_callback, $transient_key ); + } + } +} + +if ( ! function_exists( 'robotstxt_smtp_uninstall_delete_logs' ) ) { + /** + * Deletes all stored SMTP logs for the current site. + * + * @since 1.1.1 + * + * @return void + */ + function robotstxt_smtp_uninstall_delete_logs(): void { + do { + $logs = get_posts( + array( + 'post_type' => 'robotstxt_smtp_log', + 'post_status' => 'any', + 'fields' => 'ids', + 'posts_per_page' => 100, + 'orderby' => 'ID', + 'order' => 'ASC', + ) + ); + + foreach ( $logs as $log_id ) { + wp_delete_post( (int) $log_id, true ); + } + } while ( ! empty( $logs ) ); + } +} + +robotstxt_smtp_uninstall_cleanup_network(); + +if ( function_exists( 'is_multisite' ) && is_multisite() ) { + $robotstxt_smtp_sites = get_sites( array( 'fields' => 'ids' ) ); + + foreach ( $robotstxt_smtp_sites as $robotstxt_smtp_site_id ) { + switch_to_blog( (int) $robotstxt_smtp_site_id ); + robotstxt_smtp_uninstall_cleanup_site(); + restore_current_blog(); + } +} else { + robotstxt_smtp_uninstall_cleanup_site(); +} diff --git a/update.json b/update.json new file mode 100644 index 0000000..ff6b339 --- /dev/null +++ b/update.json @@ -0,0 +1,27 @@ +{ + "name": "SMTP (by ROBOTSTXT)", + "slug": "robotstxt-smtp", + "version": "2.0.0", + "download_url": "https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp/releases/download/2.0.0/robotstxt-smtp-2.0.0.zip", + "requires": "6.5", + "requires_php": "8.2", + "tested": "6.9", + "last_updated": "2026-01-29", + "author": "ROBOTSTXT", + "author_profile": "https://www.robotstxt.es/", + "homepage": "https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp", + "description": "Configure WordPress to send emails through SMTP with detailed controls. Supports multiple SMTP providers, logging, diagnostics, and network/site-level configuration.", + "changelog": "

2.0.0 - 2026-01-29

  • Security: Comprehensive security audit and hardening
  • Security: Enhanced nonce validation across all forms and actions
  • Security: Improved input sanitization and validation
  • Security: Enhanced password encryption and migration
  • Security: Secure handling of superglobals and transients
  • Security: Strengthened regex patterns and port number validation
  • Added: Reply-To header support for Amazon SES
  • Fixed: Access control and form handling improvements
  • Fixed: WordPress Multisite rate limiting enhancements
  • Fixed: Empty password field handling
  • Improved: Code quality and PHPDoc documentation

1.2.0 - 2026-01-27

  • Enhanced DNS blacklist checking with error handling
  • Added rate limiting for DNSBL queries
  • Improved caching mechanism for DNS results
  • Fixed warnings in SMTP diagnostics
  • Security improvements and code optimization
", + "sections": { + "description": "Configure WordPress to send emails through SMTP with detailed controls. Supports multiple SMTP providers, logging, diagnostics, and network/site-level configuration.", + "changelog": "

2.0.0 - 2026-01-29

  • Security: Comprehensive security audit and hardening
  • Security: Enhanced nonce validation across all forms and actions
  • Security: Improved input sanitization and validation
  • Security: Enhanced password encryption and migration
  • Security: Secure handling of superglobals and transients
  • Security: Strengthened regex patterns and port number validation
  • Added: Reply-To header support for Amazon SES
  • Fixed: Access control and form handling improvements
  • Fixed: WordPress Multisite rate limiting enhancements
  • Fixed: Empty password field handling
  • Improved: Code quality and PHPDoc documentation

1.2.0 - 2026-01-27

  • Enhanced DNS blacklist checking with error handling
  • Added rate limiting for DNSBL queries
  • Improved caching mechanism for DNS results
  • Fixed warnings in SMTP diagnostics
  • Security improvements and code optimization
" + }, + "banners": { + "low": "", + "high": "" + }, + "icons": { + "1x": "", + "2x": "" + } +}