From b30f9f90af02e4039d9309fa4306a67335bb8aef Mon Sep 17 00:00:00 2001 From: Vineet Mahajan Date: Sun, 6 Dec 2020 10:19:45 +0530 Subject: [PATCH 1/2] Email sending program --- email_send.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 email_send.py diff --git a/email_send.py b/email_send.py new file mode 100644 index 0000000..72ba46c --- /dev/null +++ b/email_send.py @@ -0,0 +1,47 @@ +from smtplib import SMTP_SSL +import os + +def send(args): + #login info + from_addr = args['from_addr'] + password = args['password'] + + #senders + to_addr = args['to_addr'] + cc_addr = args['cc_addr'] + bcc_addr = args['bcc_addr'] + + #email compiled + message = "From: %s\r\n" % from_addr + message += "To: %s\r\n" % ', '.join(to_addr) + message += "CC: %s\r\n" % ', '.join(cc_addr) + message += "Subject: %s\r\n" % args['subject'] + message += "\r\n" + message += args['body'] + + recivers = to_addr + cc_addr + bcc_addr + print(message) + with SMTP_SSL('smtp.gmail.com', 465) as server: + server.login(from_addr, password) #login process + + while len(recivers)>99: #only 100 emails can be sent once + rec = recivers[:100] + recivers = recivers[100:] + server.sendmail(from_addr, rec, message) + + server.sendmail(from_addr, recivers, message) + return None + + + +args = { + 'from_addr' : 'sender', + 'password' : 'password;, + 'to_addr' : [], + 'cc_addr' : [], + 'bcc_addr' : [], + 'subject' : 'Demo subject', + 'body' : 'Unreal body', +} +send(args) + From 713aae76657482f594354a8f6fa314bde739655d Mon Sep 17 00:00:00 2001 From: Sigma086 <68197705+VineetS086@users.noreply.github.com> Date: Sun, 6 Dec 2020 10:34:55 +0530 Subject: [PATCH 2/2] Update email_send.py --- email_send.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/email_send.py b/email_send.py index 72ba46c..f2e68e3 100644 --- a/email_send.py +++ b/email_send.py @@ -36,7 +36,7 @@ def send(args): args = { 'from_addr' : 'sender', - 'password' : 'password;, + 'password' : 'password', 'to_addr' : [], 'cc_addr' : [], 'bcc_addr' : [],