Sindbad~EG File Manager

Current Path : /home/numerotech/mcinfo.numerotech.com/mc_info_update/core/library/
Upload File :
Current File : //home/numerotech/mcinfo.numerotech.com/mc_info_update/core/library/email.py

from flask import request, url_for,flash, render_template
from core import app
from flask import url_for
from datetime import datetime, date, time, timedelta
import requests,mandrill,json

import sib_api_v3_sdk
from sib_api_v3_sdk.rest import ApiException


class EMAIL:
	# Brevo starts here
	def sendMail(subject,html,to,conf):
		if conf:
			print("sendMail")
			print(conf)
			from_mail_name  = conf["conf_name"]
			from_mail_id 	= 'support@numerotec.com'
			reply_mail_id 	= conf["e_support_email"]
			configuration   = sib_api_v3_sdk.Configuration()
			configuration.api_key['api-key'] = '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'
			
			api_instance = sib_api_v3_sdk.TransactionalEmailsApi(sib_api_v3_sdk.ApiClient(configuration))
			
			sender = {"name":from_mail_name,"email":from_mail_id}
			to = [{"email":to}]
			reply_to = {"email":reply_mail_id}
			send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(to=to, reply_to=reply_to, html_content=html, sender=sender, subject=subject)
			try:
				api_response = api_instance.send_transac_email(send_smtp_email)
				print(api_response)
				print("in try")
				return("success")
				
			except ApiException as e:
				print("in exception")
				print("Exception when calling SMTPApi->send_transac_email: %s\n" % e)
				return("fail")
		else:
			return ('Email Id is Blank')
			
	
	
	def MCAcknowledgesendMail(subject,html,to,conf):
		if conf:
			print("MCAcknowledgesendMail")
			print(conf)
			from_mail_name  = conf["conf_name"]
			from_mail_id 	= 'support@numerotec.com'
			reply_mail_id 	= conf["e_support_email"]
			configuration   = sib_api_v3_sdk.Configuration()
			configuration.api_key['api-key'] = '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'
			
			api_instance = sib_api_v3_sdk.TransactionalEmailsApi(sib_api_v3_sdk.ApiClient(configuration))
			
			sender = {"name":from_mail_name,"email":from_mail_id}
			to = [{"email":to}]
			reply_to = {"email":reply_mail_id}
			send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(to=to, reply_to=reply_to, html_content=html, sender=sender, subject=subject)
			try:
				api_response = api_instance.send_transac_email(send_smtp_email)
				print(api_response)
				print("in try")
				return("success")
				
			except ApiException as e:
				print("in exception")
				print("Exception when calling SMTPApi->send_transac_email: %s\n" % e)
				return("fail")
		else:
			return ('Email Id is Blank')

	# Brevo ends here
	
# Mailgun starts here
# 	def sendMail(subject,html,to,conf):
# 		if conf:
# 			from_mail_name  = conf["conf_name"]
# 			from_mail_id 	= 'support@numerotec.com'
# 			reply_mail_id 	= conf["e_support_email"]
# 			url  	= 'https://api.mailgun.net/v3/'+conf['domain']+'/messages'
# 			auth 	= ('api',conf['secret_key'])
# 			data 	= {
# 			'from'   : from_mail_name+'<'+from_mail_id+'>',
# 			'to'     : to,
# 			'subject': subject,
# 			'html'   : html
# 			}
# 			data['h:Reply-To']= reply_mail_id
# 			res  = requests.post(url, auth=auth, data=data)
# 			return "mail sent successful." 
# 		else:
# 			return ('Email Id is Blank')
			
	
	
# 	def MCAcknowledgesendMail(subject,html,to,conf):
# 		if conf:
# 			from_mail_name  = conf["conf_name"]
# 			from_mail_id 	= 'support@numerotec.com'
# 			reply_mail_id 	= conf["e_support_email"]
# 			url  	= 'https://api.mailgun.net/v3/'+conf['domain']+'/messages'
# 			auth 	= ('api',conf['secret_key'])
# 			data 	= {
# 			'from'   : from_mail_name+'<'+from_mail_id+'>',
# 			'to'     : to,
# 			'subject': subject,
# 			'html'   : html
# 			}
# 			data['h:Reply-To']= reply_mail_id
# 			res  = requests.post(url, auth=auth, data=data)
# 			return "mail sent successful." 
# 		else:
# 			return ('Email Id is Blank')
# Mailgun ends here	
			
	
	# Old Mandrill Function - Changed Mandrill to mailgun by Ramya on 2024-05-15 1637
	# def sendMail(subject,html,to,conf):
	#     # MANDRILL_API_KEY='MAoeFJshVAG4-xTyPpTgUg'
	#     MANDRILL_API_KEY='3rql7lHFpPcoHnNAWYQTFQ' # IP ADDRESS ENABLED
	#     mandrill_client = mandrill.Mandrill(MANDRILL_API_KEY)

	#     message = {'subject' : subject, 'recipients':to,'from_name': conf["conf_name"],
	#     'html': html, 'from_email' : 'support@numerotec.com',
	#     "headers" :{"Reply-To": conf["e_support_email"]} ,'to' : [{'email':to,'name':to,'type':'to'}] }

	#     result = mandrill_client.messages.send(message = message,send_async=True)
	#     return ('success')

	# def MCAcknowledgesendMail(subject,html,to,conf):
	#     # MANDRILL_API_KEY='MAoeFJshVAG4-xTyPpTgUg'
	#     MANDRILL_API_KEY='3rql7lHFpPcoHnNAWYQTFQ' # IP ADDRESS ENABLED
	#     mandrill_client = mandrill.Mandrill(MANDRILL_API_KEY)

	#     message = {'subject' : subject, 'recipients':to,'from_name': conf["conf_name"],
	#     'html': html, 'from_email' : 'support@numerotec.com',
	#     "headers" :{"Reply-To": conf["e_support_email"]} ,'to' : [{'email':to,'name':to,'type':'to'}] }

	#     result = mandrill_client.messages.send(message = message,send_async=True)
	#     return ('success')    
	

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists