Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(5)  |  Call(4)  |  Derive(0)  |  Import(1)
Sends a message to the admins, as defined by the ADMINS setting.

        def mail_admins(subject, message, fail_silently=False, connection=None,
                html_message=None):
    """Sends a message to the admins, as defined by the ADMINS setting."""
    if not app.config.get('ADMINS', None):
        return
    mail = EmailMultiAlternatives(u'%s%s' % (app.config.get('EMAIL_SUBJECT_PREFIX', '[Flask] '), subject),
                message, app.config.get('SERVER_EMAIL', 'root@localhost'), [a[1] for a in app.config['ADMINS']],
                connection=connection)
    if html_message:
        mail.attach_alternative(html_message, 'text/html')
    mail.send(fail_silently=fail_silently)
        


src/f/l/Flask-Email-1.4.4/tests/__init__.py   Flask-Email(Download)
from flask.ext.email.backends.dummy import Mail as DummyMail
from flask.ext.email.message import EmailMessage
from flask.ext.email import get_connection, send_mail, send_mass_mail, mail_managers, mail_admins
 
import unittest
 
        connection = get_connection('tests.CustomMail')
        mail_admins('Admin message', 'Content', connection=connection)
        self.assertEqual(mail.outbox, [])
        self.assertEqual(len(connection.test_outbox), 1)
    def test_html_mail_admins(self):
        """Test html_message argument to mail_admins """
        mail_admins('Subject', 'Content', html_message='HTML Content')
        message = self.get_the_message()
 
 
        self.flush_mailbox()
        mail_admins('Subject', 'Content')
        message = self.get_the_message()
        self.assertEqual(message.get('subject'), '[Flask] Subject')
        if there are no recipients (#9383)
        """
        mail_admins('hi', 'there')
        self.assertEqual(self.get_mailbox_content(), [])
        mail_managers('hi', 'there')