コード例 #1
0
def send_user_link_to_whole_sequence(sequence):
    all_signups = signup_api.get_signups(sequence)
    context = {
        'mooc_title': settings.MOOC_TITLE,
        'mooc_domain': settings.MOOC_DOMAIN,
        'sequence': sequence
    }

    subject = render_to_string('classphoto/emails/sequence_links-subject.txt',
                               context).strip()
    text_body = render_to_string('classphoto/emails/sequence_links.txt',
                                 context).strip()
    html_body = render_to_string('classphoto/emails/sequence_links.html',
                                 context).strip()

    for i in range(0, len(all_signups), 1000):
        signups = all_signups[i:i + 1000]
        emails = [signup['email'] for signup in signups]
        recipient_variables = {
            signup['email']: {
                'key': signup['key']
            }
            for signup in signups
        }

        mailgun.api.send_mass_email(
            emails,
            settings.DEFAULT_FROM_EMAIL,
            subject,
            text_body,
            html_body,
            tags=['classphotolink'],
            campaign_id=sequence_api.sequence_campaign(sequence),
            recipient_variables=json.dumps(recipient_variables))
コード例 #2
0
def send_group_photos(sequence):

    context = {
        'mooc_title': settings.MOOC_TITLE,
        'mooc_domain': settings.MOOC_DOMAIN,
        'sequence': sequence,
    }

    urls = group_photo.make_group_photos(sequence)

    for group_uri, image_url in urls.items():
        group = group_api.get_group(group_uri)
        context['image_url'] = image_url
        subject = render_to_string(
            'classphoto/emails/sequence_group_photo-subject.txt',
            context).strip()
        text_body = render_to_string(
            'classphoto/emails/sequence_group_photo.txt', context).strip()
        html_body = render_to_string(
            'classphoto/emails/sequence_group_photo.html', context).strip()

        mailgun.api.send_email(
            group['address'],
            settings.DEFAULT_FROM_EMAIL,
            subject,
            text_body,
            html_body,
            tags=['group_photo'],
            campaign_id=sequence_api.sequence_campaign(sequence))
コード例 #3
0
ファイル: emails.py プロジェクト: MHM5000/mechanical-mooc
def send_group_photos(sequence):

    context = {
        'mooc_title': settings.MOOC_TITLE,
        'mooc_domain': settings.MOOC_DOMAIN,
        'sequence': sequence,
    }

    urls = group_photo.make_group_photos(sequence)

    for group_uri, image_url in urls.items():
        group = group_api.get_group(group_uri)
        context['image_url'] = image_url
        subject = render_to_string(
            'classphoto/emails/sequence_group_photo-subject.txt', context
        ).strip()
        text_body = render_to_string(
            'classphoto/emails/sequence_group_photo.txt', context
        ).strip()
        html_body = render_to_string(
            'classphoto/emails/sequence_group_photo.html', context
        ).strip()

        mailgun.api.send_email(
            group['address'],
            settings.DEFAULT_FROM_EMAIL,
            subject,
            text_body,
            html_body,
            tags=['group_photo'],
            campaign_id=sequence_api.sequence_campaign(sequence)
        )
コード例 #4
0
ファイル: emails.py プロジェクト: MHM5000/mechanical-mooc
def send_user_link_to_whole_sequence( sequence ):
    all_signups = signup_api.get_signups(sequence)
    context = {
        'mooc_title': settings.MOOC_TITLE,
        'mooc_domain': settings.MOOC_DOMAIN,
        'sequence': sequence
    }

    subject = render_to_string('classphoto/emails/sequence_links-subject.txt', context).strip()
    text_body = render_to_string('classphoto/emails/sequence_links.txt', context).strip()
    html_body = render_to_string('classphoto/emails/sequence_links.html', context).strip()

    for i in range(0, len(all_signups), 1000):
        signups = all_signups[i:i+1000]
        emails = [ signup['email'] for signup in signups ]
        recipient_variables = {
            signup['email']: {'key': signup['key']} for signup in signups
        }

        mailgun.api.send_mass_email(
            emails,
            settings.DEFAULT_FROM_EMAIL,
            subject,
            text_body,
            html_body,
            tags=['classphotolink'],
            campaign_id=sequence_api.sequence_campaign(sequence),
            recipient_variables=json.dumps(recipient_variables)
        )
コード例 #5
0
ファイル: email.py プロジェクト: MHM5000/mechanical-mooc
def send_email( email_uri ):
    """ Send the email to the intended target audience """
    email = mail_api.get_email(email_uri)

    if email['audience'] == 'groups':
        to_addresses = [g['address'] for g in group_api.get_groups(email['sequence'])]
    elif email['audience'] == 'individuals':
        to_addresses = [sequence_api.sequence_list_name(email['sequence'])]

    text_body = render_to_string('mail/email.txt', {'email': email})
    html_body = render_to_string('mail/email.html', {'email': email})

    batch_size = 1000

    for i in range(0, len(to_addresses), batch_size):
        mailgun_api.send_mass_email(
            to_addresses[i:i+batch_size],
            settings.DEFAULT_FROM_EMAIL,
            email['subject'],
            text_body,
            html_body,
            email['tags'].split(','),
            sequence_api.sequence_campaign(email['sequence'])
        )
    mail_api.mark_sent(email_uri)
コード例 #6
0
def send_email(email_uri):
    """ Send the email to the intended target audience """
    email = mail_api.get_email(email_uri)

    if email['audience'] == 'groups':
        to_address = ','.join(
            [g['address'] for g in group_api.get_groups(email['sequence'])])
    elif email['audience'] == 'individuals':
        to_address = sequence_api.sequence_list_name(email['sequence'])

    text_body = render_to_string('mail/email.txt', {'email': email})
    html_body = render_to_string('mail/email.html', {'email': email})

    mailgun_api.send_email(to_address, settings.DEFAULT_FROM_EMAIL,
                           email['subject'], text_body, html_body,
                           email['tags'].split(','),
                           sequence_api.sequence_campaign(email['sequence']))
    mail_api.mark_sent(email_uri)
コード例 #7
0
ファイル: email.py プロジェクト: Afey/mechanical-mooc
def send_email( email_uri ):
    """ Send the email to the intended target audience """
    email = mail_api.get_email(email_uri)

    if email['audience'] == 'groups':
        to_address = ','.join([g['address'] for g in group_api.get_groups(email['sequence'])])
    elif email['audience'] == 'individuals':
        to_address = sequence_api.sequence_list_name(email['sequence'])

    text_body = render_to_string('mail/email.txt', {'email': email})
    html_body = render_to_string('mail/email.html', {'email': email})

    mailgun_api.send_email(
        to_address,
        settings.DEFAULT_FROM_EMAIL,
        email['subject'],
        text_body,
        html_body,
        email['tags'].split(','),
        sequence_api.sequence_campaign(email['sequence'])
    )
    mail_api.mark_sent(email_uri)