def SendMail(sender, msg, subject, filenmame=None): outlook_config_data = cs.readConfig('outlook_mail') emailId = outlook_config_data.get('emailId') password = outlook_config_data.get('emailPassword') if emailId == None or password == None: cs.warn('unable to retrive mail cred') cs.reConfig('outlook_mail') return SendMail(sender, msg, subject, filenmame) authenticiation = (emailId, password) m = Message(auth=authenticiation) m.setRecipients(sender) m.setSubject(subject) m.setBodyHTML(msg) m.setSenderName() if filenmame: att = Attachment(path=filenmame) m.attachments.append(att) mailSendStatus = m.sendMessage() return mailSendStatus
def send_email(email, subject, message): o365_auth = ('*****@*****.**', 'Notreset2017!') m = Message(auth=o365_auth) m.setRecipients(email) m.setSubject(subject) m.setBodyHTML(message) m.sendMessage() print("Email was send on {}, with message: {}".format(email, message))
def send(self, subject, body, to=None): """ Envia email :param subject: titulo de mensagem :param body: corpo do email :return: objeto de email """ m = Message(auth=(self.user, self.pwd)) emails = self.to_email if to is None else to for i in emails.split(';'): m.addRecipient(i) m.setSubject(subject) m.setBodyHTML(body) try: m.sendMessage() except Exception as e: self.error = f'Falha ao enviar o email{e}'