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
class Mailgun:
def sendMail(subject,html,to,mailData,societyData):
# societyData = Auth.getSociety(society_id)
if societyData:
bcc_mails = societyData['e_backup_mails']
from_mail_name = societyData['e_from_mail_name']
from_mail_id = societyData['e_from_mail_id']
reply_mail_id = societyData['e_reply_mail_id']
if mailData and type(mailData) != dict:
mailData = dict(mailData._mapping)
if mailData:
if mailData.get('bcc_mails',None) is not None:
bcc_mails = mailData.get('bcc_mails',None)
if mailData.get('from_mail_name',None) is not None :
from_mail_name = mailData.get('from_mail_name',None)
if mailData.get('from_mail_id',None) is not None :
from_mail_id = mailData.get('from_mail_id',None)
if mailData.get('reply_mail_id',None) is not None :
reply_mail_id = mailData.get('reply_mail_id',None)
# for sending backup mails
if int(mailData.get('is_send_backup',None))==1:
bcc = [bcc_mails]
else:
bcc = []
cc = []
# bcc = [bcc_mails]
url = 'https://api.mailgun.net/v3/'+societyData['domain']+'/messages'
auth = ('api',societyData['secret_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."
else:
return redirect (url_for('user.Home'))
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists