Connection stack

The connection stack allows you to use Envelopes’ SMTP connection wrapper in threaded apps. Consult the example Flask app to see it in action.

Code of this module has been adapted from RQ by Vincent Driessen.


Returns the current SMTP connection (i.e. the topmost on the connection stack).


Pops the topmost connection from the stack.


Pushes the given connection on the stack.


Convenience function to resolve the given or the current connection. Raises an exception if it cannot resolve a connection now.


Clears the stack and uses the given connection. Protects against mixed use of use_connection() and stacked connection contexts.

Previous topic

SMTP connection

This Page