code: def send_email_message(self, recipient, subject, html_message, text_message, sender_email, sender_name):
          
  
          # Construct sender from sender_name and sender_email
          sender = '"%s" <%s>' % (sender_name, sender_email) if sender_name else sender_email
  
          # Send email via SMTP except when we're testing
          if not current_app.testing:  # pragma: no cover
              try:
                  # Prepare email message
                  from flask_mail import Message
                  message = Message(
                      subject,
                      sender=sender,
                      recipients=[recipient],
                      html=html_message,
                      body=text_message)
  
                  # Send email message
                  self.mail.send(message)
  
              # Print helpful error messages on exceptions
              except (socket.gaierror, socket.error) as e:
                  raise EmailError('SMTP Connection error: Check your MAIL_SERVER and MAIL_PORT settings.')
              except smtplib.SMTPAuthenticationError:
                  raise EmailError('SMTP Authentication error: Check your MAIL_USERNAME and MAIL_PASSWORD settings.')
docs: Send email message via Flask-Mail.
  
          Args:
              recipient: Email address or tuple of (Name, Email-address).
              subject: Subject line.
              html_message: The message body in HTML.
              text_message: The message body in plain text.