title: RuntimeError (_app_ctx_err_msg): Working outside of application context while sending mail from thread
body: <p>I am trying to send email using flask-mail and here is the code snippet I have to used to send mail</p>
  
  <pre><code>def send_async_email(app, msg):
      with app.app_context():
          mail.send(msg)
  
  def send_email(subject, recipients, text_body=None, html_body=None):
      msg = Message(subject, recipients=recipients)
      msg.body = text_body
      msg.html = html_body
      thr = Thread(target=send_async_email, args=[current_app, msg])
      thr.start()
  </code></pre>
  
  <p>While running this code, I am getting the following error</p>
  
  <pre><code>Exception in thread Thread-9:
  Traceback (most recent call last):
    File "C:\Python37\lib\threading.py", line 917, in _bootstrap_inner
      self.run()
    File "C:\Python37\lib\threading.py", line 865, in run
      self._target(*self._args, **self._kwargs)
    File "..\flask_demo\flaskdemo\common_utils.py", line 7, in send_async_email
      with app.app_context():
    File "..\flask_demo\venv\lib\site-packages\werkzeug\local.py", line 348, in __getattr__
      return getattr(self._get_current_object(), name)
    File "..\flask_demo\venv\lib\site-packages\werkzeug\local.py", line 307, in _get_current_object
      return self.__local()
    File "..\flask_demo\venv\lib\site-packages\flask\globals.py", line 51, in _find_app
      raise RuntimeError(_app_ctx_err_msg)
  RuntimeError: Working outside of application context.
  
  This typically means that you attempted to use functionality that needed
  to interface with the current application object in some way. To solve
  this, set up an application context with app.app_context().  See the
  documentation for more information.
  </code></pre>