Example #1
0
def enviar_email_prof(data, aluno, contato, nivel,materia,tipo, cidade, genero, nome):
    
    mail_content = "<br><b>Data</b>: " +data+"<br><b>Aluno</b>: " +aluno  +"<br><b>contato</b>: " +contato  +"<br><b>Nivel</b>: " +nivel +"<br><b>Materia</b>: " +materia + "<br><b>Tipo:</b> " +tipo+ "<br><b>Cidade:</b> " +cidade + "<br><b>Genero:</b> " + genero + "<br><b>Nome:</b> " +nome
    
    #The mail addresses and password
    sender_address = '*****@*****.**'
    sender_pass = '******'
    receiver_address = '*****@*****.**'
    #Setup the MIME
    message = MIMEMultipart()
    message.IsBodyHtml = True
    message['From'] = sender_address
    message['To'] = receiver_address
    message['Subject'] = data + " | "+ aluno+" | "+contato+" | "+ nivel+" | "+ materia+" | "+ tipo+" | "+ cidade+" | "+ genero+" | "+ nome   #The subject line
    #The body and the attachments for the mail
    #message.Body = mail_content
    message.attach(MIMEText(mail_content, 'html'))
    #message.attach(MIMEText(mail_content, 'plain'))
    #Create SMTP session for sending the mail
    session = smtplib.SMTP('smtp.gmail.com', 587) #use gmail with port
    session.starttls() #enable security
    session.login(sender_address, sender_pass) #login with mail_id and password
    text = message.as_string()
    session.sendmail(sender_address, receiver_address, text)
    session.quit()
Example #2
0
def enviar_email_site(data):
    
    mail_content = "<br><b>Data</b>: " +data
    #The mail addresses and password
    sender_address = '*****@*****.**'
    sender_pass = '******'
    receiver_address = '*****@*****.**'
    #Setup the MIME
    message = MIMEMultipart()
    message.IsBodyHtml = True
    message['From'] = sender_address
    message['To'] = receiver_address
    message['Subject'] = "NOVO ACESSO " + " | " + data
    #message.Body = mail_content
    message.attach(MIMEText(mail_content, 'html'))
    #message.attach(MIMEText(mail_content, 'plain'))
    #Create SMTP session for sending the mail
    session = smtplib.SMTP('smtp.gmail.com', 587) #use gmail with port
    session.starttls() #enable security
    session.login(sender_address, sender_pass) #login with mail_id and password
    text = message.as_string()
    session.sendmail(sender_address, receiver_address, text)
    session.quit()