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.

envelopes.connstack.get_current_connection()

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

envelopes.connstack.pop_connection()

Pops the topmost connection from the stack.

envelopes.connstack.push_connection(connection)

Pushes the given connection on the stack.

envelopes.connstack.resolve_connection(connection=None)

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

envelopes.connstack.use_connection(connection)

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