old_contents: """
  byceps.email
  ~~~~~~~~~~~~
  
  Sending e-mail.
  
  :Copyright: 2014-2022 Jochen Kupperschmidt
  :License: Revised BSD (see `LICENSE` file for details)
  """
  
  from __future__ import annotations
  from typing import Any, Optional
  
  from flask import current_app, Flask
  # Hack to avoid import error in `marrow.util` on Python 3.8+.
  import sys
  sys.modules['cgi.parse_qsl'] = None
  from marrow.mailer import Mailer
  
  
  def init_app(app: Flask) -> None:
      config = _get_config(app)
      app.marrowmailer = Mailer(config)
  
  
  def _get_config(app: Flask) -> dict[str, Any]:
      if app.config.get('MAIL_SUPPRESS_SEND', False):
          return {
              'transport.use': 'mock',
          }
  
      config = {
          'transport.use': app.config.get('MAIL_TRANSPORT', 'smtp'),
          'transport.host': app.config.get('MAIL_SERVER', 'localhost'),
          'transport.port': app.config.get('MAIL_PORT', 25),
          'transport.debug': app.config.get('MAIL_DEBUG', app.debug),
          'message.author': app.config['MAIL_DEFAULT_SENDER'],
      }
  
      username = app.config.get('MAIL_USERNAME', None)
      if username is not None:
          config['transport.username'] = username
  
      password = app.config.get('MAIL_PASSWORD', None)
      if password is not None:
          config['transport.password'] = password
  
      if app.config.get('MAIL_USE_SSL', False):
          config['transport.tls'] = 'ssl'
  
      if app.config.get('MAIL_USE_TLS', False):
          config['transport.tls'] = 'required'
  
      return config
  
  
  def send(
      sender: Optional[str], recipients: list[str], subject: str, body: str
  ) -> None:
      """Assemble and send an e-mail."""
      mailer = current_app.marrowmailer
  
      message = mailer.new(
          author=sender, to=recipients, subject=subject, plain=body, brand=False
      )
  
      mailer.start()
      mailer.send(message)
      mailer.stop()
  
new_contents: """
  byceps.email
  ~~~~~~~~~~~~
  
  Sending e-mail.
  
  :Copyright: 2014-2022 Jochen Kupperschmidt
  :License: Revised BSD (see `LICENSE` file for details)
  """
  
  from __future__ import annotations
  from typing import Any, Optional
  
  from flask import current_app, Flask
  # Hack to avoid import error in `marrow.util` on Python 3.8+.
  import sys
  sys.modules['cgi.parse_qsl'] = None
  from marrow.mailer import Mailer
  
  
  def init_app(app: Flask) -> None:
      config = _get_config(app)
      app.marrowmailer = Mailer(config)
  
  
  def _get_config(app: Flask) -> dict[str, Any]:
      config = {
          'transport.use': app.config.get('MAIL_TRANSPORT', 'smtp'),
          'transport.host': app.config.get('MAIL_SERVER', 'localhost'),
          'transport.port': app.config.get('MAIL_PORT', 25),
          'transport.debug': app.config.get('MAIL_DEBUG', app.debug),
          'message.author': app.config['MAIL_DEFAULT_SENDER'],
      }
  
      username = app.config.get('MAIL_USERNAME', None)
      if username is not None:
          config['transport.username'] = username
  
      password = app.config.get('MAIL_PASSWORD', None)
      if password is not None:
          config['transport.password'] = password
  
      if app.config.get('MAIL_USE_SSL', False):
          config['transport.tls'] = 'ssl'
  
      if app.config.get('MAIL_USE_TLS', False):
          config['transport.tls'] = 'required'
  
      return config
  
  
  def send(
      sender: Optional[str], recipients: list[str], subject: str, body: str
  ) -> None:
      """Assemble and send an e-mail."""
      if current_app.config.get('MAIL_SUPPRESS_SEND', False):
          current_app.logger.debug('Suppressing sending of email.')
          return
  
      mailer = current_app.marrowmailer
  
      message = mailer.new(
          author=sender, to=recipients, subject=subject, plain=body, brand=False
      )
  
      current_app.logger.debug('Sending email.')
      mailer.start()
      mailer.send(message)
      mailer.stop()
  
subject: Move email send suppression to `byceps.email.send`, skip instead of using mock transport, log decision