import os import sendgrid from sendgrid import SendGridAPIClient from sendgrid.helpers.mail import Mail from email.mime.application import MIMEApplication from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.mime.image import MIMEImage import smtplib, ssl fromadd = 'pragnakalp.dev35@gmail.com' password = 'pragnakalpl20$123' SENDGRID_API_KEY = "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" def gmail_login(): try: server = smtplib.SMTP_SSL('smtp.sendgrid.net', 465) server.ehlo() server.login('apikey', SENDGRID_API_KEY) return server except Exception as e: print("*** MAIL ERROR ***"*10) print(e) def send_user_email(input_img,hostname,text_output,Method): try: attachment = input_img email_body="" text =f"A user has submitted a image for OCR.\r\n\r\{hostname}\rMethod: {Method}\r\Result: {text_output}" html = """
{hostname}
Method: {Method}
Generated text: {text_output}