Sindbad~EG File Manager
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 sendMail(subject,html,to,mailData,societyData):
if societyData :
if societyData['driver'] == 'mailgun':
# pass
Mailgun.sendMail(subject,html,to,mailData,societyData)
elif societyData['driver'] == 'mandrill':
# pass
Mandrill.sendMail(subject,html,to,mailData,societyData)
else:
return "Please check mail configuration setting"
else:
return redirect (url_for('user.Home_index'))
def sendMail_otp(subject,html,to):
societyData = {
'driver':'mailgun',
'e_backup_emails': 'aiosbackup@gmail.com',
'e_from_email' : 'support@aios-online.com',
'conf_name' : '',
'e_reply_to' : 'support@aios-online.com',
'domain': 'mg2.numerotec.com',
'secret_key':'500f990be972a993db2004203b97b5c4-191fb7b6-be86716a',
}
mailData = {
'bcc_mails': 'aiosbackup@gmail.com',
'from_mail_name':'Prof. (Dr.) Namrata Sharma - Chairperson, AIOS Scientific Committee ..',
'from_mail_id' : None,
'reply_mail_id':None,
'is_send_backup' : 0,
}
return EMAIL.sendMail(subject=subject,html=html,to=to,mailData=mailData,societyData=societyData)
# def sendMail(subject,html,to):
# MANDRILL_API_KEY='XEs1ytJQpEwaZSq25YgB4Q' # IP ADDRESS ENABLED
# mandrill_client = mandrill.Mandrill(MANDRILL_API_KEY)
# #Test mail id for all mails
# # is_test_mail = AbstractModel().settings_mail('is_test_mail')
# # if is_test_mail["setting_value"] != 0 :
# # is_test_mail_id = AbstractModel().settings_mail('is_test_mail_id')
# # to = is_test_mail_id["setting_value"]
# message = {
# 'from_email' : ' support@numerotec.com',
# 'from_name': 'CSOS',
# 'subject' : subject,
# 'recipients':to,
# 'html': html,
# "headers" :
# {"Reply-To": " support@numerotec.com"} ,
# 'to' : [
# {
# 'email':to,
# 'name':to,
# 'type':'to'
# }
# ]
# }
# result = mandrill_client.messages.send(message = message,send_async=True)
# return ('success')
# def sendMailInMailGun(subject,html,to,society_id,cc=[],bcc=[]):
# societyData = Auth.getSociety(society_id)
# if societyData:
# 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': societyData['society_intial']+' Profile update ',
# 'html': html,
# 'from_email' : societyData['e_from_mail_id'],
# "headers" :{"Reply-To": societyData['e_reply_mail_id']} ,
# 'to' : [{'email':to,'name':to,'type':'to'},{'email':societyData['e_backup_mails'],'name':to,'type':'to'}] }
# try:
# result = mandrill_client.messages.send(message = message,send_async=True)
# except:
# print("error in mandrill")
# return ('success')
# else:
# return ('Email id is blank')
# else:
# return 'Please try again'
# def sendMailInMailGun1(subject,html,to,cc=[],bcc=[]):
# url = 'https://api.mailgun.net/v3/numerotech.com/messages'
# bcc = ["ipgsbackup@gmail.com"]
# auth = ('api', 'key-e13725db7c3a95b679911c038b490db1')
# data = {
# 'from' : 'IPGS Profile update <support@ipgs.org.in>',
# 'to' : to,
# 'cc' : cc,
# 'bcc' : bcc,
# 'subject': subject,
# 'html' : html
# }
# data['h:Reply-To']="Support <support@ipgs.org.in>" # <------------- HERE!
# res = requests.post(url, auth=auth, data=data)
# return "mail sent successful."
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists