Make attachment system with my python email sender

Asked

Viewed 208 times

0

So, I’m developing a mass mailing, Only I’m not getting to use attachment in this shipment.

The Code is found like this:

  #!/usr/bin/python3

import smtplib
import os as sistema
import getpass


sistema.system('cls' if sistema.name == 'nt' else 'clear')

def banner():
    ban = '''
   BUNITO
    '''
    print(ban)

banner()
# é nois Állan tamo progamando muitooo
# assinado Vinicius
# melhor TCC!!!
#S2
try:
    print('====' * 10)
    meu_email = input('[*]Seu Gmail: ')
    print('====' * 10)
    min_senha = getpass.getpass('[*]Sua senha: ')
    print('====' * 10)
    #destinatario = input('[*]Email PARA ENVIAR ')
    #print('====' * 10)
    assunto = input('[*]Assunto: ')
    print('====' * 10)
    menssagem = input('[*]Menssagem: ')
    print('====' * 10)
    quantidade = int(input('[*]Quantidade de pessoas que vao receber os emails: '))
    print('====' * 10)

    i = 0

    #O naruto pode ser duro as vezes...
    #-----------------------------------------
    arquivo = open('emails.txt','r')
    emails = arquivo.read()
    emails = emails.split()
    #-----------------------------------------
    while (i < quantidade):

        msg_header = 'Content-type: text/html\n' \
                     'Subject: {}\n'.format(assunto)
        msg_content = '<h2> <font color="black"> {menssagem} </font></h2>\n'.format(menssagem=menssagem)
        msg_full = (''.join([msg_header, msg_content])).encode()
#        print(':0')
        server = smtplib.SMTP('smtp.gmail.com:587')
        server.starttls()
        server.login(meu_email, min_senha)
        print('login')
        server.sendmail(meu_email,
                        [emails[i], emails[i]],
                        msg_full)
#        print(':)')

        print('[{}]Enviando para : {}'.format(i,emails[i]))
        i +=1
        server.quit()
except:
    erro = '''

    '''
    print(erro)

I would like to be able to make a system that can send an attachment at the same time.

1 answer

0


Browser other questions tagged

You are not signed in. Login or sign up in order to post.