예제 #1
0
def run():
    client = Vivo()
    client._get_ticket_info()
    availables = client._save_tickets()

    if len(availables) > 0:
        KEY = config('MANDRILL_KEY')
        template = env.get_template('mail.txt')
        html_template = env.get_template('mail.html')
        text = template.render(tickets=availables)
        html = html_template.render(tickets=availables)
        mandrill_client = mandrill.Mandrill(KEY)
        message = {
            'from_email':
            '*****@*****.**',
            'from_name':
            'Vivo Scrapper',
            'subject':
            'Tem evento novo!!!!',
            'html':
            html,
            'text':
            text,
            'to': [
                {
                    'email': '*****@*****.**',
                    'type': 'to',
                },
                {
                    'email': '*****@*****.**',
                    'type': 'bcc',
                },
                {
                    'email': '*****@*****.**',
                    'type': 'bcc',
                },
                {
                    'email': '*****@*****.**',
                    'type': 'bcc',
                },
                {
                    'email': '*****@*****.**',
                    'type': 'bcc',
                },
                {
                    'email': '*****@*****.**',
                    'type': 'bcc',
                },
                {
                    'email': '*****@*****.**',
                    'type': 'bcc',
                },
                {
                    'email': '*****@*****.**',
                    'type': 'bcc',
                },
                {
                    'email': '*****@*****.**',
                    'type': 'bcc',
                },
            ],
        }

        mandrill_client.messages.send(message=message)