Пример #1
0
    if email_count % MAX_EMAIL_PER_BATCH > 0:
        total_batch_count += 1

    # Main Loop
    # while the name_email_dictionary has members
    while name_email_dictionary:
        for i in range(MAX_EMAIL_PER_BATCH):
            # if the dictionary still has members
            if name_email_dictionary:
                # pop an item and append it to the batch list
                email_batch_list.append(name_email_dictionary.popitem())
        # when the batch_list has reached 50 members, run the generate email method
        
        batch_success_data = Mailer.generateEmail(email_batch_list, current_batch, total_batch_count, html_text, plain_text, SMTP_TIME_OUT)
        current_batch += 1

        # update statistics
        for item in batch_success_data['valid_emails']:
            success_data['valid_emails'].append(item)
        for item in batch_success_data['invalid_emails']:
            success_data['invalid_emails'].append(item)
        for item in batch_success_data['send_errors']:
            success_data['send_errors'].append(item)
        success_data['send_count'] += batch_success_data['send_count']

        #reset batch list
        email_batch_list = []
        
    Logger.create_log_file(success_data)