|
@@ -5,6 +5,54 @@ from email.mime.text import MIMEText
|
|
|
from email.mime.base import MIMEBase
|
|
from email.mime.base import MIMEBase
|
|
|
from email import encoders
|
|
from email import encoders
|
|
|
|
|
|
|
|
|
|
+# def sendEmail(file_name,reciever_email,body,pdf_attach,subject):
|
|
|
|
|
+# # send_attachment.py
|
|
|
|
|
+# try:
|
|
|
|
|
+# # create message object instance
|
|
|
|
|
+# msg = MIMEMultipart()
|
|
|
|
|
+
|
|
|
|
|
+# # setup the parameters of the message
|
|
|
|
|
+# password = "kefonboard@2020"
|
|
|
|
|
+# msg['From'] = "admin@abacussoftware.services"
|
|
|
|
|
+# msg['To'] = reciever_email
|
|
|
|
|
+# msg['Subject'] = subject
|
|
|
|
|
+
|
|
|
|
|
+# msg.attach(MIMEText(body, 'html'))
|
|
|
|
|
+
|
|
|
|
|
+# if pdf_attach==True:
|
|
|
|
|
+# try:
|
|
|
|
|
+# pdfname='po_pdf/'+file_name
|
|
|
|
|
+# # open the file in bynary
|
|
|
|
|
+# binary_pdf = open(pdfname, 'rb')
|
|
|
|
|
+
|
|
|
|
|
+# payload = MIMEBase('application', 'octate-stream', Name='po_pdf.pdf')
|
|
|
|
|
+# payload.set_payload((binary_pdf).read())
|
|
|
|
|
+
|
|
|
|
|
+# # enconding the binary into base64
|
|
|
|
|
+# encoders.encode_base64(payload)
|
|
|
|
|
+
|
|
|
|
|
+# # add header with pdf name
|
|
|
|
|
+# payload.add_header('Content-Decomposition', 'attachment', filename=pdfname)
|
|
|
|
|
+# msg.attach(payload)
|
|
|
|
|
+# except Exception as err:
|
|
|
|
|
+# print('pdf attach err',err)
|
|
|
|
|
+
|
|
|
|
|
+# # create server
|
|
|
|
|
+# server = smtplib.SMTP('bom15.balasai.com: 587')
|
|
|
|
|
+# server.starttls()
|
|
|
|
|
+
|
|
|
|
|
+# # Login Credentials for sending the mail
|
|
|
|
|
+# server.login(msg['From'], password)
|
|
|
|
|
+
|
|
|
|
|
+# # send the message via the server.
|
|
|
|
|
+# server.sendmail(msg['From'], msg['To'], msg.as_string())
|
|
|
|
|
+
|
|
|
|
|
+# server.quit()
|
|
|
|
|
+
|
|
|
|
|
+# print('Email sent')
|
|
|
|
|
+# except Exception as err:
|
|
|
|
|
+# print(err)
|
|
|
|
|
+
|
|
|
def sendEmail(file_name,reciever_email,body,pdf_attach,subject):
|
|
def sendEmail(file_name,reciever_email,body,pdf_attach,subject):
|
|
|
# send_attachment.py
|
|
# send_attachment.py
|
|
|
try:
|
|
try:
|
|
@@ -12,8 +60,10 @@ def sendEmail(file_name,reciever_email,body,pdf_attach,subject):
|
|
|
msg = MIMEMultipart()
|
|
msg = MIMEMultipart()
|
|
|
|
|
|
|
|
# setup the parameters of the message
|
|
# setup the parameters of the message
|
|
|
- password = "kefonboard@2020"
|
|
|
|
|
- msg['From'] = "admin@abacussoftware.services"
|
|
|
|
|
|
|
+ # password = "kefonboard@2020"
|
|
|
|
|
+ password = "onboardkef@2021"
|
|
|
|
|
+ # msg['From'] = "admin@abacussoftware.services"
|
|
|
|
|
+ msg['From'] = "onboard@kotakeducationfoundation.org"
|
|
|
msg['To'] = reciever_email
|
|
msg['To'] = reciever_email
|
|
|
msg['Subject'] = subject
|
|
msg['Subject'] = subject
|
|
|
|
|
|
|
@@ -37,8 +87,8 @@ def sendEmail(file_name,reciever_email,body,pdf_attach,subject):
|
|
|
except Exception as err:
|
|
except Exception as err:
|
|
|
print('pdf attach err',err)
|
|
print('pdf attach err',err)
|
|
|
|
|
|
|
|
- # create server
|
|
|
|
|
- server = smtplib.SMTP('bom15.balasai.com: 587')
|
|
|
|
|
|
|
+
|
|
|
|
|
+ server =smtplib.SMTP('smtp.gmail.com', 587)
|
|
|
server.starttls()
|
|
server.starttls()
|
|
|
|
|
|
|
|
# Login Credentials for sending the mail
|
|
# Login Credentials for sending the mail
|