Sindbad~EG File Manager

Current Path : /home/numerotech/s3.numerotech.com/s3_backup_app_v1/core/library/
Upload File :
Current File : //home/numerotech/s3.numerotech.com/s3_backup_app_v1/core/library/email.py

from flask import request, url_for,flash, render_template,redirect
from core import app
from flask import url_for
from datetime import datetime, date, time, timedelta
import requests,mandrill,json
from core.library.helper import Helper
from .. import Cryptography,Auth,Helper,RouteGroup
from core.library.Mandrill import Mandrill
from core.library.Mailgun import Mailgun

class EMAIL:
	
	def OtpSendMail(subject,html,to):
		from_mail_name  = 'AWS APP'
		from_mail_id    = 'apps@numerotec.com'
		reply_mail_id   = 'ntecBackup@gmail.com'

		cc      = []
		bcc     = []
		url     = 'https://api.mailgun.net/v3/mailgun.urbanedge.co.in/messages'
		auth    = ('api','c490c312d1becd68199c1942f90fcb22-191fb7b6-e958e8e0')
		data    = {
		'from'   : from_mail_name+'<'+from_mail_id+'>',
		'to'     : to,
		'cc'     : cc,
		'bcc'    : bcc,
		'subject': subject,
		'html'   : html
		}
		data['h:Reply-To']= reply_mail_id
		res  = requests.post(url, auth=auth, data=data)
		return "mail sent successful." 
	
	
	
	
#     def OtpSendMail(subject,html,to):
#         # MANDRILL_API_KEY='MAoeFJshVAG4-xTyPpTgUg'
#         if to:
#             print("entering into mandrill")
#             # MANDRILL_API_KEY='md-WHhIRdtiJJHa7wD0_WY6pQ'
#             MANDRILL_API_KEY='md-WHhIRdtiJJHa7wD0_WY6pQ' # IP ADDRESS ENABLED
#             mandrill_client = mandrill.Mandrill(MANDRILL_API_KEY)

#             message = {'subject' : subject, 'recipients':to,'from_name': 'AWS APP',
#             'html': html, 'from_email' : 'apps@numerotec.com',
#             "headers" :{"Reply-To": "ntecBackup@gmail.com"} ,'to' : [{'email':to,'name':to,'type':'to'}] }

# #           result = mandrill_client.messages.send(message = message,send_async=True)
#             try:
#                 result = mandrill_client.messages.send(message = message,send_async=True)
#                 print('success')
#             except:
#                 print("error in mandrill")
#             return ('success')

#         else:

#             return ('Email Id is Blank')






	# def sendMail(subject,html,to):
	#     # MANDRILL_API_KEY='MAoeFJshVAG4-xTyPpTgUg'
		
	#     print("email function")
	#     MANDRILL_API_KEY='3rql7lHFpPcoHnNAWYQTFQ' # IP ADDRESS ENABLED
	#     mandrill_client = mandrill.Mandrill(MANDRILL_API_KEY)
 
	#     message = {'subject' : subject, 'recipients':to,'from_name': 'AWS',
	#     'html': html, 'from_email' : 'ntecBackup@gmail.com',
	#     "headers" :{"Reply-To": "ntecBackup@gmail.com"} ,'to' : [{'email':to,'name':to,'type':'to'}] }
 
		
	#     # result = mandrill_client.messages.send(message = message,send_async=True)
	#     try:
	#         result = mandrill_client.messages.send(message = message,send_async=True)
	#     except:
	#         print("error in mandrill")
	#     return ('success')


# mailgun function for sending mails		
# 	def sendMailInMailGun(subject,html,to,mailData):
# 		societyData		= Auth.getSociety()
# 		bcc_mails 		= societyData['backup_mail']
# 		from_mail_name 	= societyData['from_mail_name']
# 		from_mail_id 	= societyData['from_mail_id']
# 		reply_mail_id 	= societyData['reply_mail_id']
# 		if mailData:
# 			if mailData.bcc_mails is not  None:
# 				bcc_mails = mailData.bcc_mails	
# 			if mailData.from_mail_name is not None :
# 				from_mail_name = mailData.from_mail_name
# 			if mailData.from_mail_id is not None :
# 				from_mail_id = mailData.from_mail_id
# 			if mailData.reply_mail_id is not None :
# 				reply_mail_id = mailData.reply_mail_id

# 		cc      = []
# 		bcc     = [bcc_mails]
# 		url  	= 'https://api.mailgun.net/v3/'+societyData['mailgun_domain']+'/messages'
# 		auth 	= ('api',societyData['mailgun_key'])
# 		data 	= {
# 		'from'   : from_mail_name+'<'+from_mail_id+'>',
# 		'to'     : to,
# 		'cc'     : cc,
# 		'bcc'    : bcc,
# 		'subject': subject,
# 		'html'   : html
# 		}
# 		data['h:Reply-To']= reply_mail_id
# 		res  = requests.post(url, auth=auth, data=data)
# 		return "mail sent successful." 




# # MailGun old function	
# 	def sendMailInMailGun_old(subject,html,to):
# 		cc      = []
# 		bcc     = [Auth.getSociety()['backup_mail']]
# 		url     = 'https://api.mailgun.net/v3/'+Auth.getSociety()['mailgun_domain']+'/messages'
# 		auth    = ('api', Auth.getSociety()['mailgun_key'])
# 		data    = {
# 		'from'   : Auth.getSociety()['from_mail_name']+'<'+Auth.getSociety()['from_mail_id']+'>',
# 		'to'     : to,
# 		'cc'     : cc,
# 		'bcc'    : bcc,
# 		'subject': subject,
# 		'html'   : html
# 		}
		
# 		data['h:Reply-To']= Auth.getSociety()['reply_mail_id'] 
# 		res  = requests.post(url, auth=auth, data=data)
# 		return "mail sent successful." 
# # -------------------------------------------------------------- MANDRILL -------------------------------------------------------------

# 	def sendMailInMailGun(subject,html,to,mailData):
# 		societyData		= Auth.getSociety()
# 		bcc_mails 		= societyData['backup_mail']
# 		from_mail_name 	= societyData['from_mail_name']
# 		from_mail_id 	= societyData['from_mail_id']
# 		reply_mail_id 	= societyData['reply_mail_id']
# 		if mailData:
# 			if mailData.bcc_mails is not  None:
# 				bcc_mails = mailData.bcc_mails	
# 			if mailData.from_mail_name is not None :
# 				from_mail_name = mailData.from_mail_name
# 			if mailData.from_mail_id is not None :
# 				from_mail_id = mailData.from_mail_id
# 			if mailData.reply_mail_id is not None :
# 				reply_mail_id = mailData.reply_mail_id
# 		if to:

# 			# MANDRILL_API_KEY='MAoeFJshVAG4-xTyPpTgUg'
# 			MANDRILL_API_KEY='XEs1ytJQpEwaZSq25YgB4Q' # IP ADDRESS ENABLED
# 			mandrill_client = mandrill.Mandrill(MANDRILL_API_KEY)

# 			message = {
# 				'subject'    : subject, 
# 				'recipients' : to,
# 				'from_name'  : from_mail_name,
# 				'html'       : html, 
# 				'from_email' : from_mail_id,
# 				"headers"    : {"Reply-To": reply_mail_id} ,
# 				'to'         : [{'email':to,'name':to,'type':'to'},{'email':bcc_mails,'name':to,'type':'to'}] 
# 				}

# 			result = mandrill_client.messages.send(message = message,send_async=True)
# 			return ('success')
# 		else:
# 			return ('Email id is blank')

# 	def sendApprovedMailInMailGun(subject,html,to):
# 		if to:

# 			# MANDRILL_API_KEY='MAoeFJshVAG4-xTyPpTgUg'
# 			MANDRILL_API_KEY='XEs1ytJQpEwaZSq25YgB4Q' # IP ADDRESS ENABLED
# 			mandrill_client = mandrill.Mandrill(MANDRILL_API_KEY)

# 			message = {
# 				'subject'   : subject, 
# 				'recipients': to,
# 				'from_name' : Auth.getSociety()['from_mail_name'],
# 				'html'      : html, 
# 				'from_email' : Auth.getSociety()['from_mail_id'],
# 				"headers" :{"Reply-To": Auth.getSociety()['reply_mail_id']} ,
# 				'to' : [
# 					{'email': to,'name':to,'type':'to'},
# 					{'email': Auth.getSociety()['backup_mail'],'name':to,'type':'to'},
# 					{'email':'drjigneshtaswala@gmail.com'},
# 					{'email':'jrajesh68@gmail.com'},
# 					{'email':'dr_mraj@yahoo.com'},
# 					{'email':'sai@numerotec.com'}
# 					] 
# 				}

# 			result = mandrill_client.messages.send(message = message,send_async=True)
# 			return ('success')
# 		else:
# 			return ('Email id is blank')	

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