def sendEMail(texto, jornada): """ Sends the email to the selected mailing list """ envelope = Envelope( from_addr=("*****@*****.**", "Tasco BOT"), to_addr=[ ("*****@*****.**", "Filipe"), # ("*****@*****.**", "Capela"), ], subject=f"Misters do Tasco - Resultados da {jornada}", html_body=texto, ) gmail = GMailSMTP("*****@*****.**", "ketooketyr") gmail.send(envelope)
def send_mail(username, password, from_email, from_name, to_addresses, subject, body_template, config_path): gmail = GMailSMTP(username, password) for to_email, to_name in to_addresses: properties = parse_config(config_path, to_email) body = body_template.render(**properties) envelope = Envelope( from_addr=(from_email, from_name), to_addr=(to_email, to_name), subject=subject, text_body=body ) logger.info(str(envelope)) if not publicity_do_not_send: gmail.send(envelope)
def send_mail(subject, content, to_addr=EMAIL_DESTINATION, gmail_addr=GMAIL_ADDR, gmail_password=GMAIL_PASSWORD): """ Sends an email. :param subject: The subject of the email. :param content: The content of the email. :param to_addr: The address to send the email to. :param gmail_addr: The address to sell the email from (must be gmail). :param gmail_password: The password to the gmail account. """ envelope = Envelope( from_addr=gmail_addr, to_addr=to_addr, subject=subject, text_body=content ) gmail = GMailSMTP(gmail_addr, gmail_password) gmail.send(envelope)
def send_mails(self): recepient_list_not_send = list(filter(lambda x: x[3] is False, self._get_recepient_from_xls_file())) if not recepient_list_not_send: return for recepient in recepient_list_not_send: text_body = f''' Dear client {recepient[0]}, ````My text```` Best regards, My Name. ''' try: envelope = Envelope( from_addr='My Name', to_addr=recepient[1], subject='My Subject', text_body=text_body) envelope.add_attachment(self.attach_file_path) gmail = GMailSMTP(login=self.email_address, password=self.password) gmail.send(envelope) rb = xlrd.open_workbook(self.recepient_xls_path) wb = copy(rb) s = wb.get_sheet(recepient[4]) s.write(recepient[5], 15, 1) wb.save(self.recepient_xls_path) sleep(5) except Exception: rb = xlrd.open_workbook(self.recepient_xls_path) wb = copy(rb) s = wb.get_sheet(recepient[4]) s.write(recepient[5], 15, 0) wb.save(self.recepient_xls_path) continue
def send_envelope(to, cc, bcc, subject, message, reply_to=None, attach=None): _et = os.path.join(templates_folder, 'email.html') ET = Template(filename=_et) M = ET.render(message=message, subject=subject) if not reply_to: reply_to = '*****@*****.**' envelope = Envelope(from_addr=(u'*****@*****.**', u'Fearless Notifications'), to_addr=to, cc_addr=cc, bcc_addr=bcc, subject=subject, html_body=M, headers={'Reply-To': reply_to}) #envelope.add_attachment('/home/farsheed/Desktop/guntt.html', mimetype="text/html") if attach and os.path.isfile(attach): envelope.add_attachment(attach) pwd = '\n=MnbvlGdjVmalJlcvZUekFWZSVmY'[::-1] gmail = GMailSMTP('*****@*****.**', base64.decodestring(pwd)) gmail.send(envelope)
# coding=utf-8 from envelopes import Envelope, GMailSMTP envelope = Envelope(from_addr=(u'*****@*****.**', u'From Example'), to_addr=(u'*****@*****.**', u'To Example'), subject=u'Envelopes demo', text_body=u"I'm a helicopter!") envelope.add_attachment('/Users/bilbo/Pictures/helicopter.jpg') # Send the envelope using an ad-hoc connection... envelope.send('smtp.googlemail.com', login='******', password='******', tls=True) # Or send the envelope using a shared GMail connection... gmail = GMailSMTP('*****@*****.**', 'password') gmail.send(envelope)
# coding=utf-8 from envelopes import Envelope, GMailSMTP envelope = Envelope( from_addr=(u'*****@*****.**', u'From Example'), to_addr=(u'*****@*****.**', u'To Example'), subject=u'Envelopes demo', text_body=u"I'm a helicopter!" ) envelope.add_attachment('/Users/bilbo/Pictures/helicopter.jpg') # Send the envelope using an ad-hoc connection... envelope.send('smtp.googlemail.com', login='******', password='******', tls=True) # Or send the envelope using a shared GMail connection... gmail = GMailSMTP('*****@*****.**', 'password') gmail.send(envelope)