示例#1
0
def test_html_mail():
    mail = mails.Mail('test', subject='A test email')
    rendered = mail.html(name='World')
    assert_equal(rendered.strip(), 'Hello <p>World</p>')
示例#2
0
from framework.email.tasks import send_email

from website import mails
from website import models
from website import settings
from website.app import init_app

from scripts import utils as script_utils

logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)

FROM_ADDR = 'OSF Support <*****@*****.**>'
MESSAGE_NAME = 'permissions_change'
SECURITY_MESSAGE = mails.Mail(
    'security_permissions_change',
    subject='OSF Privacy Notice',
)


def send_security_message(user, label, mail):
    if label in user.security_messages:
        return
    # Pass mailer so that celery is not used
    # Email synchronously so that user is only saved after email has been sent
    mails.send_mail(
        user.username,
        mail,
        from_addr=FROM_ADDR,
        mailer=send_email,
        user=user,
        username=settings.MANDRILL_USERNAME,
示例#3
0
def test_plain_mail():
    mail = mails.Mail('test', subject='A test email to ${name}')
    rendered = mail.text(name='World')
    assert_equal(rendered.strip(), 'Hello World')
    assert_equal(mail.subject(name='World'), 'A test email to World')