code: def send_mail(subject, recipient, template, **context):
      
  
      context.setdefault('security', _security)
      context.update(_security._run_ctx_processor('mail'))
  
      sender = _security.email_sender
      if isinstance(sender, LocalProxy):
          sender = sender._get_current_object()
  
      msg = Message(subject,
                    sender=sender,
                    recipients=[recipient])
  
      ctx = ('security/email', template)
      if config_value('EMAIL_PLAINTEXT'):
          msg.body = _security.render_template('%s/%s.txt' % ctx, **context)
      if config_value('EMAIL_HTML'):
          msg.html = _security.render_template('%s/%s.html' % ctx, **context)
  
      if _security._send_mail_task:
          _security._send_mail_task(msg)
          return
  
      mail = current_app.extensions.get('mail')
      mail.send(msg)
docs: Send an email via the Flask-Mail extension.
  
      :param subject: Email subject
      :param recipient: Email recipient
      :param template: The name of the email template
      :param context: The context to render the template with