diff --git a/composer.json b/composer.json index cc54b7aa665119d8d167ede5b17c3a4b40eeb07b..707e144a0a8e9859ba8d1009739b1d5f059877d1 100644 --- a/composer.json +++ b/composer.json @@ -157,7 +157,7 @@ "drupal/simple_megamenu": "1.0-beta3", "drupal/simple_sitemap": "^3.0", "drupal/simplesamlphp_auth": "3.0", - "drupal/smtp": "1.0-beta4", + "drupal/smtp": "1.x-dev#84f789cbba894290cf82ed2558c8a4e7e24f3c89", "drupal/social_media": "^1.3", "drupal/social_media_links": "^2.6", "drupal/superfish": "1.2", @@ -213,6 +213,9 @@ "ln -s ../vendor/simplesamlphp/simplesamlphp/www web/simplesaml", "DrupalProject\\composer\\ScriptHandler::createRequiredFiles" ], + "post-package-install": [ + "rm -rf web/modules/smtp/.git" + ], "post-update-cmd": [ "DrupalProject\\composer\\ScriptHandler::createRequiredFiles" ], @@ -276,6 +279,9 @@ }, "drupal/entity_embed": { "2881745": "https://www.drupal.org/files/issues/2018-12-04/2881745-22.patch" + }, + "drupal/smtp": { + "2781157": "https://www.drupal.org/files/issues/2018-11-07/2781157-n10.patch" } } }, diff --git a/composer.lock b/composer.lock index 425c0d01b0bb3e0b4796f1cc4c3238ebfda91b34..27eddb17796b3208000fa099d22837ba81ab6432 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "769a2f27603a88c2ab01fb352de955ea", + "content-hash": "f1a3322d7f0802f2868bb22c0febf809", "packages": [ { "name": "alchemy/zippy", @@ -5047,7 +5047,8 @@ "homepage": "https://www.drupal.org/project/migrate_devel", "support": { "source": "http://cgit.drupalcode.org/migrate_devel" - } + }, + "time": "2017-06-25T23:46:13+00:00" }, { "name": "drupal/migrate_plus", @@ -5957,17 +5958,11 @@ }, { "name": "drupal/smtp", - "version": "1.0.0-beta4", + "version": "dev-1.x", "source": { "type": "git", "url": "https://git.drupal.org/project/smtp", - "reference": "8.x-1.0-beta4" - }, - "dist": { - "type": "zip", - "url": "https://ftp.drupal.org/files/projects/smtp-8.x-1.0-beta4.zip", - "reference": "8.x-1.0-beta4", - "shasum": "80a4df4b2fd2d1b2dc653552d232ce98cb54bb9d" + "reference": "84f789cbba894290cf82ed2558c8a4e7e24f3c89" }, "require": { "drupal/core": "~8.0" @@ -5978,12 +5973,15 @@ "dev-1.x": "1.x-dev" }, "drupal": { - "version": "8.x-1.0-beta4", - "datestamp": "1527598380", + "version": "8.x-1.0-beta4+26-dev", + "datestamp": "1533298680", "security-coverage": { "status": "not-covered", - "message": "Beta releases are not covered by Drupal security advisories." + "message": "Dev releases are not covered by Drupal security advisories." } + }, + "patches_applied": { + "2781157": "https://www.drupal.org/files/issues/2018-11-07/2781157-n10.patch" } }, "notification-url": "https://packages.drupal.org/8/downloads", @@ -11035,6 +11033,7 @@ "drupal/migrate_devel": 20, "drupal/realname": 5, "drupal/roleassign": 15, + "drupal/smtp": 20, "drupal/view_unpublished": 15 }, "prefer-stable": true, diff --git a/patches/smtp-make-timeout-configurable-2781157-n10.patch b/patches/smtp-make-timeout-configurable-2781157-n10.patch new file mode 100644 index 0000000000000000000000000000000000000000..dc68062a689eba7d1aea648bcbb2ae4d623736f9 --- /dev/null +++ b/patches/smtp-make-timeout-configurable-2781157-n10.patch @@ -0,0 +1,106 @@ +diff --git a/config/install/smtp.settings.yml b/config/install/smtp.settings.yml +index 7b9865e..bf8d3a0 100644 +--- a/config/install/smtp.settings.yml ++++ b/config/install/smtp.settings.yml +@@ -3,6 +3,7 @@ smtp_host: '' + smtp_hostbackup: '' + smtp_port: '25' + smtp_protocol: 'standard' ++smtp_timeout: 30 + smtp_username: '' + smtp_password: '' + smtp_from: '' +diff --git a/config/schema/smtp.schema.yml b/config/schema/smtp.schema.yml +index cda9cd0..1128d11 100644 +--- a/config/schema/smtp.schema.yml ++++ b/config/schema/smtp.schema.yml +@@ -17,6 +17,9 @@ smtp.settings: + smtp_protocol: + type: string + label: 'Use encrypted protocol' ++ smtp_timeout: ++ type: integer ++ label: 'Amount of seconds for the SMTP command to timeout' + smtp_username: + type: string + label: 'Username' +diff --git a/smtp.install b/smtp.install +index 389f250..e1fe0e5 100644 +--- a/smtp.install ++++ b/smtp.install +@@ -16,9 +16,18 @@ function smtp_uninstall() { + $default_system_mail = 'php_mail'; + $mail_config = $config->getEditable('system.mail'); + $default_interface = (!$smtp_config->get('prev_mail_system')) ? $smtp_config->get('prev_mail_system') : $default_system_mail; +- $mail_config ->set('interface.default', $default_interface) ++ $mail_config->set('interface.default', $default_interface) + ->save(); + + // Cleaning garbage. + $smtp_config->delete(); + } ++ ++/** ++ * Add SMTP timeout configuration and change default to 30. ++ */ ++function smtp_update_8001() { ++ \Drupal::configFactory()->getEditable('smtp.settings') ++ ->set('smtp_timeout', 30) ++ ->save(TRUE); ++} +diff --git a/src/Form/SMTPConfigForm.php b/src/Form/SMTPConfigForm.php +index e6c93aa..a459f33 100644 +--- a/src/Form/SMTPConfigForm.php ++++ b/src/Form/SMTPConfigForm.php +@@ -133,7 +133,13 @@ class SMTPConfigForm extends ConfigFormBase { + '#description' => $encryption_description, + '#disabled' => $this->isOverridden('smtp_protocol'), + ]; +- ++ $form['server']['smtp_timeout'] = [ ++ '#type' => 'textfield', ++ '#title' => t('Timeout'), ++ '#default_value' => $config->get('smtp_timeout'), ++ '#description' => t('Amount of seconds for the SMTP commands to timeout.'), ++ '#disabled' => $this->isOverridden('smtp_timeout'), ++ ]; + $form['auth'] = [ + '#type' => 'details', + '#title' => $this->t('SMTP Authentication'), +@@ -157,7 +163,7 @@ class SMTPConfigForm extends ConfigFormBase { + + $form['email_options'] = [ + '#type' => 'details', +- '#title' =>$this->t('E-mail options'), ++ '#title' => $this->t('E-mail options'), + '#open' => TRUE, + ]; + $form['email_options']['smtp_from'] = [ +@@ -300,6 +306,7 @@ class SMTPConfigForm extends ConfigFormBase { + 'smtp_hostbackup', + 'smtp_port', + 'smtp_protocol', ++ 'smtp_timeout', + 'smtp_username', + 'smtp_from', + 'smtp_fromname', +diff --git a/src/Plugin/Mail/SMTPMailSystem.php b/src/Plugin/Mail/SMTPMailSystem.php +index 1ca4205..8967a08 100644 +--- a/src/Plugin/Mail/SMTPMailSystem.php ++++ b/src/Plugin/Mail/SMTPMailSystem.php +@@ -141,6 +141,7 @@ class SMTPMailSystem implements MailInterface, ContainerFactoryPluginInterface { + + // Create a new PHPMailer object - autoloaded from registry. + $mailer = new PHPMailer(); ++ $mailer->Timeout = $this->smtpConfig->get('smtp_timeout'); + + // Turn on debugging, if requested. + if ($this->smtpConfig->get('smtp_debugging') && \Drupal::currentUser()->hasPermission('administer smtp module')) { +@@ -250,7 +251,6 @@ class SMTPMailSystem implements MailInterface, ContainerFactoryPluginInterface { + $mailer->ContentType = $content_type = 'multipart/alternative'; + + // Get the boundary ID from the Content-Type header. +- + $boundary = $this->getSubstring($value, 'boundary', '"', '"'); + break; + diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 2ab7cfadbb1e7b04919a686eb14cb57d0d99f850..c909ef42f0116245ce51dde0ff27c77bc6ae4adb 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -6145,18 +6145,12 @@ }, { "name": "drupal/smtp", - "version": "1.0.0-beta4", - "version_normalized": "1.0.0.0-beta4", + "version": "dev-1.x", + "version_normalized": "dev-1.x", "source": { "type": "git", "url": "https://git.drupal.org/project/smtp", - "reference": "8.x-1.0-beta4" - }, - "dist": { - "type": "zip", - "url": "https://ftp.drupal.org/files/projects/smtp-8.x-1.0-beta4.zip", - "reference": "8.x-1.0-beta4", - "shasum": "80a4df4b2fd2d1b2dc653552d232ce98cb54bb9d" + "reference": "84f789cbba894290cf82ed2558c8a4e7e24f3c89" }, "require": { "drupal/core": "~8.0" @@ -6167,15 +6161,18 @@ "dev-1.x": "1.x-dev" }, "drupal": { - "version": "8.x-1.0-beta4", - "datestamp": "1527598380", + "version": "8.x-1.0-beta4+26-dev", + "datestamp": "1533298680", "security-coverage": { "status": "not-covered", - "message": "Beta releases are not covered by Drupal security advisories." + "message": "Dev releases are not covered by Drupal security advisories." } + }, + "patches_applied": { + "2781157": "https://www.drupal.org/files/issues/2018-11-07/2781157-n10.patch" } }, - "installation-source": "dist", + "installation-source": "source", "notification-url": "https://packages.drupal.org/8/downloads", "license": [ "GPL-2.0" diff --git a/web/modules/smtp/LICENSE.txt b/web/modules/smtp/LICENSE.txt deleted file mode 100644 index d159169d1050894d3ea3b98e1c965c4058208fe1..0000000000000000000000000000000000000000 --- a/web/modules/smtp/LICENSE.txt +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) 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 -this service 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 make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. 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. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the 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 a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE 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. - - 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 -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - 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 2 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, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision 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, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -This 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. diff --git a/web/modules/smtp/PATCHES.txt b/web/modules/smtp/PATCHES.txt new file mode 100644 index 0000000000000000000000000000000000000000..40f313d9c52db0c1d7109b7b7d2adbf9d7f5657b --- /dev/null +++ b/web/modules/smtp/PATCHES.txt @@ -0,0 +1,7 @@ +This file was automatically generated by Composer Patches (https://github.com/cweagans/composer-patches) +Patches applied to this directory: + +2781157 +Source: https://www.drupal.org/files/issues/2018-11-07/2781157-n10.patch + + diff --git a/web/modules/smtp/README.txt b/web/modules/smtp/README.txt index 2ae3a916a4df2683120619b30fa39547b9cfe139..db7cc836188bd5ae71fe8034318dc1e93705180d 100644 --- a/web/modules/smtp/README.txt +++ b/web/modules/smtp/README.txt @@ -4,7 +4,7 @@ This module adds SMTP functionality to Drupal. REQUIREMENTS ------------ * Access to an SMTP server -* The following PHP extensions need to be installed: ereg, hash, date & pcre. +* The following PHP extensions need to be installed: hash, date & pcre. * Optional: To connect to an SMTP server using SSL, you need to have the openssl package installed on your server, and your webserver and PHP @@ -32,8 +32,8 @@ important for this to be the correct address and some ISPs will block email that comes from an invalid address. This module no longer uses the PHPMailer package as an external library, instead -a slimmed down version of the library have been relicensed and integrated with the -smtp module. +a slimmed down version of the library have been relicensed and integrated with +the smtp module. Connecting to an SMTP server using SSL is possible only if PHP's openssl extension is working. If the SMTP module detects openssl is available it diff --git a/web/modules/smtp/config/install/smtp.settings.yml b/web/modules/smtp/config/install/smtp.settings.yml index 7b9865e25063690a7a190d86e0400a6335291b1b..bf8d3a021d7e64bab22e1fdd3ddf80f0972ff084 100644 --- a/web/modules/smtp/config/install/smtp.settings.yml +++ b/web/modules/smtp/config/install/smtp.settings.yml @@ -3,6 +3,7 @@ smtp_host: '' smtp_hostbackup: '' smtp_port: '25' smtp_protocol: 'standard' +smtp_timeout: 30 smtp_username: '' smtp_password: '' smtp_from: '' diff --git a/web/modules/smtp/config/schema/smtp.schema.yml b/web/modules/smtp/config/schema/smtp.schema.yml index cda9cd068eb74439986ebb9c2cf1113ece2e5ab0..1128d1144a5267446b3bce9b6db220a272266dbf 100644 --- a/web/modules/smtp/config/schema/smtp.schema.yml +++ b/web/modules/smtp/config/schema/smtp.schema.yml @@ -17,6 +17,9 @@ smtp.settings: smtp_protocol: type: string label: 'Use encrypted protocol' + smtp_timeout: + type: integer + label: 'Amount of seconds for the SMTP command to timeout' smtp_username: type: string label: 'Username' diff --git a/web/modules/smtp/smtp.info.yml b/web/modules/smtp/smtp.info.yml index ecf2b3d30bbf83551d4c94d96452e73c57b358b1..6acdb25050cf56be6a5a99210fbc17f7a9c66ff9 100644 --- a/web/modules/smtp/smtp.info.yml +++ b/web/modules/smtp/smtp.info.yml @@ -2,11 +2,5 @@ name: SMTP Authentication Support description: "Allow for site emails to be sent through an SMTP server of your choice." package: Mail type: module -# core: 8.x +core: 8.x configure: smtp.config - -# Information added by Drupal.org packaging script on 2018-05-29 -version: '8.x-1.0-beta4' -core: '8.x' -project: 'smtp' -datestamp: 1527598397 diff --git a/web/modules/smtp/smtp.install b/web/modules/smtp/smtp.install index 389f2507a9565f5cd7d56c9b29b48e6427990101..e1fe0e54f2d9b11ff687d573f6ae9b144034b823 100644 --- a/web/modules/smtp/smtp.install +++ b/web/modules/smtp/smtp.install @@ -16,9 +16,18 @@ function smtp_uninstall() { $default_system_mail = 'php_mail'; $mail_config = $config->getEditable('system.mail'); $default_interface = (!$smtp_config->get('prev_mail_system')) ? $smtp_config->get('prev_mail_system') : $default_system_mail; - $mail_config ->set('interface.default', $default_interface) + $mail_config->set('interface.default', $default_interface) ->save(); // Cleaning garbage. $smtp_config->delete(); } + +/** + * Add SMTP timeout configuration and change default to 30. + */ +function smtp_update_8001() { + \Drupal::configFactory()->getEditable('smtp.settings') + ->set('smtp_timeout', 30) + ->save(TRUE); +} diff --git a/web/modules/smtp/smtp.module b/web/modules/smtp/smtp.module index 258a878f0b2f0bea662a2775881598d8202294e5..eb0b2086d75bc11113c7c953e93ff0c80a313bc9 100644 --- a/web/modules/smtp/smtp.module +++ b/web/modules/smtp/smtp.module @@ -27,18 +27,6 @@ function smtp_help($route_name, RouteMatchInterface $route_match) { } } -/** - * Implements hook_menu(). - */ -function smtp_menu() { - $items['admin/config/system/smtp'] = [ - 'title' => 'SMTP Authentication Support', - 'description' => 'Allow for site emails to be sent through an SMTP server of your choice.', - 'route_name' => 'smtp.config', - ]; - return $items; -} - /** * Implements hook_mail(). */ diff --git a/web/modules/smtp/src/Exception/PHPMailerException.php b/web/modules/smtp/src/Exception/PHPMailerException.php new file mode 100644 index 0000000000000000000000000000000000000000..86cc9c02160a46b71313b2f26990327f23cce53e --- /dev/null +++ b/web/modules/smtp/src/Exception/PHPMailerException.php @@ -0,0 +1,10 @@ +<?php + +namespace Drupal\smtp\Exception; + +/** + * General exception for errors thrown by PHPMailer. + */ +class PHPMailerException extends \Exception { + +} diff --git a/web/modules/smtp/src/Form/SMTPConfigForm.php b/web/modules/smtp/src/Form/SMTPConfigForm.php index 97d46bdd0a78821beb73d3ed1a2b963e9a6f07da..a459f33c48c8d6546c3ae99300bd4e9a3070cc7a 100644 --- a/web/modules/smtp/src/Form/SMTPConfigForm.php +++ b/web/modules/smtp/src/Form/SMTPConfigForm.php @@ -6,7 +6,6 @@ use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Messenger\Messenger; -use Drupal\smtp\Plugin\Mail\SMTPMailSystem; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -47,7 +46,7 @@ public static function create(ContainerInterface $container) { /** * {@inheritdoc} */ - public function getFormID() { + public function getFormId() { return 'smtp_admin_settings'; } @@ -134,7 +133,13 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#description' => $encryption_description, '#disabled' => $this->isOverridden('smtp_protocol'), ]; - + $form['server']['smtp_timeout'] = [ + '#type' => 'textfield', + '#title' => t('Timeout'), + '#default_value' => $config->get('smtp_timeout'), + '#description' => t('Amount of seconds for the SMTP commands to timeout.'), + '#disabled' => $this->isOverridden('smtp_timeout'), + ]; $form['auth'] = [ '#type' => 'details', '#title' => $this->t('SMTP Authentication'), @@ -158,7 +163,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['email_options'] = [ '#type' => 'details', - '#title' =>$this->t('E-mail options'), + '#title' => $this->t('E-mail options'), '#open' => TRUE, ]; $form['email_options']['smtp_from'] = [ @@ -232,7 +237,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { * Check if config variable is overridden by the settings.php. * * @param string $name - * STMP settings key. + * SMTP settings key. * * @return bool * Boolean. @@ -270,6 +275,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) { if (empty($values['smtp_username'])) { $values['smtp_password'] = ''; } + // A little hack. When form is presented, // the password is not shown (Drupal way of doing). // So, if user submits the form without changing the password, @@ -300,6 +306,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { 'smtp_hostbackup', 'smtp_port', 'smtp_protocol', + 'smtp_timeout', 'smtp_username', 'smtp_from', 'smtp_fromname', @@ -325,9 +332,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) { else { $default_system_mail = 'php_mail'; $mail_config = $this->configFactory->getEditable('system.mail'); - $default_interface = ($mail_config->get('prev_mail_system')) ? $mail_config->get('prev_mail_system') : $default_system_mail; - $mail_config->set('interface.default', $default_interface) - ->save(); + $default_interface = $mail_config->get('prev_mail_system') ? $mail_config->get('prev_mail_system') : $default_system_mail; + $mail_config->set('interface.default', $default_interface)->save(); } // If an address was given, send a test e-mail message. @@ -335,6 +341,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $params['subject'] = $this->t('Drupal SMTP test e-mail'); $params['body'] = [$this->t('If you receive this message it means your site is capable of using SMTP to send e-mail.')]; $account = \Drupal::currentUser(); + // If module is off, send the test message // with SMTP by temporarily overriding. if (!$config->get('smtp_on')) { @@ -342,10 +349,12 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $mail_system = 'SMTPMailSystem'; $mail_config->set('interface.default', $mail_system)->save(); } + \Drupal::service('plugin.manager.mail')->mail('smtp', 'smtp-test', $test_address, $account->getPreferredLangcode(), $params); if (!$config->get('smtp_on')) { $mail_config->set('interface', $original)->save(); } + $this->messenger->addMessage($this->t('A test e-mail has been sent to @email via SMTP. You may want to check the log for any error messages.', ['@email' => $test_address])); } @@ -354,9 +363,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { /** * {@inheritdoc} - * - * @todo - Flesh this out. */ - public function getEditableConfigNames() {} + protected function getEditableConfigNames() {} } diff --git a/web/modules/smtp/src/PHPMailer/PHPMailer.php b/web/modules/smtp/src/PHPMailer/PHPMailer.php index ece2aae5a2e6fb2d755c4b1dcf414c2c33dc5ce9..f71a186ddca6f30407b97b010a47458d7163c590 100644 --- a/web/modules/smtp/src/PHPMailer/PHPMailer.php +++ b/web/modules/smtp/src/PHPMailer/PHPMailer.php @@ -1,5 +1,7 @@ <?php +// @codingStandardsIgnoreFile + /*~ class.phpmailer.php Orginal release information: .---------------------------------------------------------------------------. @@ -32,7 +34,7 @@ namespace Drupal\smtp\PHPMailer; use Drupal\smtp\PHPMailer\SMTP; -use Drupal\smtp\Plugin\Exception\PHPMailerException; +use Drupal\smtp\Exception\PHPMailerException; /** * PHPMailer - PHP email transport class @@ -460,11 +462,12 @@ private function AddAnAddress($kind, $address, $name = '') { $address = trim($address); $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim if (!self::ValidateAddress($address)) { - $this->SetError(t('Invalid address') . ': ' . $address); + $invalidAddress = t('Invalid address: @address', ['address' => $address]); + $this->SetError($invalidAddress); if ($this->exceptions) { - throw new phpmailerException(t('Invalid address') . ': ' . $address); + throw new PHPMailerException($invalidAddress); } - echo t('Invalid address') . ': ' . $address; + echo $invalidAddress; return FALSE; } if ($kind != 'ReplyTo') { @@ -493,11 +496,12 @@ public function SetFrom($address, $name = '', $auto=1) { $address = trim($address); $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim if (!self::ValidateAddress($address)) { - $this->SetError(t('Invalid address') . ': ' . $address); + $invalidAddress = t('Invalid address: @address', ['address' => $address]); + $this->SetError($invalidAddress); if ($this->exceptions) { - throw new phpmailerException(t('Invalid address') . ': ' . $address); + throw new PHPMailerException($invalidAddress); } - echo t('Invalid address') . ': ' . $address; + echo $invalidAddress; return FALSE; } $this->From = $address; @@ -551,7 +555,7 @@ public static function ValidateAddress($address) { public function Send() { try { if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) { - throw new phpmailerException(t('You must provide at least one recipient email address.'), self::STOP_CRITICAL); + throw new PHPMailerException(t('You must provide at least one recipient email address.'), self::STOP_CRITICAL); } // Set whether the message is multipart/alternative @@ -565,7 +569,7 @@ public function Send() { $body = $this->CreateBody(); if (empty($this->Body)) { - throw new phpmailerException(t('Message body empty'), self::STOP_CRITICAL); + throw new PHPMailerException(t('Message body empty'), self::STOP_CRITICAL); } // digitally sign with DKIM if enabled @@ -584,7 +588,7 @@ public function Send() { return $this->MailSend($header, $body); } - } catch (phpmailerException $e) { + } catch (PHPMailerException $e) { $this->SetError($e->getMessage()); if ($this->exceptions) { throw $e; @@ -611,7 +615,7 @@ protected function SendmailSend($header, $body) { if ($this->SingleTo === TRUE) { foreach ($this->SingleToArray as $key => $val) { if (!@$mail = popen($sendmail, 'w')) { - throw new phpmailerException(t('Could not execute: !smail', array('!smail' => $this->Sendmail)), self::STOP_CRITICAL); + throw new PHPMailerException(t('Could not execute: @smail', array('@smail' => $this->Sendmail)), self::STOP_CRITICAL); } fputs($mail, "To: " . $val . "\n"); fputs($mail, $header); @@ -621,13 +625,13 @@ protected function SendmailSend($header, $body) { $isSent = ($result == 0) ? 1 : 0; $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body); if ($result != 0) { - throw new phpmailerException(t('Could not execute: !smail', array('!smail' => $this->Sendmail)), self::STOP_CRITICAL); + throw new PHPMailerException(t('Could not execute: @smail', array('@smail' => $this->Sendmail)), self::STOP_CRITICAL); } } } else { if (!@$mail = popen($sendmail, 'w')) { - throw new phpmailerException(t('Could not execute: !smail', array('!smail' => $this->Sendmail)), self::STOP_CRITICAL); + throw new PHPMailerException(t('Could not execute: @smail', array('@smail' => $this->Sendmail)), self::STOP_CRITICAL); } fputs($mail, $header); fputs($mail, $body); @@ -636,7 +640,7 @@ protected function SendmailSend($header, $body) { $isSent = ($result == 0) ? 1 : 0; $this->doCallback($isSent, $this->to, $this->cc, $this->bcc, $this->Subject, $body); if ($result != 0) { - throw new phpmailerException(t('Could not execute: !smail', array('!smail' => $this->Sendmail)), self::STOP_CRITICAL); + throw new PHPMailerException(t('Could not execute: @smail', array('@smail' => $this->Sendmail)), self::STOP_CRITICAL); } } return TRUE; @@ -695,7 +699,7 @@ protected function MailSend($header, $body) { ini_set('sendmail_from', $old_from); } if (!$rt) { - throw new phpmailerException(t('Could not instantiate mail function.'), self::STOP_CRITICAL); + throw new PHPMailerException(t('Could not instantiate mail function.'), self::STOP_CRITICAL); } return TRUE; } @@ -713,11 +717,11 @@ protected function SmtpSend($header, $body) { $bad_rcpt = array(); if (!$this->SmtpConnect()) { - throw new phpmailerException(t('SMTP Error: Could not connect to SMTP host.'), self::STOP_CRITICAL); + throw new PHPMailerException(t('SMTP Error: Could not connect to SMTP host.'), self::STOP_CRITICAL); } $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender; if (!$this->smtp->Mail($smtp_from)) { - throw new phpmailerException(t('The following From address failed: !from', array('!from' => $smtp_from)), self::STOP_CRITICAL); + throw new PHPMailerException(t('The following From address failed: @from', array('@from' => $smtp_from)), self::STOP_CRITICAL); } // Attempt to send attach all recipients @@ -764,10 +768,10 @@ protected function SmtpSend($header, $body) { if (count($bad_rcpt) > 0 ) { //Create error message for any bad addresses $badaddresses = implode(', ', $bad_rcpt); - throw new phpmailerException(t('SMTP Error: The following recipients failed: @bad', array('@bad' => $badaddresses))); + throw new PHPMailerException(t('SMTP Error: The following recipients failed: @bad', array('@bad' => $badaddresses))); } if (!$this->smtp->Data($header . $body)) { - throw new phpmailerException(t('SMTP Error: Data not accepted.'), self::STOP_CRITICAL); + throw new PHPMailerException(t('SMTP Error: Data not accepted.'), self::STOP_CRITICAL); } if ($this->SMTPKeepAlive == TRUE) { $this->smtp->Reset(); @@ -815,7 +819,7 @@ public function SmtpConnect() { if ($tls) { if (!$this->smtp->StartTLS()) { - throw new phpmailerException(t('StartTLS not supported by server or could not initiate session.')); + throw new PHPMailerException(t('StartTLS not supported by server or could not initiate session.')); } //We must resend HELO after tls negotiation @@ -825,16 +829,16 @@ public function SmtpConnect() { $connection = TRUE; if ($this->SMTPAuth) { if (!$this->smtp->Authenticate($this->Username, $this->Password)) { - throw new phpmailerException(t('SMTP Error: Could not authenticate.')); + throw new PHPMailerException(t('SMTP Error: Could not authenticate.')); } } } $index++; if (!$connection) { - throw new phpmailerException(t('SMTP Error: Could not connect to SMTP host.')); + throw new PHPMailerException(t('SMTP Error: Could not connect to SMTP host.')); } } - } catch (phpmailerException $e) { + } catch (PHPMailerException $e) { $this->smtp->Reset(); throw $e; } @@ -1236,9 +1240,9 @@ public function CreateBody() { else { @unlink($file); @unlink($signed); - throw new phpmailerException(t('Signing Error: !err', array('!err' => openssl_error_string()))); + throw new PHPMailerException(t('Signing Error: @err', array('@err' => openssl_error_string()))); } - } catch (phpmailerException $e) { + } catch (PHPMailerException $e) { $body = ''; if ($this->exceptions) { throw $e; @@ -1338,7 +1342,7 @@ public function TextLine($value) { public function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') { try { if ( !@is_file($path) ) { - throw new phpmailerException(t('Could not access file: @nofile', array('@nofile' => $path)), self::STOP_CONTINUE); + throw new PHPMailerException(t('Could not access file: @nofile', array('@nofile' => $path)), self::STOP_CONTINUE); } $filename = basename($path); if ( $name == '' ) { @@ -1356,7 +1360,7 @@ public function AddAttachment($path, $name = '', $encoding = 'base64', $type = ' 7 => 0 ); - } catch (phpmailerException $e) { + } catch (PHPMailerException $e) { $this->SetError($e->getMessage()); if ($this->exceptions) { throw $e; @@ -1462,7 +1466,7 @@ private function AttachAll() { private function EncodeFile($path, $encoding = 'base64') { try { if (!is_readable($path)) { - throw new phpmailerException(t('File Error: Could not open file: @nofile', array('@nofile' => $path)), self::STOP_CONTINUE); + throw new PHPMailerException(t('File Error: Could not open file: @nofile', array('@nofile' => $path)), self::STOP_CONTINUE); } if (function_exists('get_magic_quotes')) { function get_magic_quotes() { @@ -2163,7 +2167,7 @@ public function set($name, $value = '') { $this->$name = $value; } else { - throw new phpmailerException(t('Cannot set or reset variable: @name', array('@name' => $name)) , self::STOP_CRITICAL); + throw new PHPMailerException(t('Cannot set or reset variable: @name', array('@name' => $name)) , self::STOP_CRITICAL); } } catch (Exception $e) { $this->SetError($e->getMessage()); diff --git a/web/modules/smtp/src/PHPMailer/SMTP.php b/web/modules/smtp/src/PHPMailer/SMTP.php index 00e548d2e63ea60d571c71b2d89d1d441fac8c89..408900229e062c7d29049d3675dd8f4b83c3395a 100644 --- a/web/modules/smtp/src/PHPMailer/SMTP.php +++ b/web/modules/smtp/src/PHPMailer/SMTP.php @@ -1,5 +1,7 @@ <?php +// @codingStandardsIgnoreFile + /*~ class.smtp.php Orginal release information: .---------------------------------------------------------------------------. diff --git a/web/modules/smtp/src/Plugin/Exception/PHPMailerException.php b/web/modules/smtp/src/Plugin/Exception/PHPMailerException.php deleted file mode 100644 index 0ba1185fb00e4afb2f473f5b45593a0cb91357dd..0000000000000000000000000000000000000000 --- a/web/modules/smtp/src/Plugin/Exception/PHPMailerException.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php - -namespace Drupal\smtp\Plugin\Exception; - -class phpmailerException extends \Exception { - public function errorMessage() { - $errorMsg = '<strong>' . $this->getMessage() . "</strong><br />\n"; - return $errorMsg; - } -} diff --git a/web/modules/smtp/src/Plugin/Mail/SMTPMailSystem.php b/web/modules/smtp/src/Plugin/Mail/SMTPMailSystem.php index 1eb4462e047464f416db3e6210edd619211bb4da..8967a081c7fc4f2ad86d4f7b3e096a885f22f748 100644 --- a/web/modules/smtp/src/Plugin/Mail/SMTPMailSystem.php +++ b/web/modules/smtp/src/Plugin/Mail/SMTPMailSystem.php @@ -6,14 +6,16 @@ use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\Core\Mail\MailFormatHelper; use Drupal\Core\Mail\MailInterface; +use Drupal\Core\Messenger\Messenger; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; -use Drupal\smtp\PHPMailer\PHPMailer; -use Psr\Log\LoggerInterface; +use Egulias\EmailValidator\EmailValidator; use Symfony\Component\DependencyInjection\ContainerInterface; +use Drupal\smtp\PHPMailer\PHPMailer; /** * Modify the drupal mail system to use smtp when sending emails. - * Include the option to choose between plain text or HTML + * + * Include the option to choose between plain text or HTML. * * @Mail( * id = "SMTPMailSystem", @@ -26,21 +28,47 @@ class SMTPMailSystem implements MailInterface, ContainerFactoryPluginInterface { protected $smtpConfig; /** - * Logger - * @var LoggerInterface + * Logger. + * + * @var \Drupal\Core\Logger\LoggerChannelFactoryInterface */ protected $logger; + /** + * Messenger. + * + * @var \Drupal\Core\Messenger\Messenger + */ + protected $messenger; + + /** + * Email validator. + * + * @var Egulias\EmailValidator\EmailValidator + */ + protected $emailValidator; + /** * Constructs a SMPTMailSystem object. + * * @param array $configuration - * @param $plugin_id - * @param $plugin_definition - * @param \Psr\Log\LoggerInterface $logger + * The configuration array. + * @param string $plugin_id + * The plug-in ID. + * @param mixed $plugin_definition + * The plug-in definition. + * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $logger + * The logger object. + * @param \Drupal\Core\Messenger\Messenger $messenger + * The messenger object. + * @param \Egulias\EmailValidator\EmailValidator $emailValidator + * The messenger object. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, LoggerChannelFactoryInterface $logger) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, LoggerChannelFactoryInterface $logger, Messenger $messenger, EmailValidator $emailValidator) { $this->smtpConfig = \Drupal::config('smtp.settings'); $this->logger = $logger; + $this->messenger = $messenger; + $this->emailValidator = $emailValidator; } /** @@ -59,21 +87,28 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition * Returns an instance of this plugin. */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static($configuration, $plugin_id, $plugin_definition, $container->get('logger.factory')); + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('logger.factory'), + $container->get('messenger'), + $container->get('email.validator') + ); } /** - * Concatenate and wrap the e-mail body for either - * plain-text or HTML emails. + * Concatenate and wrap the e-mail body for either plain-text or HTML emails. * - * @param $message + * @param array $message * A message array, as described in hook_mail_alter(). * - * @return + * @return array * The formatted $message. */ public function format(array $message) { $this->AllowHtml = $this->smtpConfig->get('smtp_allowhtml'); + // Join the body array into one string. $message['body'] = implode("\n\n", $message['body']); if ($this->AllowHtml == 0) { @@ -82,18 +117,20 @@ public function format(array $message) { // Wrap the mail body for sending. $message['body'] = MailFormatHelper::wrapMail($message['body']); } + return $message; } /** * Send the e-mail message. * - * @see drupal_mail() - * - * @param $message + * @param array $message * A message array, as described in hook_mail_alter(). - * @return + * + * @return mixed * TRUE if the mail was successfully accepted, otherwise FALSE. + * + * @see drupal_mail() */ public function mail(array $message) { $to = $message['to']; @@ -104,6 +141,7 @@ public function mail(array $message) { // Create a new PHPMailer object - autoloaded from registry. $mailer = new PHPMailer(); + $mailer->Timeout = $this->smtpConfig->get('smtp_timeout'); // Turn on debugging, if requested. if ($this->smtpConfig->get('smtp_debugging') && \Drupal::currentUser()->hasPermission('administer smtp module')) { @@ -118,11 +156,11 @@ public function mail(array $message) { } // Set SMTP module email from. - if (\Drupal::service('email.validator')->isValid($this->smtpConfig->get('smtp_from'))) { - $from = $this->smtpConfig->get('smtp_from'); - $headers['Sender'] = $from; - $headers['Return-Path'] = $from; - $headers['Reply-To'] = $from; + if ($this->emailValidator->isValid($this->smtpConfig->get('smtp_from'))) { + $from = $this->smtpConfig->get('smtp_from'); + $headers['Sender'] = $from; + $headers['Return-Path'] = $from; + $headers['Reply-To'] = $from; } // Defines the From value to what we expect. @@ -143,31 +181,33 @@ public function mail(array $message) { // Create the list of 'To:' recipients. $torecipients = explode(',', $to); foreach ($torecipients as $torecipient) { - $to_comp = $this->_get_components($torecipient); + $to_comp = $this->getComponents($torecipient); $mailer->AddAddress($to_comp['email'], $to_comp['name']); } // Parse the headers of the message and set the PHPMailer object's settings // accordingly. foreach ($headers as $key => $value) { - //watchdog('error', 'Key: ' . $key . ' Value: ' . $value); switch (strtolower($key)) { case 'from': if ($from == NULL or $from == '') { // If a from value was already given, then set based on header. - // Should be the most common situation since drupal_mail moves the + // Should be the most common situation since drupal_mail moves the. // from to headers. - $from = $value; - $mailer->From = $value; - // then from can be out of sync with from_name ! + $from = $value; + $mailer->From = $value; + $mailer->FromName = ''; - $mailer->Sender = $value; + $mailer->Sender = $value; } break; + case 'content-type': - // Parse several values on the Content-type header, storing them in an array like - // key=value -> $vars['key']='value' + // Parse several values on the Content-type header, + // storing them in an array like. + // key=value -> $vars['key']='value'. $vars = explode(';', $value); + foreach ($vars as $i => $var) { if ($cut = strpos($var, '=')) { $new_var = trim(strtolower(substr($var, $cut + 1))); @@ -176,10 +216,14 @@ public function mail(array $message) { $vars[$new_key] = $new_var; } } - // Set the charset based on the provided value, otherwise set it to UTF-8 (which is Drupals internal default). + + // Set the charset based on the provided value, + // otherwise set it to UTF-8 (which is Drupal's internal default). $mailer->CharSet = isset($vars['charset']) ? $vars['charset'] : 'UTF-8'; - // If $vars is empty then set an empty value at index 0 to avoid a PHP warning in the next statement - $vars[0] = isset($vars[0])?$vars[0]:''; + + // If $vars is empty then set an empty value at index 0, + // to avoid a PHP warning in the next statement. + $vars[0] = isset($vars[0]) ? $vars[0] : ''; switch ($vars[0]) { case 'text/plain': @@ -187,35 +231,40 @@ public function mail(array $message) { $mailer->IsHTML(FALSE); $content_type = 'text/plain'; break; + case 'text/html': // The message includes only an HTML part. $mailer->IsHTML(TRUE); $content_type = 'text/html'; break; + case 'multipart/related': // Get the boundary ID from the Content-Type header. - $boundary = $this->_get_substring($value, 'boundary', '"', '"'); + $boundary = $this->getSubstring($value, 'boundary', '"', '"'); // The message includes an HTML part w/inline attachments. $mailer->ContentType = $content_type = 'multipart/related; boundary="' . $boundary . '"'; - break; + break; + case 'multipart/alternative': // The message includes both a plain text and an HTML part. $mailer->ContentType = $content_type = 'multipart/alternative'; // Get the boundary ID from the Content-Type header. - $boundary = $this->_get_substring($value, 'boundary', '"', '"'); - break; + $boundary = $this->getSubstring($value, 'boundary', '"', '"'); + break; + case 'multipart/mixed': // The message includes one or more attachments. $mailer->ContentType = $content_type = 'multipart/mixed'; // Get the boundary ID from the Content-Type header. - $boundary = $this->_get_substring($value, 'boundary', '"', '"'); - break; + $boundary = $this->getSubstring($value, 'boundary', '"', '"'); + break; + default: - // Everything else is unsuppored by PHPMailer. - drupal_set_message(t('The %header of your message is not supported by PHPMailer and will be sent as text/plain instead.', ['%header' => "Content-Type: $value"]), 'error'); + // Everything else is unsupported by PHPMailer. + $this->messenger->addMessage($this->t('The %header of your message is not supported by PHPMailer and will be sent as text/plain instead.', ['%header' => "Content-Type: $value"]), 'error'); $this->logger->error(t('The %header of your message is not supported by PHPMailer and will be sent as text/plain instead.', ['%header' => "Content-Type: $value"])); // Force the Content-Type to be text/plain. @@ -227,8 +276,8 @@ public function mail(array $message) { case 'reply-to': // Only add a "reply-to" if it's not the same as "return-path". if ($value != $headers['Return-Path']) { - $reply_to_comp = $this->_get_components($value); - $mailer->AddReplyTo($reply_to_comp['email'], Unicode::mimeHeaderEncode($reply_to_comp['name'])); + $reply_to_comp = $this->getComponents($value); + $mailer->AddReplyTo($reply_to_comp['email'], $reply_to_comp['name']); } break; @@ -252,8 +301,8 @@ public function mail(array $message) { case 'cc': $ccrecipients = explode(',', $value); foreach ($ccrecipients as $ccrecipient) { - $cc_comp = $this->_get_components($ccrecipient); - $mailer->AddCC($cc_comp['email'], Unicode::mimeHeaderEncode($cc_comp['name'])); + $cc_comp = $this->getComponents($ccrecipient); + $mailer->AddCC($cc_comp['email'], $cc_comp['name']); } break; @@ -271,21 +320,20 @@ public function mail(array $message) { } } - /** - * TODO - * Need to figure out the following. - * - * Add one last header item, but not if it has already been added. - * $errors_to = FALSE; - * foreach ($mailer->CustomHeader as $custom_header) { - * if ($custom_header[0] = '') { - * $errors_to = TRUE; - * } - * } - * if ($errors_to) { - * $mailer->AddCustomHeader('Errors-To: '. $from); - * } - */ + // TODO + // Need to figure out the following. + // + // Add one last header item, but not if it has already been added. + // $errors_to = FALSE; + // foreach ($mailer->CustomHeader as $custom_header) { + // if ($custom_header[0] = '') { + // $errors_to = TRUE; + // } + // } + // if ($errors_to) { + // $mailer->AddCustomHeader('Errors-To: '. $from); + // } + // // Add the message's subject. $mailer->Subject = Unicode::mimeHeaderEncode($subject); @@ -298,19 +346,19 @@ public function mail(array $message) { case 'multipart/alternative': // Split the body based on the boundary ID. - $body_parts = $this->_boundary_split($body, $boundary); + $body_parts = $this->boundarySplit($body, $boundary); foreach ($body_parts as $body_part) { // If plain/text within the body part, add it to $mailer->AltBody. if (strpos($body_part, 'text/plain')) { // Clean up the text. - $body_part = trim($this->_remove_headers(trim($body_part))); + $body_part = trim($this->removeHeaders(trim($body_part))); // Include it as part of the mail object. $mailer->AltBody = $body_part; } // If plain/html within the body part, add it to $mailer->Body. elseif (strpos($body_part, 'text/html')) { // Clean up the text. - $body_part = trim($this->_remove_headers(trim($body_part))); + $body_part = trim($this->removeHeaders(trim($body_part))); // Include it as part of the mail object. $mailer->Body = $body_part; } @@ -319,15 +367,11 @@ public function mail(array $message) { case 'multipart/mixed': // Split the body based on the boundary ID. - $body_parts = $this->_boundary_split($body, $boundary); + $body_parts = $this->boundarySplit($body, $boundary); - // Determine if there is an HTML part for when adding the plain text part. - $text_plain = FALSE; - $text_html = FALSE; + // Determine if there is an HTML part. + $text_html = FALSE; foreach ($body_parts as $body_part) { - if (strpos($body_part, 'text/plain')) { - $text_plain = TRUE; - } if (strpos($body_part, 'text/html')) { $text_html = TRUE; } @@ -338,18 +382,20 @@ public function mail(array $message) { // $mailer->AltBody or $mailer->Body, depending on whether there is // also a text/html part ot not. if (strpos($body_part, 'multipart/alternative')) { + // Get boundary ID from the Content-Type header. - $boundary2 = $this->_get_substring($body_part, 'boundary', '"', '"'); + $boundary2 = $this->getSubstring($body_part, 'boundary', '"', '"'); // Clean up the text. - $body_part = trim($this->_remove_headers(trim($body_part))); + $body_part = trim($this->removeHeaders(trim($body_part))); // Split the body based on the boundary ID. - $body_parts2 = $this->_boundary_split($body_part, $boundary2); + $body_parts2 = $this->boundarySplit($body_part, $boundary2); foreach ($body_parts2 as $body_part2) { + // If plain/text within the body part, add it to $mailer->AltBody. if (strpos($body_part2, 'text/plain')) { // Clean up the text. - $body_part2 = trim($this->_remove_headers(trim($body_part2))); + $body_part2 = trim($this->removeHeaders(trim($body_part2))); // Include it as part of the mail object. $mailer->AltBody = $body_part2; $mailer->ContentType = 'multipart/mixed'; @@ -357,9 +403,9 @@ public function mail(array $message) { // If plain/html within the body part, add it to $mailer->Body. elseif (strpos($body_part2, 'text/html')) { // Get the encoding. - $body_part2_encoding = $this->_get_substring($body_part2, 'Content-Transfer-Encoding', ' ', "\n"); + $body_part2_encoding = $this->getSubstring($body_part2, 'Content-Transfer-Encoding', ' ', "\n"); // Clean up the text. - $body_part2 = trim($this->_remove_headers(trim($body_part2))); + $body_part2 = trim($this->removeHeaders(trim($body_part2))); // Check whether the encoding is base64, and if so, decode it. if (Unicode::strtolower($body_part2_encoding) == 'base64') { // Include it as part of the mail object. @@ -375,10 +421,11 @@ public function mail(array $message) { } } } + // If text/plain within the body part, add it to $mailer->Body. elseif (strpos($body_part, 'text/plain')) { // Clean up the text. - $body_part = trim($this->_remove_headers(trim($body_part))); + $body_part = trim($this->removeHeaders(trim($body_part))); if ($text_html) { $mailer->AltBody = $body_part; @@ -394,7 +441,7 @@ public function mail(array $message) { // If text/html within the body part, add it to $mailer->Body. elseif (strpos($body_part, 'text/html')) { // Clean up the text. - $body_part = trim($this->_remove_headers(trim($body_part))); + $body_part = trim($this->removeHeaders(trim($body_part))); // Include it as part of the mail object. $mailer->Body = $body_part; $mailer->IsHTML(TRUE); @@ -402,19 +449,19 @@ public function mail(array $message) { } // Add the attachment. elseif (strpos($body_part, 'Content-Disposition: attachment;') && !isset($message['params']['attachments'])) { - $file_path = $this->_get_substring($body_part, 'filename=', '"', '"'); - $file_name = $this->_get_substring($body_part, ' name=', '"', '"'); - $file_encoding = $this->_get_substring($body_part, 'Content-Transfer-Encoding', ' ', "\n"); - $file_type = $this->_get_substring($body_part, 'Content-Type', ' ', ';'); + $file_path = $this->getSubstring($body_part, 'filename=', '"', '"'); + $file_name = $this->getSubstring($body_part, ' name=', '"', '"'); + $file_encoding = $this->getSubstring($body_part, 'Content-Transfer-Encoding', ' ', "\n"); + $file_type = $this->getSubstring($body_part, 'Content-Type', ' ', ';'); if (file_exists($file_path)) { if (!$mailer->AddAttachment($file_path, $file_name, $file_encoding, $file_type)) { - drupal_set_message(t('Attahment could not be found or accessed.')); + $this->messenger->addMessage($this->t('Attachment could not be found or accessed.')); } } else { // Clean up the text. - $body_part = trim($this->_remove_headers(trim($body_part))); + $body_part = trim($this->removeHeaders(trim($body_part))); if (Unicode::strtolower($file_encoding) == 'base64') { $attachment = base64_decode($body_part); @@ -431,7 +478,7 @@ public function mail(array $message) { $real_path = \Drupal::service('file_system')->realpath($file_path->uri); if (!$mailer->AddAttachment($real_path, $file_name)) { - drupal_set_message(t('Attachment could not be found or accessed.')); + $this->messenger->addMessage($this->t('Attachment could not be found or accessed.')); } } } @@ -468,7 +515,6 @@ public function mail(array $message) { $mailer->Password = $password; } - // Set the protocol prefix for the smtp host. switch ($this->smtpConfig->get('smtp_protocol')) { case 'ssl': @@ -483,7 +529,6 @@ public function mail(array $message) { $mailer->SMTPSecure = ''; } - // Set other connection settings. $mailer->Host = $this->smtpConfig->get('smtp_host') . ';' . $this->smtpConfig->get('smtp_hostbackup'); $mailer->Port = $this->smtpConfig->get('smtp_port'); @@ -511,14 +556,15 @@ public function mail(array $message) { * Swiped from Mail::MimeDecode, with modifications based on Drupal's coding * standards and this bug report: http://pear.php.net/bugs/bug.php?id=6495 * - * @param input + * @param string $input * A string containing the body text to parse. - * @param boundary + * @param string $boundary * A string with the boundary string to parse on. - * @return + * + * @return array * An array containing the resulting mime parts */ - protected function _boundary_split($input, $boundary) { + protected function boundarySplit($input, $boundary) { $parts = []; $bs_possible = substr($boundary, 2, -2); $bs_check = '\"' . $bs_possible . '\"'; @@ -536,21 +582,27 @@ protected function _boundary_split($input, $boundary) { } return $parts; - } // End of _smtp_boundary_split(). + } /** * Strips the headers from the body part. * - * @param input + * @param string $input * A string containing the body part to strip. - * @return + * + * @return string * A string with the stripped body part. */ - protected function _remove_headers($input) { + protected function removeHeaders($input) { $part_array = explode("\n", $input); // Will strip these headers according to RFC2045. - $headers_to_strip = ['Content-Type', 'Content-Transfer-Encoding', 'Content-ID', 'Content-Disposition']; + $headers_to_strip = [ + 'Content-Type', + 'Content-Transfer-Encoding', + 'Content-ID', + 'Content-Disposition', + ]; $pattern = '/^(' . implode('|', $headers_to_strip) . '):/'; while (count($part_array) > 0) { @@ -561,10 +613,11 @@ protected function _remove_headers($input) { // If the line starts with a known header string. if (preg_match($pattern, $line)) { $line = rtrim(array_shift($part_array)); - // Remove line containing matched header. - // If line ends in a ';' and the next line starts with four spaces, it's a continuation - // of the header split onto the next line. Continue removing lines while we have this condition. + // Remove line containing matched header. + // If line ends in a ';' and the next line starts with four spaces, + // it's a continuation of the header split onto the next line. + // Continue removing lines while we have this condition. while (substr($line, -1) == ';' && count($part_array) > 0 && substr($part_array[0], 0, 4) == ' ') { $line = rtrim(array_shift($part_array)); } @@ -585,19 +638,20 @@ protected function _remove_headers($input) { * Returns the string from within $source that is some where after $target * and is between $beginning_character and $ending_character. * - * @param $source + * @param string $source * A string containing the text to look through. - * @param $target + * @param string $target * A string containing the text in $source to start looking from. - * @param $beginning_character + * @param string $beginning_character * A string containing the character just before the sought after text. - * @param $ending_character + * @param string $ending_character * A string containing the character just after the sought after text. - * @return + * + * @return string * A string with the text found between the $beginning_character and the * $ending_character. */ - protected function _get_substring($source, $target, $beginning_character, $ending_character) { + protected function getSubstring($source, $target, $beginning_character, $ending_character) { $search_start = strpos($source, $target) + 1; $first_character = strpos($source, $beginning_character, $search_start) + 1; $second_character = strpos($source, $ending_character, $first_character) + 1; @@ -614,35 +668,38 @@ protected function _get_substring($source, $target, $beginning_character, $endin /** * Returns an array of name and email address from a string. * - * @param $input - * A string that contains different possible combinations of names and - * email address. - * @return - * An array containing a name and an email address. + * @param string $input + * A string that contains different possible combinations of names and + * email address. + * + * @return array + * An array containing a name and an email address. */ - protected function _get_components($input) { + protected function getComponents($input) { + $input = trim($input); $components = [ 'input' => $input, 'name' => '', 'email' => '', ]; - // If the input is a valid email address in its entirety, then there is - // nothing to do, just return that. - if (\Drupal::service('email.validator')->isValid(trim($input))) { - $components['email'] = trim($input); + // If the input is a valid email address in its entirety, + // then there is nothing to do, just return that. + if ($this->emailValidator->isValid($input)) { + $components['email'] = $input; return $components; } // Check if $input has one of the following formats, extract what we can: - // some name <address@example.com> - // "another name" <address@example.com> - // <address@example.com> - if (preg_match('/^"?([^"\t\n]*)"?\s*<([^>\t\n]*)>$/', trim($input), $matches)) { + // some name <address@example.com>. + // "another name" <address@example.com>. + // <address@example.com>. + if (preg_match('/^"?([^"\t\n]*)"?\s*<([^>\t\n]*)>$/', $input, $matches)) { $components['name'] = trim($matches[1]); $components['email'] = trim($matches[2]); } return $components; } + } diff --git a/web/modules/smtp/tests/src/Unit/Plugin/Mail/SMTPMailSystemTest.php b/web/modules/smtp/tests/src/Unit/Plugin/Mail/SMTPMailSystemTest.php new file mode 100644 index 0000000000000000000000000000000000000000..0319aad46f6d09e4eb8efe8dbc4de4d4773798f7 --- /dev/null +++ b/web/modules/smtp/tests/src/Unit/Plugin/Mail/SMTPMailSystemTest.php @@ -0,0 +1,145 @@ +<?php + +namespace Drupal\Tests\smtp\Unit\Plugin\Mail; + +use Drupal\Core\Config\Config; +use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Logger\LoggerChannelFactoryInterface; +use Drupal\Core\Messenger\Messenger; +use Drupal\Core\StringTranslation\TranslationInterface; +use Drupal\smtp\Plugin\Mail\SMTPMailSystem; +use Drupal\Tests\UnitTestCase; +use Egulias\EmailValidator\EmailValidator; +use Prophecy\Argument; +use Symfony\Component\DependencyInjection\ContainerInterface; + +/** + * Validate requirements for SMTPMailSystem. + * + * @group SMTP + */ +class SMTPMailSystemTest extends UnitTestCase { + + /** + * Test setup. + */ + public function setup() { + $this->mockConfigFactory = $this->prophesize(ConfigFactoryInterface::class); + $this->mockConfig = $this->prophesize(Config::class); + $this->mockConfigFactory->get('smtp.settings')->willReturn($this->mockConfig->reveal()); + $this->mockConfigFactory->getEditable('smtp.settings')->willReturn($this->mockConfig->reveal()); + + // $this->mockConfigSystemSite = $this->prophesize(Config::class); + // $this->mockConfigSystemSite->get('name')->willReturn('Site name'); + // $this->mockConfigFactory->get('system.site')->willReturn($this->mockConfigSystemSite->reveal()); + + $this->mockLogger = $this->prophesize(LoggerChannelFactoryInterface::class); + $this->mockMessenger = $this->prophesize(Messenger::class); + + $mockContainer = $this->mockContainer = $this->prophesize(ContainerInterface::class); + $mockContainer->get('config.factory')->willReturn($this->mockConfigFactory->reveal()); + $mockContainer->get('logger.factory')->willReturn($this->mockLogger->reveal()); + $mockContainer->get('messenger')->willReturn($this->mockMessenger->reveal()); + + $mockStringTranslation = $this->prophesize(TranslationInterface::class); + $mockStringTranslation->translate(Argument::any())->willReturnArgument(0); + $mockStringTranslation->translate(Argument::any(), Argument::any())->willReturnArgument(0); + $mockStringTranslation->translateString(Argument::any())->willReturn('.'); + $mockContainer->get('string_translation')->willReturn($mockStringTranslation->reveal()); + + // Email validator. + $this->emailValidator = new EmailValidator(); + $mockContainer->get('email.validator')->willReturn($this->emailValidator); + \Drupal::setContainer($this->mockContainer->reveal()); + } + + /** + * Provides scenarios for getComponents(). + */ + public function getComponentsProvider() { + return [ + [ + // Input. + 'name@example.com', + // Expected. + [ + 'name' => '', + 'email' => 'name@example.com', + ], + ], + [ + ' name@example.com', + [ + 'name' => '', + 'input' => 'name@example.com', + 'email' => 'name@example.com', + ], + ], + [ + 'name@example.com ', + [ + 'name' => '', + 'input' => 'name@example.com', + 'email' => 'name@example.com', + ], + ], + [ + 'some name <address@example.com>', + [ + 'name' => 'some name', + 'email' => 'address@example.com', + ], + ], + [ + '"some name" <address@example.com>', + [ + 'name' => 'some name', + 'email' => 'address@example.com', + ], + ], + [ + '<address@example.com>', + [ + 'name' => '', + 'email' => 'address@example.com', + ], + ], + ]; + } + + /** + * Test getComponents(). + * + * @dataProvider getComponentsProvider + */ + public function testGetComponents($input, $expected) { + $mailSystem = new SMTPMailSystemTestHelper([], '', [], $this->mockLogger->reveal(), $this->mockMessenger->reveal(), $this->emailValidator); + + $ret = $mailSystem->publiGetComponents($input); + + if (!empty($expected['input'])) { + $this->assertEquals($expected['input'], $ret['input']); + } + else { + $this->assertEquals($input, $ret['input']); + } + + $this->assertEquals($expected['name'], $ret['name']); + $this->assertEquals($expected['email'], $ret['email']); + } + +} + +/** + * Test helper for SMTPMailSystemTest. + */ +class SMTPMailSystemTestHelper extends SMTPMailSystem { + + /** + * Exposes getComponents for testing. + */ + public function publiGetComponents($input) { + return $this->getComponents($input); + } + +}; diff --git a/web/modules/smtp/tests/src/Unit/SMTPConfigFormTest.php b/web/modules/smtp/tests/src/Unit/SMTPConfigFormTest.php index 4d806131fec77b5a4b34b42b55bbe62ef202835e..93fb785dd3bbe8e7e3106aeee6c89df0c5ec9174 100644 --- a/web/modules/smtp/tests/src/Unit/SMTPConfigFormTest.php +++ b/web/modules/smtp/tests/src/Unit/SMTPConfigFormTest.php @@ -13,7 +13,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; /** - * Validate requirements for ProceedingsRealmNegotiator. + * Validate requirements for SMTPConfigForm. * * @group SMTP */ @@ -94,4 +94,14 @@ public function testBuildFormDisabledMessage() { $this->mockMessenger->addMessage(Argument::which('getUntranslatedString', 'SMTP module is INACTIVE.'))->shouldHaveBeenCalled(); } + /** + * Test form id. + */ + public function testGetFormId() { + $formBuilder = SMTPConfigForm::create($this->mockContainer->reveal()); + + $form_id = $formBuilder->getFormId(); + $this->assertEquals('smtp_admin_settings', $form_id); + } + }