diff --git a/LICENSE.txt b/LICENSE.txt
deleted file mode 100644
index d159169..0000000
--- a/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/README.txt b/README.txt
index 513d1e4..92116d8 100644
--- a/README.txt
+++ b/README.txt
@@ -1,6 +1,3 @@
-
-Copyright 2007 Khalid Baheyeldin and http://2bits.com
-
 Description
 -----------
 This module intercepts all outgoing emails from a Drupal site and
@@ -12,44 +9,36 @@ site for the purpose of development, and you do not want any email sent
 to real users of the original site. Or you want to check the emails sent
 for uniform formatting, footers, ...etc.
 
-This is also a good demonstration of what hook_mail_alter(), available in
-Drupal 5.x and later, can do.
-
 Installation
 ------------
-To install this module, do the following:
-
-1. Extract the tar ball that you downloaded from Drupal.org.
-
-2. Upload the entire directory and all its contents to your
-   modules directory.
+Install and enable as you would install any module.
 
 Configuration
 -------------
-To enable this module do the following:
-
-1. Go to Admin -> Modules, and enable reroute email.
 
-2. Go to Admin -> Configuration -> Development -> Reroute email, and enter an
-   email address to route all email to. If the field is empty and no value is
-   provided for rerouted email addresses, all outgoing emails would be aborted
-   and recorded in the recent log entries, with a full dump of the email
-   variables, which could provide an additional debugging method.
+Go to Admin -> Configuration -> Development -> Reroute email, and enable r
+erouting and enter an email address to route all email to. If the
+"Email Addresses" field is empty, all attempts to send mail will be aborted
+and the failure noted in the log along with a full dump of the email
+variables, which could provide an additional debugging method.
 
 Tips and Tricks
 ---------------
-Reroute Email provides configuration variables that you can directly override
-in the settings.php file of a site. This is useful for moving sites from live
-to test and vice versa.
+This module is *not* intended to be enabled at all on a production site.
 
-To use this variable, you add the following line in the settings.php file
-for the test environment:
+It does provide configuration that you can override in the settings.php or
+settings.local.php file of a site. This is useful for moving sites from live to
+test and vice versa.
 
-  $conf['reroute_email_enable'] = 1;
+To override configuration add these lines to settings.local.php or settings.php
+in the dev/test environment:
 
-And for the live site, you set it as follows:
+$config['reroute_email.settings']['reroute_email_enable'] = TRUE;
+$config['reroute_email.settings']['reroute_email_address'] = 'your.email@example.com';
 
-  $conf['reroute_email_enable'] = 0;
+And for the production or other site, you set it as follows:
+
+$config['reroute_email.settings']['reroute_email_enable'] = FALSE;
 
 Configuration and all the settings variables can be overridden in the
 settings.php file by copying and pasting the code snippet below and changing
@@ -62,19 +51,19 @@ the values:
  * disabled, change the values below accordingly for your site.
  */
 // Enable email rerouting.
-$conf['reroute_email_enable'] = 1;
+$config['reroute_email.settings']['reroute_email_enable'] = TRUE;
 // Space, comma, or semicolon-delimited list of email addresses to pass
 // through. Every destination email address which is not on this list will be
 // rerouted to the first address on the list.
-$conf['reroute_email_address'] = "example@example.com";
+$config['reroute_email.settings']['reroute_email_address'] = 'your.email@example.com';
 // Enable inserting a message into the email body when the mail is being
 // rerouted.
-$conf['reroute_email_enable_message'] = 1;
+$conf['reroute_email.settings']['reroute_email_enable_message'] = 1;
 
 
 Test Email Form
 ---------------
-Reroute Email also provides a convenient form for testing email sending or
+Reroute Email also provides a form for testing email sending or
 rerouting. After enabling the module, a test email form is accessible under:
 Admin -> Configuration -> Development -> Reroute email -> Test email form
 
@@ -88,17 +77,17 @@ If you want to report bugs, feature requests, or submit a patch, please do so
 at the project page on the Drupal web site.
 http://drupal.org/project/reroute_email
 
-Author
-------
+Original Author
+---------------
 Khalid Baheyeldin (http://baheyeldin.com/khalid and http://2bits.com)
 
-Maintainers
------------
-rfay (http://drupal.org/user/30906)
+Current Maintainers
+-------------------
 DYdave (http://drupal.org/user/467284)
+rfay (http://drupal.org/user/30906)
 
 If you use this module, find it useful, and want to send the author a thank you
 note, then use the Feedback/Contact page at the URL above.
 
-The author can also be contacted for paid customizations of this and other
+The maintainers can also be contacted for paid customizations of this and other
 modules.
diff --git a/config/schema/reroute_email.schema.yml b/config/schema/reroute_email.schema.yml
new file mode 100644
index 0000000..ebd3461
--- /dev/null
+++ b/config/schema/reroute_email.schema.yml
@@ -0,0 +1,17 @@
+reroute_email.settings:
+  type: config_object
+  label: 'Reroute Email Settings'
+  mapping:
+    reroute_email_enable:
+      type: boolean
+      label: 'Enable reroute_email'
+    reroute_email_address:
+      type: string
+      label: 'Rerouting email addresses'
+    reroute_email_enable_message:
+      type: boolean
+      label: 'Add message to body of email'
+    reroute_email_enable_dsm:
+      type: boolean
+      label: 'Enable dsm() function for debugging'
+
diff --git a/reroute_email.admin.inc b/reroute_email.admin.inc
deleted file mode 100644
index 2e74f81..0000000
--- a/reroute_email.admin.inc
+++ /dev/null
@@ -1,125 +0,0 @@
-<?php
-
-/**
- * @file
- * Reroute Email admin configuration functions.
- */
-
-/**
- * Settings form.
- */
-function reroute_email_settings() {
-  // @FIXME
-// // @FIXME
-// // The correct configuration object could not be determined. You'll need to
-// // rewrite this call manually.
-$form[REROUTE_EMAIL_ENABLE] = array(
-    '#type'          => 'checkbox',
-    '#title'         => t('Enable rerouting'),
-    '#default_value' => \Drupal::config('reroute_email.settings')->get(REROUTE_EMAIL_ENABLE),
-    '#description'   => t('Check this box if you want to enable email rerouting. Uncheck to disable rerouting.'),
-  );
-
-  // @FIXME
-// // @FIXME
-// // The correct configuration object could not be determined. You'll need to
-// // rewrite this call manually.
-$form[REROUTE_EMAIL_ADDRESS] = array(
-    '#type'          => 'textfield',
-    '#title'         => t('Email addresses'),
-    '#default_value' => \Drupal::config('reroute_email.settings')->get(REROUTE_EMAIL_ADDRESS),
-    '#description'   => 'Provide a space, comma, or semicolon-delimited list of email addresses to pass through. Every destination email address which is not on this list will be rerouted to the first address on the list.<br/> If the field is empty and no value is provided, <strong>all outgoing emails would be aborted</strong> and the email would be recorded in the <a href="@dblog">recent log entries</a>.', array('@dblog' => \Drupal\Core\Url::fromRoute('dblog.overview')),
-    '#states' => array(
-      'visible' => array(':input[name=reroute_email_enable]' => array('checked' => TRUE)),
-    ),
-  );
-
-  // @FIXME
-// // @FIXME
-// // The correct configuration object could not be determined. You'll need to
-// // rewrite this call manually.
-$form[REROUTE_EMAIL_ENABLE_MESSAGE] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Show rerouting description in mail body'),
-    '#default_value' => \Drupal::config('reroute_email.settings')->get(REROUTE_EMAIL_ENABLE_MESSAGE),
-    '#description' => t('Check this box if you want a message to be inserted into the email body when the mail is being rerouted. Otherwise, SMTP headers will be used to describe the rerouting. If sending rich-text email, leave this unchecked so that the body of the email will not be disturbed.'),
-    '#states' => array(
-      'visible' => array(':input[name=reroute_email_enable]' => array('checked' => TRUE)),
-    ),
-  );
-
-
-  return system_settings_form($form);
-}
-
-/**
- * Validation callback for reroute_email_settings() form.
- */
-function reroute_email_settings_validate($form, $form_state) {
-  if ($form_state['values']['reroute_email_enable'] == TRUE) {
-    // Allow splitting emails by space, comma, semicolon.
-    $addresslist = preg_split(REROUTE_EMAIL_EMAIL_SPLIT_RE, $form_state['values']['reroute_email_address'], -1, PREG_SPLIT_NO_EMPTY);
-    foreach ($addresslist as $address) {
-      if (!valid_email_address($address)) {
-        form_set_error('reroute_email_address', t('@address is not a valid email address', array('@address' => $address)));
-      }
-    }
-  }
-}
-
-/**
- * Form for sending test messages.
- */
-function reroute_email_test_email_form() {
-  return array(
-    'addresses' => array(
-      '#type' => 'fieldset',
-      '#description' => t('Email addresses are not validated: any valid or invalid email address format could be submitted.'),
-      'to' => array(
-        '#type' => 'textfield',
-        '#title' => t('To'),
-        '#required' => TRUE,
-      ),
-      'cc' => array(
-        '#type' => 'textfield',
-        '#title' => t('Cc'),
-      ),
-      'bcc' => array(
-        '#type' => 'textfield',
-        '#title' => t('Bcc'),
-      ),
-    ),
-    'subject' => array(
-      '#type' => 'textfield',
-      '#title' => t('Subject'),
-      '#default_value' => t('Reroute Email Test'),
-    ),
-    'body' => array(
-      '#type' => 'textarea',
-      '#title' => t('Body'),
-    ),
-    'submit' => array(
-      '#type' => 'submit',
-      '#value' => t('Send email'),
-    ),
-  );
-}
-
-/**
- * Submit handler for email test.
- */
-function reroute_email_test_email_form_submit(&$form, &$form_state) {
-  $from = "devarajjohnson23@gmail.com";
-  $to = $form_state['values']['to'];
-  $param_keys = array('cc', 'bcc', 'subject', 'body');
-  $params = array_intersect_key($form_state['values'], array_flip($param_keys));
-  $langcode = \Drupal::languageManager()->getDefaultLanguage();
-    
-  // Send email with drupal_mail.
-    $message =  \Drupal::service('plugin.manager.mail')->mail('reroute_email', 'test_email_form', $to, $langcode, $params, $from);
-
-  //$message = drupal_mail('reroute_email', 'test_email_form', $to, language_default(), $params);
-  if (!empty($message['result'])) {
-    drupal_set_message(t("Test email submitted for delivery."));
-  }
-}
diff --git a/reroute_email.install b/reroute_email.install
deleted file mode 100644
index e7a8991..0000000
--- a/reroute_email.install
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-
-/**
- * @file
- * Reroute Email module installation functions.
- */
-
-/**
- * Implements hook_uninstall().
- */
-function reroute_email_uninstall() {
-  \Drupal::config('reroute_email.settings')->clear('reroute_email_address')->save();
-  \Drupal::config('reroute_email.settings')->clear('reroute_email_enable')->save();
-  \Drupal::config('reroute_email.settings')->clear('reroute_email_enable_message')->save();
-}
diff --git a/reroute_email.module b/reroute_email.module
index 4550220..507fab6 100644
--- a/reroute_email.module
+++ b/reroute_email.module
@@ -80,105 +80,112 @@ function reroute_email_menu() {
 /**
  * Implements hook_mail_alter().
  *
- * This hook is required to change the destination of outgoing emails.
+ * Alter destination of outgoing emails if reroute_email is enabled.
  */
 function reroute_email_mail_alter(&$message) {
-  // @FIXME
-// // @FIXME
-// // The correct configuration object could not be determined. You'll need to
-// // rewrite this call manually.
-if (\Drupal::config('reroute_email.settings')->get(REROUTE_EMAIL_ENABLE)) {
-    global $base_url;
-
-    if (empty($message)) {
-      return;
-    }
+  global $base_url;
+  $config = \Drupal::config('reroute_email.settings');
+  $site_mail = \Drupal::config('system.site')->get('mail');
 
-    if (!is_array($message)) {
-      return;
-    }
+  if (empty($config->get(REROUTE_EMAIL_ENABLE))) {
+    return;
+  }
+
+  if (empty($message)) {
+    return;
+  }
+
+  if (!is_array($message)) {
+    return;
+  }
 
-    $mailkey = isset($message['id']) ? $message['id'] : t('[mail id] is missing');
-    $to = isset($message['to']) ? $message['to'] : t('[to] is missing');
+  $mailkey = isset($message['id']) ? $message['id'] : t('[mail id] is missing');
+  $to = isset($message['to']) ? $message['to'] : t('[to] is missing');
 
-    $message['headers']['X-Rerouted-Mail-Key'] = $mailkey;
-    $message['headers']['X-Rerouted-Website'] = $base_url;
+  $message['headers']['X-Rerouted-Mail-Key'] = $mailkey;
+  $message['headers']['X-Rerouted-Website'] = $base_url;
 
-    // Unset Bcc and Cc fields to prevent emails from going to those addresses.
-    if (isset($message['headers']) && is_array($message['headers'])) {
+  // Unset Bcc and Cc fields to prevent emails from going to those addresses.
+  if (isset($message['headers']) && is_array($message['headers'])) {
 
-      // Ensure we catch all Cc and Bcc headers, regardless of case,
-      // and protecting against multiple instances of the "same" header.
-      $header_keys = array();
-      foreach (array_keys($message['headers']) as $key) {
-        $header_keys[strtolower($key)][] = $key;
-      }
+    // Ensure we catch all Cc and Bcc headers, regardless of case,
+    // and protecting against multiple instances of the "same" header.
+    $header_keys = array();
+    foreach (array_keys($message['headers']) as $key) {
+      $header_keys[strtolower($key)][] = $key;
+    }
 
-      if (!empty($header_keys['cc'])) {
-        foreach ($header_keys['cc'] as $header) {
-          $message['headers']['X-Rerouted-Original-Cc'] = $message['headers'][$header];
-          unset($message['headers'][$header]);
-        }
+    if (!empty($header_keys['cc'])) {
+      foreach ($header_keys['cc'] as $header) {
+        $message['headers']['X-Rerouted-Original-Cc'] = $message['headers'][$header];
+        unset($message['headers'][$header]);
       }
-      if (!empty($header_keys['bcc'])) {
-        foreach ($header_keys['bcc'] as $header) {
-          $message['headers']['X-Rerouted-Original-Bcc'] = $message['headers'][$header];
-          unset($message['headers'][$header]);
-        }
+    }
+    if (!empty($header_keys['bcc'])) {
+      foreach ($header_keys['bcc'] as $header) {
+        $message['headers']['X-Rerouted-Original-Bcc'] = $message['headers'][$header];
+        unset($message['headers'][$header]);
       }
     }
-    // Split the address string on whitespace, ignoring any empty results.
-    $addresslist = preg_split(REROUTE_EMAIL_EMAIL_SPLIT_RE, \Drupal::config('reroute_email.settings')->get(REROUTE_EMAIL_ADDRESS), -1, PREG_SPLIT_NO_EMPTY);
-
-    if (!in_array($to, $addresslist)) {
-
-      // Not on the list, so reroute to the first address in the list.
-      $message['headers']['X-Rerouted-Original-To'] = $to;
-      $message['to'] = !empty($addresslist[0]) ? $addresslist[0] : REROUTE_EMAIL_ADDRESS_EMPTY_PLACEHOLDER;
-
-      if (\Drupal::config('reroute_email.settings')->get(REROUTE_EMAIL_ENABLE_MESSAGE)) {
-        // Format a message to show at the top.
-        $msg = t("This email was rerouted.") . "\n";
-        $msg .= t("Web site: @site", array('@site' => $base_url)) . "\n";
-        $msg .= t("Mail key: @key", array('@key' => $mailkey)) . "\n";
-        $msg .= t("Originally to: @to", array('@to' => $to)) . "\n";
-        $msg .= "-----------------------\n";
-
-        // Prepend explanation message to the body of the email. This must be
-        // handled differently depending on whether the body came in as a
-        // string or an array. If it came in as a string (despite the fact it
-        // should be an array) we'll respect that and leave it as a string.
-        if (is_string($message['body'])) {
-          $message['body'] = $msg . $message['body'];
-        }
-        else {
-          array_unshift($message['body'], $msg);
-        }
+  }
+
+  // Get reroute_email_address, or use system.site.mail if reroute_email_address is not set.
+  $reroute_email_address = $config->get(REROUTE_EMAIL_ADDRESS);
+  if (empty($reroute_email_address)) {
+    $reroute_email_address = $site_mail;
+  }
+  // Split the address string on whitespace, ignoring any empty results.
+  $addresslist = preg_split(REROUTE_EMAIL_EMAIL_SPLIT_RE, $reroute_email_address, -1, PREG_SPLIT_NO_EMPTY);
+
+  if (!in_array($to, $addresslist)) {
+
+    // Not on the list, so reroute to the first address in the list.
+    $message['headers']['X-Rerouted-Original-To'] = $to;
+    $message['to'] = !empty($addresslist[0]) ? $addresslist[0] : REROUTE_EMAIL_ADDRESS_EMPTY_PLACEHOLDER;
+
+    if ($config->get(REROUTE_EMAIL_ENABLE_MESSAGE)) {
+      // Format a message to show at the top.
+      $msg = t("This email was rerouted.") . "\n";
+      $msg .= t("Web site: @site", array('@site' => $base_url)) . "\n";
+      $msg .= t("Mail key: @key", array('@key' => $mailkey)) . "\n";
+      $msg .= t("Originally to: @to", array('@to' => $to)) . "\n";
+      $msg .= "-----------------------\n";
+
+      // Prepend explanation message to the body of the email. This must be
+      // handled differently depending on whether the body came in as a
+      // string or an array. If it came in as a string (despite the fact it
+      // should be an array) we'll respect that and leave it as a string.
+      if (is_string($message['body'])) {
+        $message['body'] = $msg . $message['body'];
+      }
+      else {
+        array_unshift($message['body'], $msg);
       }
     }
-  
-    // Abort sending of the email only if the address is an empty string.
-    if (empty(\Drupal::config('reroute_email.settings')->get(REROUTE_EMAIL_ADDRESS))) {
-      $message['send'] = FALSE;
-      // Record a variable dump of the email in the recent log entries.
-    /*  watchdog('reroute_email', 'Aborted email sending for <em>@message_id</em>. <br/>Detailed email data: Array $message <pre>@message</pre>', array(
+  }
+
+  // Abort sending of the email if the reroute_email_address is an empty string.
+  if ($config->get(REROUTE_EMAIL_ADDRESS) === '') {
+    $message['send'] = FALSE;
+    // Record a variable dump of the email in the recent log entries.
+    unset($message['params']);  // Extensive params keys cause OOM error in var_export()
+    $message_string = var_export($message, TRUE);
+    \Drupal::logger('reroute_email')
+      ->notice('Aborted email sending for <em>@message_id</em>. <br/>Detailed email data: Array $message <pre>@message</pre>', array(
         '@message_id' => $message['id'],
-        '@message' => print_r($message, TRUE),
-      ));*/
-// Logs a notice
-/*$message = 'Aborted email sending for <em>@message_id</em>. <br/>Detailed email data: Array $message <pre>@message</pre>', array(
+        '@message' => $message_string,
+      ));
+    // Let users know email has been aborted, but logged.
+    drupal_set_message(t('<em>@message_id</em> was aborted by reroute email; site administrators can check the recent log entries for complete details on the rerouted email.', ['@message_id' => $message['id']]));
+  }
+  else {
+    // Display a message to let users know email was rerouted.
+    drupal_set_message(t('Submitted email, with ID: <em>@message_id</em>, was rerouted to configured address: <em>@reroute_target</em>. For more details please refer to Reroute Email settings.', [
         '@message_id' => $message['id'],
-        '@message' => print_r($message, TRUE),
-      );*/
-\Drupal::logger('reroute_email')->notice('Aborted email sending');
-// Logs an error
-      // Let users know email has been aborted, but logged.
-      /*drupal_set_message("<em>@message_id</em> was aborted by reroute email, please check the <a href='@dblog'>recent log entries</a> for complete details on the rerouted email.", array("@message_id" => $message['id'], "@dblog" => \Drupal\Core\Url::fromRoute('dblog.overview')));*/
-     drupal_set_message('Email failed');
-    }
-
+        '@reroute_target' => $message['to'],
+      ]
+    ));
   }
-
 }
 
 /**
diff --git a/reroute_email.test b/reroute_email.test
deleted file mode 100644
index e0d5605..0000000
--- a/reroute_email.test
+++ /dev/null
@@ -1,541 +0,0 @@
-<?php
-
-/**
- * @file
- * Test the Reroute Email module.
- */
-
-/**
- * Provides common functionality for the Reroute Email test classes.
- */
-class RerouteEmailTestCase extends DrupalWebTestCase {
-
-  /**
-   * User object to perform site browsing.
-   *
-   * @var object
-   */
-  protected $adminUser;
-
-  /**
-   * Reroute email destination address used for the tests.
-   *
-   * @var string
-   */
-  protected $rerouteDestination = "rerouted@example.com";
-
-  /**
-   * Original email address used for the tests.
-   *
-   * @var string
-   */
-  protected $originalDestination = "original@example.com";
-
-  /**
-   * Permissions required by the user to perform the tests.
-   *
-   * @var array
-   */
-  protected $permissions = array(
-    'administer reroute email',
-  );
-
-  /**
-   * Enable modules and create user with specific permissions.
-   */
-  public function setUp() {
-    // Merge inherited classes modules, see FieldUITestCase for an example.
-    $modules = func_get_args();
-    if (isset($modules[0]) && is_array($modules[0])) {
-      $modules = $modules[0];
-    }
-    $modules[] = 'reroute_email';
-    parent::setUp($modules);
-
-    // Authenticate test user.
-    $this->adminUser = $this->drupalCreateUser($this->permissions);
-    $this->drupalLogin($this->adminUser);
-  }
-
-  /**
-   * Helper function to configure Reroute Email Settings.
-   *
-   * @param string $reroute_destination
-   *   (optional) The email address to which emails should be rerouted.
-   *   Defaults to $this->rerouteDestination if set to NULL.
-   * @param bool $reroute_email_enable
-   *   (optional) Set to TRUE to enable email Rerouting, defaults to TRUE.
-   * @param bool $reroute_email_enable_message
-   *   (optional) Set to TRUE to show rerouting description, defaults to TRUE.
-   */
-  public function configureRerouteEmail($reroute_destination = NULL, $reroute_email_enable = TRUE, $reroute_email_enable_message = TRUE) {
-    // Initialize $reroute_destination by default if no value is provided.
-    if (!isset($reroute_destination)) {
-      $reroute_destination = $this->rerouteDestination;
-    }
-    // Configure to Reroute Email settings form.
-    $post = array(
-      'reroute_email_address' => $reroute_destination,
-      'reroute_email_enable' => $reroute_email_enable,
-      'reroute_email_enable_message' => $reroute_email_enable_message,
-    );
-    // Submit Reroute Email Settings form and check if it was successful.
-    $this->drupalPost("admin/config/development/reroute_email", $post, t('Save configuration'));
-    $this->assertText(t("The configuration options have been saved."));
-  }
-
-  /**
-   * Assert whether the text "Originally to: @to_email" is found in email body.
-   *
-   * @param string $mail_body
-   *   The email body in which the line of text should be searched for.
-   * @param bool $message
-   *   Message to display in test case results.
-   * @param bool $original_destination
-   *   (optional) The original email address to be found in rerouted email
-   *   body. Defaults to $this->originalDestination if set to NULL.
-   */
-  public function assertOriginallyTo($mail_body, $message, $original_destination = NULL) {
-    // Initialize $original_destination by default if no value is provided.
-    if (!isset($original_destination)) {
-      $original_destination = $this->originalDestination;
-    }
-    // Search in $mailbody for "Originally to: $original_destination".
-    $search_for = t("Originally to: @to", array('@to' => $original_destination));
-    $has_info = preg_match("/$search_for/", $mail_body);
-    // Asserts whether searched text was found.
-    $this->assertTrue($has_info, $message);
-    $this->verbose(t('Email body was: <pre>@mail_body</pre>', array('@mail_body' => $mail_body)));
-  }
-}
-
-/**
- * Tests email rerouting for the site-wide Core Contact form.
- */
-class RerouteEmailContactTestCase extends RerouteEmailTestCase {
-
-  /**
-   * Implements DrupalWebTestCase::getInfo().
-   */
-  public static function getInfo() {
-    return array(
-      'name' => 'Site-wide Core Contact form email rerouting',
-      'description' => "Test Reroute Email module's ability to reroute mail sent from the Core Contact module forms.",
-      'group' => 'Reroute Email',
-    );
-  }
-
-  /**
-   * Enable modules and create user with specific permissions.
-   */
-  public function setUp() {
-    // Add more permissions to be able to manipulate the contact forms.
-    $this->permissions[] = 'administer contact forms';
-    $this->permissions[] = 'access site-wide contact form';
-    // Include Core Contact module.
-    parent::setUp('contact');
-  }
-
-  /**
-   * Basic tests of email rerouting for emails sent through the Contact forms.
-   *
-   * The Core Contact email form is submitted several times with different
-   * Email Rerouting settings: Rerouting enabled or disabled, Body injection
-   * enabled or disabled, several recipients with or without whitelist.
-   */
-  public function testBasicNotification() {
-    // Additional destination email address used for testing the whitelist.
-    $additional_destination = "additional@example.com";
-
-    // Configure to reroute normally to rerouted@example.com.
-    $this->configureRerouteEmail();
-
-    // Configure the contact settings to send to $original_destination.
-    $this->drupalPost('admin/structure/contact/edit/1', array('recipients' => $this->originalDestination), t('Save'));
-
-    // Go to the contact page and send an email.
-    $post = array('subject' => "Test test test", 'message' => 'This is a test');
-    $this->drupalPost("contact", $post, t("Send message"));
-    $this->assertText(t("Your message has been sent"));
-    $mails = $this->drupalGetMails();
-    $mail = end($mails);
-    $this->assertMail('to', $this->rerouteDestination, format_string("Email was rerouted to @address", array('@address' => $this->rerouteDestination)));
-    // Check if original destination email address is in rerouted email body.
-    $this->assertOriginallyTo($mail['body'], 'Found the correct "Originally to" line in the body');
-    $this->assertTrue(strpos($mail['body'], 'Originally to') !== FALSE, 'Body does contain "Originally to"');
-
-    // Now try sending to one of the additional email addresses that should
-    // not be rerouted. Configure two email addresses in reroute form.
-    // Body injection is still turned on.
-    $this->configureRerouteEmail("{$this->rerouteDestination}, $additional_destination");
-
-    // Configure the contact settings to point to the additional recipient.
-    $this->drupalPost('admin/structure/contact/edit/1', array('recipients' => $additional_destination), t('Save'));
-
-    // Go to the contact page and send an email.
-    $post = array('subject' => "Test test test", 'message' => 'This is a test');
-    $this->drupalPost("contact", $post, t("Send message"));
-    $this->assertText(t("Your message has been sent"));
-    $mails = $this->drupalGetMails();
-    $mail = end($mails);;
-    $this->assertMail('to', $additional_destination, 'Email was not rerouted because destination was in whitelist');
-
-    // Now change the configuration to disable reroute and set the original
-    // email recipients.
-    $this->configureRerouteEmail(NULL, FALSE);
-
-    // Set the contact form to send to original_destination.
-    $this->drupalPost('admin/structure/contact/edit/1', array('recipients' => $this->originalDestination), t('Save'));
-    // Go to the contact page and send an email.
-    $post = array('subject' => "Test test test", 'message' => 'This is a test');
-    $this->drupalPost("contact", $post, t("Send message"));
-    $this->assertText(t("Your message has been sent"));
-    $mails = $this->drupalGetMails();
-    $mail = end($mails);
-    // Mail should not be rerouted - should go to $original_destination.
-    $this->assertMail('to', $this->originalDestination, 'Mail not rerouted - sent to original destination.');
-    $this->verbose(t("Email 'to' was: <pre>@mail_to</pre>", array('@mail_to' => $mail['to'])));
-
-    // Configure to reroute without body injection.
-    $this->configureRerouteEmail(NULL, TRUE, FALSE);
-
-    // Go to the contact page and send an email.
-    $post = array('subject' => "Test test test", 'message' => 'This is a test');
-    $this->drupalPost("contact", $post, t("Send message"));
-    $this->assertText(t("Your message has been sent"));
-    $mails = $this->drupalGetMails();
-    $mail = end($mails);
-    // There should be nothing in the body except the contact message - no
-    // body injection like 'Originally to'.
-    $this->assertTrue(strpos($mail['body'], 'Originally to') === FALSE, 'Body does not contain "Originally to"');
-    $this->assertTrue($mail['headers']['X-Rerouted-Original-To'] == $this->originalDestination, 'X-Rerouted-Original-To is correctly set to the original destination email');
-  }
-}
-
-/**
- * Tests email rerouting for the Test Email form.
- */
-class RerouteEmailTestEmailTestCase extends RerouteEmailTestCase {
-
-  /**
-   * Implements DrupalWebTestCase::getInfo().
-   */
-  public static function getInfo() {
-    return array(
-      'name' => 'Test Email form',
-      'description' => "Test Reroute Email's form for sending a test email.",
-      'group' => 'Reroute Email',
-    );
-  }
-
-  /**
-   * Basic tests for reroute_email Test Email form.
-   *
-   * Check if submitted form values are properly submitted and rerouted.
-   * Test Subject, To, Cc, Bcc and Body submitted values, form validation,
-   * default values, and submission with invalid email addresses.
-   */
-  public function testFormTestEmail() {
-
-    // Configure to reroute normally to rerouted@example.com.
-    $this->configureRerouteEmail();
-
-    // Check Subject field default value.
-    $this->drupalGet("admin/config/development/reroute_email/test");
-    $this->assertFieldByName('subject', t("Reroute Email Test"), 'The expected default value was found for the Subject field.');
-
-    // Submit the Test Email form to send an email to be rerouted.
-    $post = array(
-      'to' => "to@example.com",
-      'cc' => "cc@example.com",
-      'bcc' => "bcc@example.com",
-      'subject' => "Test Reroute Email Test Email Form",
-      'body' => 'Testing email rerouting and the Test Email form',
-    );
-    $this->drupalPost("admin/config/development/reroute_email/test", $post, t("Send email"));
-    $this->assertText(t("Test email submitted for delivery."));
-    $mails = $this->drupalGetMails();
-    $mail = end($mails);
-    // Check rerouted email to.
-    $this->assertMail('to', $this->rerouteDestination, format_string('To email address was rerouted to @address.', array('@address' => $this->rerouteDestination)));
-
-    // Check the To passed through the Test Email Form.
-    $this->assertOriginallyTo($mail['body'], 'Found submitted "To" email address in the body', $post['to']);
-
-    // Check the Cc and Bcc headers are the ones submitted through the form.
-    $this->assertTrue($mail['headers']['X-Rerouted-Original-Cc'] == $post['cc'], format_string('X-Rerouted-Original-Cc is correctly set to submitted value: @address', array('@address' => $post['cc'])));
-    $this->assertTrue($mail['headers']['X-Rerouted-Original-Bcc'] == $post['bcc'], format_string('X-Rerouted-Original-Cc is correctly set to submitted value: @address', array('@address' => $post['bcc'])));
-    // Check the Subject and Body field values can be found in rerouted email.
-    $this->assertMail('subject', $post['subject'], format_string('Subject is correctly set to submitted value: @subject', array('@subject' => $post['subject'])));
-    $this->assertFalse(strpos($mail['body'], $post['body']) === FALSE, 'Body contains the value submitted through the form');
-
-    // Check required To field.
-    $this->drupalPost("admin/config/development/reroute_email/test", array('to' => ''), t("Send email"));
-    $this->assertText(t("To field is required."));
-
-    // Test form submission with email rerouting and invalid email addresses.
-    $post = array(
-      'to' => "To address invalid format",
-      'cc' => "Cc address invalid format",
-      'bcc' => "Bcc address invalid format",
-    );
-    $this->drupalPost("admin/config/development/reroute_email/test", $post, t("Send email"));
-    // Successful submission with email rerouting enabled.
-    $this->assertText(t("Test email submitted for delivery."));
-    $mails = $this->drupalGetMails();
-    $mail = end($mails);
-    // Check rerouted email to.
-    $this->assertMail('to', $this->rerouteDestination, format_string('To email address was rerouted to @address.', array('@address' => $this->rerouteDestination)));
-
-    // Check the To passed through the Test Email Form.
-    $this->assertOriginallyTo($mail['body'], 'Found submitted "To" email address in the body', $post['to']);
-
-    // Check the Cc and Bcc headers are the ones submitted through the form.
-    $this->assertTrue($mail['headers']['X-Rerouted-Original-Cc'] == $post['cc'], format_string('X-Rerouted-Original-Cc is correctly set to submitted value: @address', array('@address' => $post['cc'])));
-    $this->assertTrue($mail['headers']['X-Rerouted-Original-Bcc'] == $post['bcc'], format_string('X-Rerouted-Original-Cc is correctly set to submitted value: @address', array('@address' => $post['bcc'])));
-
-    // Now change the configuration to disable reroute and submit the Test
-    // Email form with the same invalid email address values.
-    $this->configureRerouteEmail(NULL, FALSE);
-
-    // Submit the test email form again with previously used invalid addresses.
-    $this->drupalPost("admin/config/development/reroute_email/test", $post, t("Send email"));
-    // Check invalid email addresses are still passed to the mail system.
-    $mails = $this->drupalGetMails();
-    $mail = end($mails);
-    // Check rerouted email to.
-    $this->assertMail('to', $post['to'], format_string('To email address is correctly set to submitted value: @address.', array('@address' => $post['to'])));
-    $this->verbose(t('Sent email values: <pre>@mail</pre>', array('@mail' => var_export($mail, TRUE))));
-    // Check the Cc and Bcc headers are the ones submitted through the form.
-    $this->assertTrue($mail['headers']['Cc'] == $post['cc'], format_string('Cc is correctly set to submitted value: @address', array('@address' => $post['cc'])));
-    $this->assertTrue($mail['headers']['Bcc'] == $post['bcc'], format_string('Bcc is correctly set to submitted value: @address', array('@address' => $post['bcc'])));
-  }
-}
-
-/**
- * Test handling of special cases for body as a string and Cc/Bcc robustness.
- */
-class RerouteEmailSpecialTestCase extends RerouteEmailTestCase {
-
-  /**
-   * Implements DrupalWebTestCase::getInfo().
-   */
-  public static function getInfo() {
-    return array(
-      'name' => 'Body as a string and robust headers',
-      'description' => "Support message's body passed as a string and Cc/Bcc header keys with an unexpected case.",
-      'group' => 'Reroute Email',
-    );
-  }
-
-  /**
-   * Enable modules and create user with specific permissions.
-   */
-  public function setUp() {
-    // Add more permissions to access recent log messages in test.
-    $this->permissions[] = 'access site reports';
-    // Include hidden test helper sub-module.
-    parent::setUp('reroute_email_test');
-  }
-
-  /**
-   * Test handling of message body as a string and header keys' robustness.
-   *
-   * A test email is sent by the reroute_email_test module with a string for
-   * the body of the email message and Cc/Bcc header keys with an unexpected
-   * case. Test if Reroute Email handles message's body properly when it is a
-   * string and captures all Cc/Bcc header keys independently of the case.
-   */
-  public function testBodyStringRobustHeaders() {
-    // Initialize Cc and Bcc keys with a special case.
-    $test_cc_key = 'cC';
-    $test_bcc_key = 'bCc';
-
-    // Configure to reroute normally to rerouted@example.com.
-    $this->configureRerouteEmail();
-
-    // Print test email values for comparing values on test results page.
-    $test_message = array(
-      'to' => $this->originalDestination,
-      'params' => array(
-        'body' => "Test Message body is a string.",
-        'headers' => array(
-          'test_cc_key' => $test_cc_key,
-          'test_bcc_key' => $test_bcc_key,
-          $test_cc_key => "test_cc_key@example.com",
-          $test_bcc_key => "test_bcc_key@example.com",
-        ),
-      ),
-    );
-    // Send test helper sub-module's email.
-    drupal_mail('reroute_email_test', 'test_reroute_email', $test_message['to'], language_default(), $test_message['params']);
-    $this->verbose(t('Test email message values: <pre>@test_message</pre>', array('@test_message' => var_export($test_message, TRUE))));
-
-    $mails = $this->drupalGetMails();
-    $mail = end($mails);
-    // Check rerouted email to.
-    $this->assertMail('to', $this->rerouteDestination, format_string('To email address was rerouted to @address.', array('@address' => $this->rerouteDestination)));
-
-    // Check if original destination email address is in rerouted email body.
-    $this->assertOriginallyTo($mail['body'], 'Found the correct "Originally to" line in the body');
-
-    // Check if test message body is found although provided as a string.
-    $this->assertTrue(strpos($mail['body'], $test_message['params']['body']) !== FALSE, 'Email body contains original message body although it was provided as a string.');
-
-    // Check the watchdog entry logged by reroute_email_test_mail_alter.
-    $this->drupalGet('admin/reports/dblog');
-    $this->assertRaw(t('A String was detected in the body'), 'Recorded in recent log messages: a String was detected in the body.');
-
-    // Test the robustness of the CC and BCC keys in headers.
-    $this->assertTrue($mail['headers']['X-Rerouted-Original-Cc'] == $test_message['params']['headers'][$test_cc_key], format_string('X-Rerouted-Original-Cc is correctly set to @test_cc_address, although Cc header message key provided was: @test_cc_key', array('@test_cc_address' => $test_message['params']['headers'][$test_cc_key], '@test_cc_key' => $test_cc_key)));
-    $this->assertTrue($mail['headers']['X-Rerouted-Original-Bcc'] == $test_message['params']['headers'][$test_bcc_key], format_string('X-Rerouted-Original-Bcc is correctly set to @test_bcc_address, although Bcc header message key provided was: @test_bcc_key', array('@test_bcc_address' => $test_message['params']['headers'][$test_bcc_key], '@test_bcc_key' => $test_bcc_key)));
-  }
-}
-
-/**
- * Test default reroute destination email address when it is empty or unset.
- */
-class RerouteEmailDefaultAddressTestCase extends RerouteEmailTestCase {
-
-  /**
-   * Implements DrupalWebTestCase::getInfo().
-   */
-  public static function getInfo() {
-    return array(
-      'name' => 'Default or empty reroute destination email address',
-      'description' => "When reroute email addresses field is not configured, attempt to use the site email address, otherwise use sendmail_from system variable.",
-      'group' => 'Reroute Email',
-    );
-  }
-
-  /**
-   * Enable modules and create user with specific permissions.
-   */
-  public function setUp() {
-    // Add more permissions to access recent log messages in test.
-    $this->permissions[] = 'access site reports';
-    parent::setUp();
-  }
-
-  /**
-   * Test reroute email address is set to site_mail, sendmail_from or empty.
-   *
-   * When reroute email addresses field is not configured and settings haven't
-   * been configured yet, check if the site email address or the sendmail_from
-   * system variable are properly used as fallbacks. Additionally, check that
-   * emails are aborted and a watchdog entry logged if reroute email address is
-   * set to an empty string.
-   */
-  public function testRerouteDefaultAddress() {
-    // Check default value for reroute_email_address when not configured.
-    // If Site email is not empty, it should be the default value.
-    // @FIXME
-// // @FIXME
-// // This looks like another module's variable. You'll need to rewrite this call
-// // to ensure that it uses the correct configuration object.
-// $default_destination = variable_get('site_mail', NULL);
-
-    $this->assertTrue(isset($default_destination), format_string('Site mail is not empty: @default_destination.', array('@default_destination' => $default_destination)));
-
-    // Programmatically enable email rerouting.
-    // @FIXME
-// // @FIXME
-// // The correct configuration object could not be determined. You'll need to
-// // rewrite this call manually.
-// variable_set(REROUTE_EMAIL_ENABLE, TRUE);
-
-    // Load the Reroute Email Settings form page. Ensure rerouting is enabled.
-    $this->drupalGet("admin/config/development/reroute_email/reroute_email");
-    $this->assertFieldByName(REROUTE_EMAIL_ENABLE, TRUE, 'Email rerouting was programmatically successfully enabled.');
-    // Check Email addresses field default value should be site_mail.
-    $this->assertFieldByName(REROUTE_EMAIL_ADDRESS, $default_destination, format_string('Site email address is configured and is the default value of the Email addresses field: @default_destination.', array('@default_destination' => $default_destination)));
-
-    // Ensure reroute_email_address is not set yet.
-    // @FIXME
-// // @FIXME
-// // The correct configuration object could not be determined. You'll need to
-// // rewrite this call manually.
-// $reroute_email_address = variable_get(REROUTE_EMAIL_ADDRESS, NULL);
-
-    $this->assertFalse(isset($reroute_email_address), 'Reroute email destination address is not configured.');
-
-    // Submit a test email and check if it is rerouted to site_mail address.
-    $this->drupalPost("admin/config/development/reroute_email/test", array('to' => "to@example.com"), t("Send email"));
-    $this->assertText(t("Test email submitted for delivery."));
-    $mails = $this->drupalGetMails();
-    $mail = end($mails);
-    // Check rerouted email is the site email address.
-    $this->assertMail('to', $default_destination, format_string('Email was properly rerouted to site email address: @default_destination.', array('@default_destination' => $default_destination)));
-
-    // Now unset site_mail to check if system sendmail_from is properly used.
-    // @FIXME
-// // @FIXME
-// // This looks like another module's variable. You'll need to rewrite this call
-// // to ensure that it uses the correct configuration object.
-// variable_del('site_mail');
-
-    // If it is defined, try to test the default sendmail_from system variable.
-    $system_email = ini_get('sendmail_from');
-    // Fallback to default placeholder if no system variable configured.
-    $default_destination = empty($system_email) ? REROUTE_EMAIL_ADDRESS_EMPTY_PLACEHOLDER : $system_email;
-
-    // Reload the Reroute Email Settings form page.
-    $this->drupalGet("admin/config/development/reroute_email/reroute_email");
-    // Check Email addresses field default value should be system default.
-    $this->assertFieldByName('reroute_email_address', $system_email, format_string('Site email address is not configured, Email addresses field defaults to system sendmail_from: <em>@default_destination</em>.', array('@default_destination' => $system_email)));
-
-    // Submit a test email to check if it is rerouted to sendmail_from address.
-    $this->drupalPost("admin/config/development/reroute_email/test", array('to' => "to@example.com"), t("Send email"));
-    $this->assertText(t("Test email submitted for delivery."));
-    $mails = $this->drupalGetMails();
-    $mail = end($mails);
-    // Check rerouted email is the system sendmail_from email address.
-    $this->assertMail('to', $default_destination, format_string('Email was properly rerouted to system sendmail_from email address: @default_destination.', array('@default_destination' => $default_destination)));
-
-    // Configure reroute email address to be emtpy: ensure emails are aborted.
-    $this->configureRerouteEmail('');
-
-    // Make sure reroute_email_address variable is an empty string.
-    // @FIXME
-// // @FIXME
-// // The correct configuration object could not be determined. You'll need to
-// // rewrite this call manually.
-// $reroute_email_address = variable_get(REROUTE_EMAIL_ADDRESS, NULL);
-
-    $this->assertTrue(is_string($reroute_email_address), 'Reroute email destination address is configured to be an empty string.');
-    // Flush the Test Mail collector to ensure it is empty for this tests.
-    // @FIXME
-// // @FIXME
-// // This looks like another module's variable. You'll need to rewrite this call
-// // to ensure that it uses the correct configuration object.
-// variable_set('drupal_test_email_collector', array());
-
-
-    // Submit a test email to check if it is aborted.
-    $this->drupalPost("admin/config/development/reroute_email/test", array('to' => "to@example.com"), t("Send email"));
-    $mails = $this->drupalGetMails();
-    $mail_aborted = end($mails);
-    $this->assertFalse($mail_aborted, 'Email sending was properly aborted because rerouting email address is an empty string.');
-    // Check status message is displayed properly after email form submission.
-    $this->assertRaw(t('<em>@message_id</em> was aborted by reroute email, please check the <a href="@dblog">recent log entries</a> for complete details on the rerouted email.', array('@message_id' => $mail['id'], '@dblog' => \Drupal\Core\Url::fromRoute('dblog.overview'))), format_string('Status message displayed as expected to the user with the mail ID <em>(@message_id)</em> and a link to recent log entries.', array('@message_id' => $mail['id'])));
-
-    // Check the watchdog entry logged with aborted email message.
-    $this->drupalGet('admin/reports/dblog');
-    // Check the link to the watchdog detailed message.
-    $watchdog_link = $this->xpath('//table[@id="admin-dblog"]/tbody/tr[contains(@class,"dblog-reroute-email")][1]/td[text()="reroute_email"]/following-sibling::td/a[contains(text(),"reroute_email")]');
-    $link_label = (string) $watchdog_link[0];
-    $this->assertTrue(isset($watchdog_link[0]), format_string("Recorded successfully a watchdog log entry in recent log messages: <em>@link</em>.", array('@link' => $link_label)));
-    // Open the full view page of the log message found for reroute_email.
-    $this->clickLink($link_label);
-
-    // Recreate expected logged message based on email submitted previously.
-    $mail['send'] = FALSE;
-    $mail['body'] = array($mail['body'], NULL);
-    // Ensure the correct email is logged with default 'to' placeholder.
-    $mail['to'] = REROUTE_EMAIL_ADDRESS_EMPTY_PLACEHOLDER;
-    $this->assertRaw(t('Aborted email sending for <em>@message_id</em>. <br/>Detailed email data: Array $message <pre>@message</pre>', array(
-      '@message_id' => $mail['id'],
-      '@message' => print_r($mail, TRUE),
-    )), format_string('The log entry recorded by Reroute Email contains a full dump of the aborted email message <em>@message_id</em> and is formatted as expected.', array('@message_id' => $mail['id'])));
-  }
-}
diff --git a/reroute_email.variable.inc b/reroute_email.variable.inc
deleted file mode 100644
index c780f17..0000000
--- a/reroute_email.variable.inc
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-/**
- * @file
- * Variable module integration.
- */
-
-/**
- * Implements hook_variable_info().
- */
-function reroute_email_variable_info() {
-  $variable = array();
-
-  $variable[REROUTE_EMAIL_ENABLE] = array(
-    'title' => t('Enable rerouting'),
-    'description' => t('Check this box if you want to enable email rerouting. Uncheck to disable rerouting.'),
-    'type' => 'boolean',
-    'default' => 0,
-    'group' => 'reroute_email',
-  );
-
-  // @FIXME
-// // @FIXME
-// // This looks like another module's variable. You'll need to rewrite this call
-// // to ensure that it uses the correct configuration object.
-$variable[REROUTE_EMAIL_ADDRESS] = array(
-    'title' => t('Email addresses'),
-    'description' => t('Provide a space, comma, or semicolon-delimited list of email addresses to pass through. Every destination email address which is not on this list will be rerouted to the first address on the list.'),
-    'default' => 'devarajjohnson23@gmail.com',
-    'group' => 'reroute_email',
-  );
-
-
-  $variable[REROUTE_EMAIL_ENABLE_MESSAGE] = array(
-    'title' => t('Show rerouting description in mail body'),
-    'description' => t('Check this box if you want a message to be inserted into the email body when the mail is being rerouted. Otherwise, SMTP headers will be used to describe the rerouting. If sending rich-text email, leave this unchecked so that the body of the email will not be disturbed.'),
-    'type' => 'boolean',
-    'default' => 1,
-    'group' => 'reroute_email',
-  );
-
-  return $variable;
-}
-
-/**
- * Implements hook_variable_group_info().
- */
-function reroute_email_variable_group_info() {
-  $groups['reroute_email'] = array(
-    'title' => t('Reroute Email'),
-    'description' => t('Reroute email configuration settings'),
-    'access' => 'administer reroute email',
-    'path' => array('admin/config/development/reroute_email'),
-  );
-  return $groups;
-}
diff --git a/src/Form/RerouteEmailSettings.php b/src/Form/RerouteEmailSettings.php
index 56f0700..5bfd31e 100644
--- a/src/Form/RerouteEmailSettings.php
+++ b/src/Form/RerouteEmailSettings.php
@@ -26,8 +26,8 @@ class RerouteEmailSettings extends ConfigFormBase {
   public function submitForm(array &$form, FormStateInterface $form_state) {
     $config = $this->config('reroute_email.settings');
 
-    foreach (Element::children($form) as $variable) {
-      $config->set($variable, $form_state->getValue($form[$variable]['#parents']));
+    foreach (['reroute_email_enable', 'reroute_email_address', 'reroute_email_enable_message'] as $variable) {
+      $config->set($variable, $form_state->getValue($variable));
     }
     $config->save();
 
@@ -46,10 +46,6 @@ class RerouteEmailSettings extends ConfigFormBase {
   }
 
   public function buildForm(array $form, \Drupal\Core\Form\FormStateInterface $form_state) {
-    // @FIXME
-// // @FIXME
-// // The correct configuration object could not be determined. You'll need to
-// // rewrite this call manually.
 $form[REROUTE_EMAIL_ENABLE] = array(
     '#type'          => 'checkbox',
     '#title'         => 'Enable rerouting',
@@ -57,22 +53,20 @@ $form[REROUTE_EMAIL_ENABLE] = array(
     '#description'   => 'Check this box if you want to enable email rerouting. Uncheck to disable rerouting.',
   );
 
-// @FIXME
-// The correct configuration object could not be determined. You'll need to
-// rewrite this call manually.
+    $default_address = \Drupal::config('reroute_email.settings')->get(REROUTE_EMAIL_ADDRESS);
+    if (empty($default_address)) {
+      $default_address = \Drupal::config('system.site')->get('mail');
+    }
 $form[REROUTE_EMAIL_ADDRESS] = array(
     '#type'          => 'textfield',
     '#title'         => 'Email addresses',
-    '#default_value' => \Drupal::config('reroute_email.settings')->get(REROUTE_EMAIL_ADDRESS),
+    '#default_value' => $default_address,
     '#description'   => 'Provide a space, comma, or semicolon-delimited list of email addresses to pass through. Every destination email address which is not on this list will be rerouted to the first address on the list.<br/> If the field is empty and no value is provided, <strong>all outgoing emails would be aborted</strong> and the email would be recorded in the <a href="@dblog">recent log entries</a>.', array('#dblog' => \Drupal\Core\Url::fromRoute('dblog.overview')),
     '#states' => array(
       'visible' => array(':input[name=reroute_email_enable]' => array('checked' => TRUE)),
     ),
   );
 
-// @FIXME
-// The correct configuration object could not be determined. You'll need to
-// rewrite this call manually.
 $form[REROUTE_EMAIL_ENABLE_MESSAGE] = array(
     '#type' => 'checkbox',
     '#title' => 'Show rerouting description in mail body',
diff --git a/src/Form/RerouteEmailTestEmailForm.php b/src/Form/RerouteEmailTestEmailForm.php
index 2b2b243..ec8d9de 100644
--- a/src/Form/RerouteEmailTestEmailForm.php
+++ b/src/Form/RerouteEmailTestEmailForm.php
@@ -56,13 +56,13 @@ class RerouteEmailTestEmailForm extends FormBase {
   }
 
   public function submitForm(array &$form, \Drupal\Core\Form\FormStateInterface $form_state) {
-    
-    $from = "devarajjohnson23@gmail.com";
+
+    $from = "somewhere@example.com";
     $to = $form_state->getValue(['to']);
     $param_keys = ['cc', 'bcc', 'subject', 'body'];
     $params = array_intersect_key($form_state->getValues(), array_flip($param_keys));
     $langcode = \Drupal::languageManager()->getDefaultLanguage();
-    
+
     // Send email with drupal_mail.
     $message =  \Drupal::service('plugin.manager.mail')->mail('reroute_email', 'test_email_form', $to, $langcode, $params, $from);
 
diff --git a/src/RerouteEmailDefaultAddressTestCase.php b/src/RerouteEmailDefaultAddressTestCase.php
deleted file mode 100644
index 0299a7d..0000000
--- a/src/RerouteEmailDefaultAddressTestCase.php
+++ /dev/null
@@ -1,150 +0,0 @@
-<?php
-namespace Drupal\reroute_email;
-
-/**
- * Test default reroute destination email address when it is empty or unset.
- */
-class RerouteEmailDefaultAddressTestCase extends RerouteEmailTestCase {
-
-  /**
-   * Implements DrupalWebTestCase::getInfo().
-   */
-  public static function getInfo() {
-    return array(
-      'name' => 'Default or empty reroute destination email address',
-      'description' => "When reroute email addresses field is not configured, attempt to use the site email address, otherwise use sendmail_from system variable.",
-      'group' => 'Reroute Email',
-    );
-  }
-
-  /**
-   * Enable modules and create user with specific permissions.
-   */
-  public function setUp() {
-    // Add more permissions to access recent log messages in test.
-    $this->permissions[] = 'access site reports';
-    parent::setUp();
-  }
-
-  /**
-   * Test reroute email address is set to site_mail, sendmail_from or empty.
-   *
-   * When reroute email addresses field is not configured and settings haven't
-   * been configured yet, check if the site email address or the sendmail_from
-   * system variable are properly used as fallbacks. Additionally, check that
-   * emails are aborted and a watchdog entry logged if reroute email address is
-   * set to an empty string.
-   */
-  public function testRerouteDefaultAddress() {
-    // Check default value for reroute_email_address when not configured.
-    // If Site email is not empty, it should be the default value.
-    // @FIXME
-// // @FIXME
-// // This looks like another module's variable. You'll need to rewrite this call
-// // to ensure that it uses the correct configuration object.
-// $default_destination = variable_get('site_mail', NULL);
-
-    $this->assertTrue(isset($default_destination), format_string('Site mail is not empty: @default_destination.', array('@default_destination' => $default_destination)));
-
-    // Programmatically enable email rerouting.
-    // @FIXME
-// // @FIXME
-// // The correct configuration object could not be determined. You'll need to
-// // rewrite this call manually.
-// variable_set(REROUTE_EMAIL_ENABLE, TRUE);
-
-    // Load the Reroute Email Settings form page. Ensure rerouting is enabled.
-    $this->drupalGet("admin/config/development/reroute_email/reroute_email");
-    $this->assertFieldByName(REROUTE_EMAIL_ENABLE, TRUE, 'Email rerouting was programmatically successfully enabled.');
-    // Check Email addresses field default value should be site_mail.
-    $this->assertFieldByName(REROUTE_EMAIL_ADDRESS, $default_destination, format_string('Site email address is configured and is the default value of the Email addresses field: @default_destination.', array('@default_destination' => $default_destination)));
-
-    // Ensure reroute_email_address is not set yet.
-    // @FIXME
-// // @FIXME
-// // The correct configuration object could not be determined. You'll need to
-// // rewrite this call manually.
-// $reroute_email_address = variable_get(REROUTE_EMAIL_ADDRESS, NULL);
-
-    $this->assertFalse(isset($reroute_email_address), 'Reroute email destination address is not configured.');
-
-    // Submit a test email and check if it is rerouted to site_mail address.
-    $this->drupalPost("admin/config/development/reroute_email/test", array('to' => "to@example.com"), t("Send email"));
-    $this->assertText(t("Test email submitted for delivery."));
-    $mails = $this->drupalGetMails();
-    $mail = end($mails);
-    // Check rerouted email is the site email address.
-    $this->assertMail('to', $default_destination, format_string('Email was properly rerouted to site email address: @default_destination.', array('@default_destination' => $default_destination)));
-
-    // Now unset site_mail to check if system sendmail_from is properly used.
-    // @FIXME
-// // @FIXME
-// // This looks like another module's variable. You'll need to rewrite this call
-// // to ensure that it uses the correct configuration object.
-// variable_del('site_mail');
-
-    // If it is defined, try to test the default sendmail_from system variable.
-    $system_email = ini_get('sendmail_from');
-    // Fallback to default placeholder if no system variable configured.
-    $default_destination = empty($system_email) ? REROUTE_EMAIL_ADDRESS_EMPTY_PLACEHOLDER : $system_email;
-
-    // Reload the Reroute Email Settings form page.
-    $this->drupalGet("admin/config/development/reroute_email/reroute_email");
-    // Check Email addresses field default value should be system default.
-    $this->assertFieldByName('reroute_email_address', $system_email, format_string('Site email address is not configured, Email addresses field defaults to system sendmail_from: <em>@default_destination</em>.', array('@default_destination' => $system_email)));
-
-    // Submit a test email to check if it is rerouted to sendmail_from address.
-    $this->drupalPost("admin/config/development/reroute_email/test", array('to' => "to@example.com"), t("Send email"));
-    $this->assertText(t("Test email submitted for delivery."));
-    $mails = $this->drupalGetMails();
-    $mail = end($mails);
-    // Check rerouted email is the system sendmail_from email address.
-    $this->assertMail('to', $default_destination, format_string('Email was properly rerouted to system sendmail_from email address: @default_destination.', array('@default_destination' => $default_destination)));
-
-    // Configure reroute email address to be emtpy: ensure emails are aborted.
-    $this->configureRerouteEmail('');
-
-    // Make sure reroute_email_address variable is an empty string.
-    // @FIXME
-// // @FIXME
-// // The correct configuration object could not be determined. You'll need to
-// // rewrite this call manually.
-// $reroute_email_address = variable_get(REROUTE_EMAIL_ADDRESS, NULL);
-
-    $this->assertTrue(is_string($reroute_email_address), 'Reroute email destination address is configured to be an empty string.');
-    // Flush the Test Mail collector to ensure it is empty for this tests.
-    // @FIXME
-// // @FIXME
-// // This looks like another module's variable. You'll need to rewrite this call
-// // to ensure that it uses the correct configuration object.
-// variable_set('drupal_test_email_collector', array());
-
-
-    // Submit a test email to check if it is aborted.
-    $this->drupalPost("admin/config/development/reroute_email/test", array('to' => "to@example.com"), t("Send email"));
-    $mails = $this->drupalGetMails();
-    $mail_aborted = end($mails);
-    $this->assertFalse($mail_aborted, 'Email sending was properly aborted because rerouting email address is an empty string.');
-    // Check status message is displayed properly after email form submission.
-    $this->assertRaw(t('<em>@message_id</em> was aborted by reroute email, please check the <a href="@dblog">recent log entries</a> for complete details on the rerouted email.', array('@message_id' => $mail['id'], '@dblog' => \Drupal\Core\Url::fromRoute('dblog.overview'))), format_string('Status message displayed as expected to the user with the mail ID <em>(@message_id)</em> and a link to recent log entries.', array('@message_id' => $mail['id'])));
-
-    // Check the watchdog entry logged with aborted email message.
-    $this->drupalGet('admin/reports/dblog');
-    // Check the link to the watchdog detailed message.
-    $watchdog_link = $this->xpath('//table[@id="admin-dblog"]/tbody/tr[contains(@class,"dblog-reroute-email")][1]/td[text()="reroute_email"]/following-sibling::td/a[contains(text(),"reroute_email")]');
-    $link_label = (string) $watchdog_link[0];
-    $this->assertTrue(isset($watchdog_link[0]), format_string("Recorded successfully a watchdog log entry in recent log messages: <em>@link</em>.", array('@link' => $link_label)));
-    // Open the full view page of the log message found for reroute_email.
-    $this->clickLink($link_label);
-
-    // Recreate expected logged message based on email submitted previously.
-    $mail['send'] = FALSE;
-    $mail['body'] = array($mail['body'], NULL);
-    // Ensure the correct email is logged with default 'to' placeholder.
-    $mail['to'] = REROUTE_EMAIL_ADDRESS_EMPTY_PLACEHOLDER;
-    $this->assertRaw(t('Aborted email sending for <em>@message_id</em>. <br/>Detailed email data: Array $message <pre>@message</pre>', array(
-      '@message_id' => $mail['id'],
-      '@message' => print_r($mail, TRUE),
-    )), format_string('The log entry recorded by Reroute Email contains a full dump of the aborted email message <em>@message_id</em> and is formatted as expected.', array('@message_id' => $mail['id'])));
-  }
-}
diff --git a/src/RerouteEmailTestCase.php b/src/RerouteEmailTestBase.php
similarity index 86%
rename from src/RerouteEmailTestCase.php
rename to src/RerouteEmailTestBase.php
index 0c92ac9..d30ed3b 100644
--- a/src/RerouteEmailTestCase.php
+++ b/src/RerouteEmailTestBase.php
@@ -1,10 +1,17 @@
 <?php
+
 namespace Drupal\reroute_email;
 
+use Drupal\simpletest\WebTestBase;
+
 /**
- * Provides common functionality for the Reroute Email test classes.
+ * Tests for reroute_email.
+ *
+ * @group reroute_email
  */
-class RerouteEmailTestCase extends DrupalWebTestCase {
+class RerouteEmailTestBase extends WebTestBase  {
+
+  public static $modules = ['reroute_email'];
 
   /**
    * User object to perform site browsing.
@@ -40,13 +47,7 @@ class RerouteEmailTestCase extends DrupalWebTestCase {
    * Enable modules and create user with specific permissions.
    */
   public function setUp() {
-    // Merge inherited classes modules, see FieldUITestCase for an example.
-    $modules = func_get_args();
-    if (isset($modules[0]) && is_array($modules[0])) {
-      $modules = $modules[0];
-    }
-    $modules[] = 'reroute_email';
-    parent::setUp($modules);
+    parent::setUp();
 
     // Authenticate test user.
     $this->adminUser = $this->drupalCreateUser($this->permissions);
@@ -76,7 +77,7 @@ class RerouteEmailTestCase extends DrupalWebTestCase {
       'reroute_email_enable_message' => $reroute_email_enable_message,
     );
     // Submit Reroute Email Settings form and check if it was successful.
-    $this->drupalPost("admin/config/development/reroute_email", $post, t('Save configuration'));
+    $this->drupalPostForm("admin/config/development/reroute_email", $post, t('Save configuration'));
     $this->assertText(t("The configuration options have been saved."));
   }
 
diff --git a/src/RerouteEmailContactTestCase.php b/src/Tests/ContactTest.php
similarity index 61%
rename from src/RerouteEmailContactTestCase.php
rename to src/Tests/ContactTest.php
index afb72a7..165f017 100644
--- a/src/RerouteEmailContactTestCase.php
+++ b/src/Tests/ContactTest.php
@@ -1,21 +1,17 @@
 <?php
-namespace Drupal\reroute_email;
+
+namespace Drupal\reroute_email\Tests;
+
+use Drupal\reroute_email\RerouteEmailTestBase;
 
 /**
- * Tests email rerouting for the site-wide Core Contact form.
+ * Test Reroute Email module's ability to reroute mail sent from the Contact module form.
+ *
+ * @group reroute_email
  */
-class RerouteEmailContactTestCase extends RerouteEmailTestCase {
+class ContactTest extends RerouteEmailTestBase {
 
-  /**
-   * Implements DrupalWebTestCase::getInfo().
-   */
-  public static function getInfo() {
-    return array(
-      'name' => 'Site-wide Core Contact form email rerouting',
-      'description' => "Test Reroute Email module's ability to reroute mail sent from the Core Contact module forms.",
-      'group' => 'Reroute Email',
-    );
-  }
+  public static $modules = ['reroute_email', 'contact'];
 
   /**
    * Enable modules and create user with specific permissions.
@@ -24,8 +20,15 @@ class RerouteEmailContactTestCase extends RerouteEmailTestCase {
     // Add more permissions to be able to manipulate the contact forms.
     $this->permissions[] = 'administer contact forms';
     $this->permissions[] = 'access site-wide contact form';
-    // Include Core Contact module.
-    parent::setUp('contact');
+    parent::setUp();
+
+    // Create a "feedback" contact form
+    $this->drupalPostForm('admin/structure/contact/add', ['label' => 'feedback', 'id' => 'feedback', 'recipients' => $this->originalDestination, 'selected' => 1], 'Save');
+    $this->assertResponse(200, 'Contact form named "feedback" added and made default');
+
+    \Drupal::service('config.factory')->getEditable('contact.settings')
+      ->set('flood.limit', 1000)
+      ->set('flood.interval', 60);
   }
 
   /**
@@ -43,15 +46,19 @@ class RerouteEmailContactTestCase extends RerouteEmailTestCase {
     $this->configureRerouteEmail();
 
     // Configure the contact settings to send to $original_destination.
-    $this->drupalPost('admin/structure/contact/edit/1', array('recipients' => $this->originalDestination), t('Save'));
+    $this->drupalPostForm('admin/structure/contact/manage/feedback', array('recipients' => $this->originalDestination), t('Save'));
 
     // Go to the contact page and send an email.
-    $post = array('subject' => "Test test test", 'message' => 'This is a test');
-    $this->drupalPost("contact", $post, t("Send message"));
+    $post = array('subject[0][value]' => "Test test test", 'message[0][value]' => 'This is a test');
+    $this->drupalPostForm("contact", $post, 'Send message');
+    $this->assertResponse(200, 'Posted contact form successfully');
+
     $this->assertText(t("Your message has been sent"));
     $mails = $this->drupalGetMails();
+
     $mail = end($mails);
-    $this->assertMail('to', $this->rerouteDestination, format_string("Email was rerouted to @address", array('@address' => $this->rerouteDestination)));
+    $this->assertMail('to', $this->rerouteDestination, t("Email was rerouted to @address", array('@address' => $this->rerouteDestination)));
+
     // Check if original destination email address is in rerouted email body.
     $this->assertOriginallyTo($mail['body'], 'Found the correct "Originally to" line in the body');
     $this->assertTrue(strpos($mail['body'], 'Originally to') !== FALSE, 'Body does contain "Originally to"');
@@ -62,25 +69,23 @@ class RerouteEmailContactTestCase extends RerouteEmailTestCase {
     $this->configureRerouteEmail("{$this->rerouteDestination}, $additional_destination");
 
     // Configure the contact settings to point to the additional recipient.
-    $this->drupalPost('admin/structure/contact/edit/1', array('recipients' => $additional_destination), t('Save'));
+    $this->drupalPostForm('admin/structure/contact/manage/feedback', array('recipients' => $additional_destination), t('Save'));
 
     // Go to the contact page and send an email.
-    $post = array('subject' => "Test test test", 'message' => 'This is a test');
-    $this->drupalPost("contact", $post, t("Send message"));
+    $post = array('subject[0][value]' => "Test test test", 'message[0][value]' => 'This is a test');
+    $this->drupalPostForm("contact", $post, t("Send message"));
     $this->assertText(t("Your message has been sent"));
-    $mails = $this->drupalGetMails();
-    $mail = end($mails);;
     $this->assertMail('to', $additional_destination, 'Email was not rerouted because destination was in whitelist');
 
-    // Now change the configuration to disable reroute and set the original
-    // email recipients.
+    // Now change the configuration to disable reroute and set the default
+    // email recipients (from system.site.mail)
     $this->configureRerouteEmail(NULL, FALSE);
 
     // Set the contact form to send to original_destination.
-    $this->drupalPost('admin/structure/contact/edit/1', array('recipients' => $this->originalDestination), t('Save'));
+    $this->drupalPostForm('admin/structure/contact/manage/feedback', array('recipients' => $this->originalDestination), t('Save'));
     // Go to the contact page and send an email.
-    $post = array('subject' => "Test test test", 'message' => 'This is a test');
-    $this->drupalPost("contact", $post, t("Send message"));
+    $post = array('subject[0][value]' => "Test test test", 'message[0][value]' => 'This is a test');
+    $this->drupalPostForm("contact", $post, t("Send message"));
     $this->assertText(t("Your message has been sent"));
     $mails = $this->drupalGetMails();
     $mail = end($mails);
@@ -92,8 +97,8 @@ class RerouteEmailContactTestCase extends RerouteEmailTestCase {
     $this->configureRerouteEmail(NULL, TRUE, FALSE);
 
     // Go to the contact page and send an email.
-    $post = array('subject' => "Test test test", 'message' => 'This is a test');
-    $this->drupalPost("contact", $post, t("Send message"));
+    $post = array('subject[0][value]' => "Test test test", 'message[0][value]' => 'This is a test');
+    $this->drupalPostForm("contact", $post, t("Send message"));
     $this->assertText(t("Your message has been sent"));
     $mails = $this->drupalGetMails();
     $mail = end($mails);
diff --git a/src/Tests/DefaultAddressTest.php b/src/Tests/DefaultAddressTest.php
new file mode 100644
index 0000000..65de4e7
--- /dev/null
+++ b/src/Tests/DefaultAddressTest.php
@@ -0,0 +1,132 @@
+<?php
+
+namespace Drupal\reroute_email\Tests;
+
+use Drupal\reroute_email\RerouteEmailTestBase;
+
+/**
+ * When reroute email addresses field is not configured, attempt to use the site email address, otherwise use sendmail_from system variable.
+ *
+ * @group reroute_email
+ */
+class DefaultAddressTest extends RerouteEmailTestBase {
+
+  public static $modules = ['reroute_email', 'dblog'];
+
+  /**
+   * Enable modules and create user with specific permissions.
+   */
+  public function setUp() {
+// Add more permissions to access recent log messages in test.
+    $this->permissions[] = 'access site reports';
+    parent::setUp();
+  }
+
+  /**
+   * Test reroute email address is set to site_mail, sendmail_from or empty.
+   *
+   * When reroute email addresses field is not configured and settings haven't
+   * been configured yet, check if the site email address or the sendmail_from
+   * system variable are properly used as fallbacks. Additionally, check that
+   * emails are aborted and a watchdog entry logged if reroute email address is
+   * set to an empty string.
+   */
+  public function testRerouteDefaultAddress() {
+
+    $config = \Drupal::service('config.factory')->getEditable('reroute_email.settings');
+
+    // Check default value for reroute_email_address when not conf  igured.
+    // If system.site's 'mail' is not empty, it should be the default value.
+    $site_mail = \Drupal::config('system.site')->get('mail');
+
+    $this->assertTrue(isset($site_mail), t('Site mail is not empty: @site_mail.', array('@site_mail' => $site_mail)));
+
+    // Programmatically enable email rerouting.
+    $config->set(REROUTE_EMAIL_ENABLE, TRUE);
+    $config->save();
+
+    // Load the Reroute Email Settings form page. Ensure rerouting is enabled.
+    $this->drupalGet("admin/config/development/reroute_email");
+    $this->assertFieldChecked('edit-reroute-email-enable', 'Email rerouting was programmatically successfully enabled.');
+
+    $reroute_email_enable = $config->get(REROUTE_EMAIL_ENABLE);
+    $this->assertTrue($reroute_email_enable, 'Rerouting is enabled');
+
+    // Check Email addresses field default value should be the value of system.site.mail.
+    $this->assertFieldByName(REROUTE_EMAIL_ADDRESS, $site_mail, t('reroute_email_address default value on form is system.site.mail value: @site_mail.', array('@site_mail' => $site_mail)));
+
+    // Ensure reroute_email_address is actually empty at this point.
+    $reroute_email_address = $config->get(REROUTE_EMAIL_ADDRESS);
+    $this->assertNull($reroute_email_address, 'Reroute email destination address is not configured.');
+
+    // Submit a test email and check if it is rerouted to system.site.mail address.
+    $this->drupalPostForm("admin/config/development/reroute_email/test", ['to' => 'to@example.com'], 'Send email');
+    $this->assertText(t("Test email submitted for delivery from test form."));
+    $mails = $this->drupalGetMails();
+    $this->assert(count($mails) == 1, 'Exactly one email captured');
+    $this->verboseEmail();
+    // Check rerouted email is the site email address.
+    $this->assertMail('to', $site_mail, t('Email was properly rerouted to site email address: @default_destination.', array('@default_destination' => $site_mail)));
+
+    // Unset system.site.mail
+    \Drupal::service('config.factory')
+      ->getEditable('system.site')
+      ->set('mail', NULL)
+      ->save();
+
+    // If sendmail_from is defined, try to test the default sendmail_from system variable.
+    $system_email = ini_get('sendmail_from');
+    // Fallback to default placeholder if no system variable configured.
+    $site_mail = empty($system_email) ? REROUTE_EMAIL_ADDRESS_EMPTY_PLACEHOLDER : $system_email;
+
+    // Reload the Reroute Email Settings form page.
+    $this->drupalGet("admin/config/development/reroute_email");
+    // Check Email addresses field default value should be system default.
+    $this->assertFieldByName('reroute_email_address', $system_email, format_string('Site email address is not configured, Email addresses field defaults to system sendmail_from: <em>@default_destination</em>.', array('@default_destination' => $system_email)));
+
+    // Submit a test email to check if it is rerouted to sendmail_from address.
+    $this->drupalPostForm("admin/config/development/reroute_email/test", array('to' => "to@example.com"), t("Send email"));
+    $this->assertText(t("Test email submitted for delivery from test form."));
+    $mails = $this->drupalGetMails();
+    $mail = end($mails);
+    // Check rerouted email is the system sendmail_from email address.
+    $this->assertMail('to', $site_mail, format_string('Email was properly rerouted to system sendmail_from email address: @default_destination.', array('@default_destination' => $site_mail)));
+
+    // Configure reroute email address to be emtpy: ensure emails are aborted.
+    $this->configureRerouteEmail('');
+
+    // Make sure reroute_email_address variable is an empty string.
+
+    $reroute_email_address = \Drupal::config('reroute_email.settings')
+      ->get(REROUTE_EMAIL_ADDRESS);
+    $this->assertTrue($reroute_email_address === '', 'Reroute email destination address is an empty string.');
+    // Flush the Test Mail collector to ensure it is empty for this tests.
+    \Drupal::state()->set('system.test_mail_collector', array());
+
+    // Submit a test email to check if it is aborted.
+    $this->drupalPostForm("admin/config/development/reroute_email/test", array('to' => "to@example.com"), t("Send email"));
+    $mails = $this->drupalGetMails();
+    $this->assertTrue(count($mails) == 0, 'Email sending was properly aborted because rerouting email address is an empty string.');
+    // Check status message is displayed properly after email form submission.
+    $this->assertPattern('/' . t('@message_id.*was aborted by reroute email', [
+      '@message_id' => $mail['id']]) . '/', t('Status message displayed as expected to the user with the mail ID <em>(@message_id)</em> and a link to recent log entries.', array('@message_id' => $mail['id'])));
+
+    // Check the watchdog entry logged with aborted email message.
+    $this->drupalGet('admin/reports/dblog');
+    // Check the link to the watchdog detailed message.
+    $dblog_link = $this->xpath('//table[@id="admin-dblog"]/tbody/tr[contains(@class,"dblog-reroute-email")][1]/td[text()="reroute_email"]/following-sibling::td/a[contains(text(),"reroute_email")]');
+    $link_label = (string) $dblog_link[0];
+    $this->assertTrue(isset($dblog_link[0]), t('Logged a message in dblog: <em>@link</em>.', array('@link' => $link_label)));
+    // Open the full view page of the log message found for reroute_email.
+    $this->clickLink($link_label);
+
+    // Recreate expected logged message based on email submitted previously.
+    $mail['send'] = FALSE;
+    $mail['body'] = array($mail['body'], NULL);
+    // Ensure the correct email is logged with default 'to' placeholder.
+    $mail['to'] = REROUTE_EMAIL_ADDRESS_EMPTY_PLACEHOLDER;
+    $this->assertPattern( '/' . t('Aborted email sending for.*@message_id.*Detailed email data',
+      ['@message_id' => $mail['id']]) . '/',
+      t('The dblog entry recorded by Reroute Email contains a dump of the aborted email message <em>@message_id</em> and is formatted as expected.', ['@message_id' => $mail['id']]));
+  }
+}
diff --git a/src/RerouteEmailTestEmailTestCase.php b/src/Tests/TestEmailTest.php
similarity index 83%
rename from src/RerouteEmailTestEmailTestCase.php
rename to src/Tests/TestEmailTest.php
index 0f0a32e..c4e3c11 100644
--- a/src/RerouteEmailTestEmailTestCase.php
+++ b/src/Tests/TestEmailTest.php
@@ -1,21 +1,15 @@
 <?php
-namespace Drupal\reroute_email;
+
+namespace Drupal\reroute_email\Tests;
+
+use Drupal\reroute_email\RerouteEmailTestBase;
 
 /**
- * Tests email rerouting for the Test Email form.
+ * Test Reroute Email's form for sending a test email.
+ *
+ * @group reroute_email
  */
-class RerouteEmailTestEmailTestCase extends RerouteEmailTestCase {
-
-  /**
-   * Implements DrupalWebTestCase::getInfo().
-   */
-  public static function getInfo() {
-    return array(
-      'name' => 'Test Email form',
-      'description' => "Test Reroute Email's form for sending a test email.",
-      'group' => 'Reroute Email',
-    );
-  }
+class TestEmailTest extends RerouteEmailTestBase {
 
   /**
    * Basic tests for reroute_email Test Email form.
@@ -41,8 +35,8 @@ class RerouteEmailTestEmailTestCase extends RerouteEmailTestCase {
       'subject' => "Test Reroute Email Test Email Form",
       'body' => 'Testing email rerouting and the Test Email form',
     );
-    $this->drupalPost("admin/config/development/reroute_email/test", $post, t("Send email"));
-    $this->assertText(t("Test email submitted for delivery."));
+    $this->drupalPostForm("admin/config/development/reroute_email/test", $post, t("Send email"));
+    $this->assertText(t("Test email submitted for delivery from test form."));
     $mails = $this->drupalGetMails();
     $mail = end($mails);
     // Check rerouted email to.
@@ -59,7 +53,7 @@ class RerouteEmailTestEmailTestCase extends RerouteEmailTestCase {
     $this->assertFalse(strpos($mail['body'], $post['body']) === FALSE, 'Body contains the value submitted through the form');
 
     // Check required To field.
-    $this->drupalPost("admin/config/development/reroute_email/test", array('to' => ''), t("Send email"));
+    $this->drupalPostForm("admin/config/development/reroute_email/test", array('to' => ''), t("Send email"));
     $this->assertText(t("To field is required."));
 
     // Test form submission with email rerouting and invalid email addresses.
@@ -68,9 +62,9 @@ class RerouteEmailTestEmailTestCase extends RerouteEmailTestCase {
       'cc' => "Cc address invalid format",
       'bcc' => "Bcc address invalid format",
     );
-    $this->drupalPost("admin/config/development/reroute_email/test", $post, t("Send email"));
+    $this->drupalPostForm("admin/config/development/reroute_email/test", $post, t("Send email"));
     // Successful submission with email rerouting enabled.
-    $this->assertText(t("Test email submitted for delivery."));
+    $this->assertText(t("Test email submitted for delivery from test form."));
     $mails = $this->drupalGetMails();
     $mail = end($mails);
     // Check rerouted email to.
@@ -88,7 +82,7 @@ class RerouteEmailTestEmailTestCase extends RerouteEmailTestCase {
     $this->configureRerouteEmail(NULL, FALSE);
 
     // Submit the test email form again with previously used invalid addresses.
-    $this->drupalPost("admin/config/development/reroute_email/test", $post, t("Send email"));
+    $this->drupalPostForm("admin/config/development/reroute_email/test", $post, t("Send email"));
     // Check invalid email addresses are still passed to the mail system.
     $mails = $this->drupalGetMails();
     $mail = end($mails);
diff --git a/src/RerouteEmailSpecialTestCase.php b/src/Tests/UnusualMessageFieldsTest.php
similarity index 76%
rename from src/RerouteEmailSpecialTestCase.php
rename to src/Tests/UnusualMessageFieldsTest.php
index 0f6d7c5..68732f9 100644
--- a/src/RerouteEmailSpecialTestCase.php
+++ b/src/Tests/UnusualMessageFieldsTest.php
@@ -1,21 +1,18 @@
 <?php
-namespace Drupal\reroute_email;
+namespace Drupal\reroute_email\Tests;
+
+use Drupal\reroute_email\RerouteEmailTestBase;
 
 /**
- * Test handling of special cases for body as a string and Cc/Bcc robustness.
+ * Test handling of
+ * - message body passed as a string
+ * - Cc/Bcc header keys with an unexpected case.
+ *
+ * @group reroute_email
  */
-class RerouteEmailSpecialTestCase extends RerouteEmailTestCase {
+class UnusualMessageFieldsTest extends RerouteEmailTestBase {
 
-  /**
-   * Implements DrupalWebTestCase::getInfo().
-   */
-  public static function getInfo() {
-    return array(
-      'name' => 'Body as a string and robust headers',
-      'description' => "Support message's body passed as a string and Cc/Bcc header keys with an unexpected case.",
-      'group' => 'Reroute Email',
-    );
-  }
+  public static $modules = ['reroute_email', 'reroute_email_test', 'dblog'];
 
   /**
    * Enable modules and create user with specific permissions.
@@ -24,7 +21,7 @@ class RerouteEmailSpecialTestCase extends RerouteEmailTestCase {
     // Add more permissions to access recent log messages in test.
     $this->permissions[] = 'access site reports';
     // Include hidden test helper sub-module.
-    parent::setUp('reroute_email_test');
+    parent::setUp();
   }
 
   /**
@@ -57,12 +54,15 @@ class RerouteEmailSpecialTestCase extends RerouteEmailTestCase {
       ),
     );
     // Send test helper sub-module's email.
-    drupal_mail('reroute_email_test', 'test_reroute_email', $test_message['to'], language_default(), $test_message['params']);
+    $langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
+    \Drupal::getContainer()
+      ->get('plugin.manager.mail')
+      ->mail('reroute_email_test', 'test_reroute_email', $test_message['to'], $langcode, $test_message['params']);
     $this->verbose(t('Test email message values: <pre>@test_message</pre>', array('@test_message' => var_export($test_message, TRUE))));
 
     $mails = $this->drupalGetMails();
     $mail = end($mails);
-    // Check rerouted email to.
+// Check rerouted email to.
     $this->assertMail('to', $this->rerouteDestination, format_string('To email address was rerouted to @address.', array('@address' => $this->rerouteDestination)));
 
     // Check if original destination email address is in rerouted email body.
@@ -76,7 +76,13 @@ class RerouteEmailSpecialTestCase extends RerouteEmailTestCase {
     $this->assertRaw(t('A String was detected in the body'), 'Recorded in recent log messages: a String was detected in the body.');
 
     // Test the robustness of the CC and BCC keys in headers.
-    $this->assertTrue($mail['headers']['X-Rerouted-Original-Cc'] == $test_message['params']['headers'][$test_cc_key], format_string('X-Rerouted-Original-Cc is correctly set to @test_cc_address, although Cc header message key provided was: @test_cc_key', array('@test_cc_address' => $test_message['params']['headers'][$test_cc_key], '@test_cc_key' => $test_cc_key)));
-    $this->assertTrue($mail['headers']['X-Rerouted-Original-Bcc'] == $test_message['params']['headers'][$test_bcc_key], format_string('X-Rerouted-Original-Bcc is correctly set to @test_bcc_address, although Bcc header message key provided was: @test_bcc_key', array('@test_bcc_address' => $test_message['params']['headers'][$test_bcc_key], '@test_bcc_key' => $test_bcc_key)));
+    $this->assertTrue($mail['headers']['X-Rerouted-Original-Cc'] == $test_message['params']['headers'][$test_cc_key], format_string('X-Rerouted-Original-Cc is correctly set to @test_cc_address, although Cc header message key provided was: @test_cc_key', array(
+      '@test_cc_address' => $test_message['params']['headers'][$test_cc_key],
+      '@test_cc_key' => $test_cc_key
+    )));
+    $this->assertTrue($mail['headers']['X-Rerouted-Original-Bcc'] == $test_message['params']['headers'][$test_bcc_key], format_string('X-Rerouted-Original-Bcc is correctly set to @test_bcc_address, although Bcc header message key provided was: @test_bcc_key', array(
+      '@test_bcc_address' => $test_message['params']['headers'][$test_bcc_key],
+      '@test_bcc_key' => $test_bcc_key
+    )));
   }
 }
diff --git a/test_modules/reroute_email_test.info.yml b/test_modules/reroute_email_test.info.yml
new file mode 100644
index 0000000..a9f8c32
--- /dev/null
+++ b/test_modules/reroute_email_test.info.yml
@@ -0,0 +1,7 @@
+name: 'Reroute Email Test'
+description: 'Helper module for the reroute email tests.'
+core: 8.x
+package: Testing
+hidden: true
+project: reroute_email
+type: module
diff --git a/tests/reroute_email_test.module b/test_modules/reroute_email_test.module
similarity index 94%
rename from tests/reroute_email_test.module
rename to test_modules/reroute_email_test.module
index 8402067..733b1b9 100644
--- a/tests/reroute_email_test.module
+++ b/test_modules/reroute_email_test.module
@@ -63,7 +63,7 @@ function reroute_email_test_mail_alter(&$message) {
   // message has already been processed by reroute_email.
   if (is_string($message['body']) && isset($message['headers']['X-Rerouted-Mail-Key'])) {
     // Record to be checked in test in the log entries.
-    watchdog('reroute_email_test', 'A String was detected in the body: <pre>!body</pre>', array('!body' => $message['body']), WATCHDOG_NOTICE);
+    \Drupal::logger('reroute_email_test')->notice('A String was detected in the body: <pre>@body</pre>', array('@body' => $message['body']));
     // Convert body to an Array.
     $message['body'] = array($message['body']);
   }
diff --git a/tests/reroute_email_test.info b/tests/reroute_email_test.info
deleted file mode 100644
index 552d5cc..0000000
--- a/tests/reroute_email_test.info
+++ /dev/null
@@ -1,12 +0,0 @@
-name = "Reroute Email Test"
-description = "Helper module for the reroute email tests."
-core = 7.x
-package = Testing
-hidden = TRUE
-
-; Information added by Drupal.org packaging script on 2014-11-01
-version = "7.x-1.2"
-core = "7.x"
-project = "reroute_email"
-datestamp = "1414831432"
-
diff --git a/upgrade-info.html b/upgrade-info.html
deleted file mode 100644
index dc0eb8e..0000000
--- a/upgrade-info.html
+++ /dev/null
@@ -1,345 +0,0 @@
-<!DOCTYPE html>
-<html>
-  <head>
-    <link href='http://fonts.googleapis.com/css?family=Open+Sans:600italic,400,700,600' rel='stylesheet' type='text/css' />
-    <style type="text/css">
-    <!--
-
-body {
-  width: 80%;
-  color: #343434;
-  margin: 1em auto;
-  font-family: 'Open Sans', Verdana, sans-serif;
-}
-
-details {
-  font-size: 18px;
-  line-height: 25px;
-  margin-bottom: 2em;
-  display: block;
-}
-
-details summary {
-  padding: 1em;
-  margin-bottom: 1em;
-  display: block;
-}
-
-details.error summary {
-  background-color: #ffd5d5;
-}
-
-details.warning summary {
-  background-color: #fff3bb;
-}
-
-a {
-  color: #095cb1;
-  font-weight: bold;
-  text-decoration: none;
-}
-
-h5 {
-  font-size: 1em;
-}
-
-aside {
-  font-style: italic;
-  line-height: 20px;
-  font-size: 15px;
-}
-
-.group {
-  border: 1px solid #ececec;
-  padding: 1em;
-  display: block;
-}
-
-.group > summary {
-  padding: 0;
-  color: #c8c8c8;
-  margin-bottom: 0;;
-  font-weight: bold;
-  letter-spacing: .1em;
-  text-transform: uppercase;
-  display: block;
-}
-
-.group[open] > summary {
-  margin-bottom: 1em;
-}
-
-.group > details:last-child {
-  margin-bottom: 0;
-}
-
-    -->
-    </style>
-  </head>
-  <body>
-      <details open="true" class="group">
-      <summary>Configuration</summary>
-          <details class="error">
-      <summary><code>variable_del()</code> has been removed.</summary>
-
-      
-            <h5>Documentation</h5>
-      <ul>
-                <li><a target="_blank" href="https://www.drupal.org/node/2183531">The Variable API has been removed</a></li>
-              </ul>
-      
-            <h5>Files Affected</h5>
-      <ul>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.install, line 12</li>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.install, line 13</li>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.install, line 14</li>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.test, line 456</li>
-            </ul>
-                  <aside>Flagged by _function_call:variable_del</aside>    </details>
-    <details class="error">
-      <summary><code>variable_get()</code> has been removed.</summary>
-
-      
-            <h5>Documentation</h5>
-      <ul>
-                <li><a target="_blank" href="https://www.drupal.org/node/2183531">The Variable API has been removed</a></li>
-              </ul>
-      
-            <h5>Files Affected</h5>
-      <ul>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.admin.inc, line 15</li>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.admin.inc, line 21</li>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.admin.inc, line 21</li>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.admin.inc, line 30</li>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.module, line 86</li>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.module, line 128</li>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.module, line 128</li>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.module, line 135</li>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.module, line 156</li>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.test, line 432</li>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.test, line 444</li>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.test, line 479</li>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.variable.inc, line 24</li>
-            </ul>
-                  <aside>Flagged by _function_call:variable_get</aside>    </details>
-    <details class="error">
-      <summary><code>variable_set()</code> has been removed.</summary>
-
-      
-            <h5>Documentation</h5>
-      <ul>
-                <li><a target="_blank" href="https://www.drupal.org/node/2183531">The Variable API has been removed</a></li>
-              </ul>
-      
-            <h5>Files Affected</h5>
-      <ul>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.test, line 436</li>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.test, line 482</li>
-            </ul>
-                  <aside>Flagged by _function_call:variable_set</aside>    </details>
-    <details class="warning">
-      <summary>Default configuration is deleted automatically.</summary>
-
-      
-      
-            <h5>Files Affected</h5>
-      <ul>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.install, line 12</li>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.install, line 13</li>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.install, line 14</li>
-            </ul>
-                  <aside>Flagged by hook_uninstall</aside>    </details>
-
-    </details>
-      <details open="true" class="group">
-      <summary>Form API</summary>
-          <details class="error">
-      <summary><code>form_set_error()</code> is now a method of <code>FormStateInterface</code>.</summary>
-
-      
-            <h5>Documentation</h5>
-      <ul>
-                <li><a target="_blank" href="https://www.drupal.org/node/2121003">Form functions moved into <code>FormStateInterface</code></a></li>
-              </ul>
-      
-            <h5>Files Affected</h5>
-      <ul>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.admin.inc, line 49</li>
-            </ul>
-                  <aside>Flagged by _function_call:form_set_error</aside>    </details>
-
-    </details>
-      <details open="true" class="group">
-      <summary>Info File</summary>
-          <details class="error">
-      <summary>Module info files' <code>core</code> key must have a value of <code>8.x</code>.</summary>
-
-      
-            <h5>Documentation</h5>
-      <ul>
-                <li><a target="_blank" href="https://www.drupal.org/node/1935708"><code>.info</code> files are now <code>.info.yml</code> files</a></li>
-              </ul>
-      
-            <h5>Files Affected</h5>
-      <ul>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email/reroute_email.info</li>
-            </ul>
-                  <aside>Flagged by info</aside>    </details>
-    <details class="error">
-      <summary>Info files must contain a <code>type</code> key.</summary>
-
-      
-            <h5>Documentation</h5>
-      <ul>
-                <li><a target="_blank" href="https://www.drupal.org/node/1935708#type"><code>.info</code> files are now <code>.info.yml</code> files</a></li>
-              </ul>
-      
-            <h5>Files Affected</h5>
-      <ul>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email/reroute_email.info</li>
-            </ul>
-                  <aside>Flagged by info</aside>    </details>
-    <details class="error">
-      <summary>Modules no longer declare classes in their info file.</summary>
-
-      
-            <h5>Documentation</h5>
-      <ul>
-                <li><a target="_blank" href="https://www.drupal.org/node/1935708#files"><code>.info</code> files are now <code>.info.yml</code> files</a></li>
-              </ul>
-      
-            <h5>Files Affected</h5>
-      <ul>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email/reroute_email.info</li>
-            </ul>
-                  <aside>Flagged by info</aside>    </details>
-    <details class="error">
-      <summary>Module info files' <code>configure</code> key must be a route name, not a path.</summary>
-
-      
-            <h5>Documentation</h5>
-      <ul>
-                <li><a target="_blank" href="https://www.drupal.org/node/1935708#configure"><code>.info</code> files are now <code>.info.yml</code> files</a></li>
-              </ul>
-      
-            <h5>Files Affected</h5>
-      <ul>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email/reroute_email.info</li>
-            </ul>
-                  <aside>Flagged by info</aside>    </details>
-
-    </details>
-      <details open="true" class="group">
-      <summary>Menu/Routing</summary>
-          <details class="error">
-      <summary><code>hook_menu()</code> has been removed from Drupal 8.</summary>
-
-      
-            <h5>Documentation</h5>
-      <ul>
-                <li><a target="_blank" href="https://www.drupal.org/node/1800686">All functionality of <code>hook_menu()</code> replaced</a></li>
-                <li><a target="_blank" href="https://www.drupal.org/node/2177901">Dynamic routes are now defined in <code>MODULE.routing.yml</code></a></li>
-                <li><a target="_blank" href="https://www.drupal.org/node/2119699">Page callbacks have been converted to controller classes</a></li>
-                <li><a target="_blank" href="https://www.drupal.org/node/2089605">Route naming convention</a></li>
-                <li><a target="_blank" href="https://www.drupal.org/node/2165243">Contextual links are now plugins defined in <code>MODULE.links.contextual.yml</code></a></li>
-                <li><a target="_blank" href="https://www.drupal.org/node/2007444">Local actions are now plugins defined in <code>MODULE.links.action.yml</code></a></li>
-                <li><a target="_blank" href="https://www.drupal.org/node/2044515">Local tasks and now plugins defined in <code>MODULE.links.task.yml</code></a></li>
-                <li><a target="_blank" href="https://www.drupal.org/node/2228089">Menu links are now defined in <code>MODULE.links.menu.yml</code></a></li>
-              </ul>
-      
-            <h5>Files Affected</h5>
-      <ul>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.module, line 46</li>
-            </ul>
-                  <aside>Flagged by _flag_hook:menu</aside>    </details>
-
-    </details>
-      <details open="true" class="group">
-      <summary>Miscellaneous</summary>
-          <details class="warning">
-      <summary>Many common functions, shared variables, and constants have been renamed.</summary>
-
-      
-            <h5>Documentation</h5>
-      <ul>
-                <li><a target="_blank" href="https://www.drupal.org/node/2324935">The global theme variables have been replaced by an ActiveTheme object</a></li>
-              </ul>
-      
-                      </details>
-    <details class="error">
-      <summary>Classes must be PSR-4 compliant.</summary>
-
-      
-            <h5>Documentation</h5>
-      <ul>
-                <li><a target="_blank" href="https://www.drupal.org/node/2246699">PSR-4 compatible class loader in Drupal core</a></li>
-              </ul>
-      
-                      </details>
-    <details class="error">
-      <summary>Automated web tests must be in a PSR-4 namespace, and unit tests must be converted to PHPUnit.</summary>
-
-      
-            <h5>Documentation</h5>
-      <ul>
-                <li><a target="_blank" href="https://www.drupal.org/node/1543796">Namespacing of automated tests has changed</a></li>
-                <li><a target="_blank" href="https://www.drupal.org/node/2301125"><code>getInfo()</code> in test classes replaced by doc comments</a></li>
-                <li><a target="_blank" href="https://www.drupal.org/node/1710766">Test classes should define a <code>$modules</code> property declaring dependencies</a></li>
-                <li><a target="_blank" href="https://www.drupal.org/node/1911318">SimpleTest tests now use empty &quot;testing&quot; profile by default</a></li>
-                <li><a target="_blank" href="https://www.drupal.org/node/1829160">New <code>KernelTestBase</code> class for API-level integration tests</a></li>
-                <li><a target="_blank" href="https://www.drupal.org/node/2012184">PHPUnit added to Drupal core</a></li>
-              </ul>
-      
-                      </details>
-
-    </details>
-      <details open="true" class="group">
-      <summary>System</summary>
-          <details class="error">
-      <summary><code>url()</code> has been removed.</summary>
-
-      
-            <h5>Documentation</h5>
-      <ul>
-                <li><a target="_blank" href="https://www.drupal.org/node/2346779"><code>url()</code> replaced by URL generation API</a></li>
-              </ul>
-      
-            <h5>Files Affected</h5>
-      <ul>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.admin.inc, line 22</li>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.module, line 164</li>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.test, line 490</li>
-            </ul>
-                  <aside>Flagged by _function_call:url</aside>    </details>
-    <details class="error">
-      <summary><code>watchdog()</code> has been removed.</summary>
-
-      
-            <h5>Documentation</h5>
-      <ul>
-                <li><a target="_blank" href="https://www.drupal.org/node/2270941"><code>watchdog()</code> is deprecated</a></li>
-              </ul>
-      
-            <h5>Files Affected</h5>
-      <ul>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.module, line 159</li>
-            </ul>
-                  <aside>Flagged by _function_call:watchdog</aside>    </details>
-    <details class="warning">
-      <summary>Static permissions are now defined in <code>MODULE.permissions.yml</code>.</summary>
-
-      
-            <h5>Documentation</h5>
-      <ul>
-                <li><a target="_blank" href="https://www.drupal.org/node/2311427">Defining permissions in <code>MODULE.permissions.yml</code></a></li>
-              </ul>
-      
-            <h5>Files Affected</h5>
-      <ul>
-              <li>C:\xampp\htdocs\drupal8demo/modules/reroute_email\reroute_email.module, line 34</li>
-            </ul>
-            <p class="fixable">This issue can be fixed automatically.</p>      <aside>Flagged by hook_permission</aside>    </details>
-
-    </details>
-    </body>
-</html>
