def queue_email(to_addresses, from_address, subject, body, commit=True, html=True, session=None):
from models import QueuedEmail<EOL>if session is None:<EOL><INDENT>session = _db.session<EOL><DEDENT>log.info('<STR_LIT>' % (to_addresses, subject))<EOL>queued_email = QueuedEmail(html, to_addresses, from_address, subject, body, STATUS_QUEUED)<EOL>session.add(queued_email)<EOL>session.commit()<EOL>return queued_email<EOL>
Add a mail to the queue to be sent.

WARNING: Commits by default!

:param to_addresses: The names and addresses to send the email to, i.e. "Steve<steve@fig14.com>, info@fig14.com"
:param from_address: Who the email is from i.e. "Stephen Brown <s@fig14.com>"
:param subject: The email subject
:param body: The html / text body of the email
:param commit: Whether to commit to the database
:param html: Is this a html email?
:param session: The sqlalchemy session or None to use db.session