def sendEmail(mail, subj): fromaddr = "*****@*****.**" toaddr = ["*****@*****.**", "*****@*****.**"] #toaddr = ["*****@*****.**"] msg = MIMENonMultipart('text', 'plain') msg['Content-Transfer-Encoding'] = '8bit' msg.set_payload(mail.encode('utf8'), 'utf-8') msg['From'] = fromaddr msg['To'] = toaddr[0] msg['Subject'] = subj server = smtplib.SMTP('smtp.gmail.com', 587) server.ehlo() server.starttls() server.ehlo() server.login(settings.email, settings.emailpass) body = msg.as_string() server.sendmail(fromaddr, toaddr[0], body, '8bitmime') msg['To'] = toaddr[1] body = msg.as_string() server.sendmail(fromaddr, toaddr[1], body, '8bitmime') server.quit()
def sendEmail(mail, subj): fromaddr = "*****@*****.**" toaddr = [ "*****@*****.**", "*****@*****.**" ] #toaddr = ["*****@*****.**"] msg = MIMENonMultipart('text', 'plain') msg['Content-Transfer-Encoding'] = '8bit' msg.set_payload(mail.encode('utf8'), 'utf-8') msg['From'] = fromaddr msg['To'] = toaddr[0] msg['Subject'] = subj server = smtplib.SMTP('smtp.gmail.com', 587) server.ehlo() server.starttls() server.ehlo() server.login(settings.email, settings.emailpass) body = msg.as_string() server.sendmail(fromaddr, toaddr[0], body, '8bitmime') msg['To'] = toaddr[1] body = msg.as_string() server.sendmail(fromaddr, toaddr[1], body, '8bitmime') server.quit()
def sendNonMultipartMail(context, sender, receiver, cc=[], bcc=[], subject="", text="", charset="utf-8"): """ """ mail = MIMENonMultipart("text", "plain") mail['From'] = sender mail['To'] = receiver mail['Cc'] = ", ".join(cc) mail['Bcc'] = ", ".join(bcc) mail['Subject'] = subject text = text.encode("utf-8") mail.set_payload(text) context.MailHost.send(mail.as_string())
def send_email(email_to, email_from, email_subject, email_body): msg = MIMENonMultipart('text', 'plain') msg['Content-Transfer-Encoding'] = '8bit' msg.set_payload(email_body, 'utf-8') msg['From'] = email_from msg['Subject'] = Header(email_subject, 'utf-8') server = smtplib.SMTP(config.smtp_host, config.smtp_port) server.ehlo() server.starttls() server.ehlo() server.login(email_from, config.email_password) for addr in email_to: msg['To'] = addr body = msg.as_string() server.sendmail(email_from, addr, body, '8bitmime') server.quit()
def send_email(email_to, email_from, email_subject, email_body): msg = MIMENonMultipart('text', 'plain') msg['Content-Transfer-Encoding'] = '8bit' msg.set_payload(email_body, 'utf-8') msg['From'] = email_from msg['Subject'] = Header(email_subject, 'utf-8') server = smtplib.SMTP(config.smtp_host, config.smtp_port) server.ehlo() server.starttls() server.ehlo() server.login(email_from, config.email_password) for addr in email_to: msg['To'] = addr body = msg.as_string() server.sendmail(email_from, addr, body, '8bitmime') server.quit()