Example #1
0
def index():
    #retrieving form data
    if request.method == 'POST':
        name=request.form['name']
        email=request.form['email']
        destination=request.form['destination']
        itinerary=request.form['itinerary']
        
        # Sending email
        app.config['MANDRILL_API_KEY'] = 'UUs-Wadj9AtJ4fMqC45SrQ'
        mandrill = Mandrill(app)
        mandrill.send_email(
        from_email='*****@*****.**',
            to=[{'email': email}],
        text='Hello'+name,
        subject="Welcome "+name
            )
            
        # Saving in database            
        client = MongoClient(host='mongodb://*****:*****@ds041633.mongolab.com:41633/buggl')
        db = client.buggl
    
        result = db.entries.insert_one({
        "name": name,
        "email": email,
        "destination": destination,
        "itinerary": itinerary,
        
        })
        
        #return
        return "Thank you "+name+". We've sent an email to: "+email+", informing you want "+itinerary+" in your trip"
        
    else:
        return render_template('index.html')
Example #2
0
def form():
    #retrieving form data
    if request.method == 'POST':
        name=request.form['name']
        email=request.form['email']
        category=request.form['trip_category']
        plan=request.form['plan']
        
        # Sending email
        app.config['MANDRILL_API_KEY'] = 'UUs-Wadj9AtJ4fMqC45SrQ'
        mandrill = Mandrill(app)
        mandrill.send_email(
        from_email='*****@*****.**',
            to=[{'email': email}],
        text='Hello'+name,
        subject="Welcome "+name
            )
            
        # Saving in database            
        client = MongoClient(host='mongodb://*****:*****@ds041633.mongolab.com:41633/buggl')
        db = client.buggl
    
        result = db.entries.insert_one({
        "plan": plan,
        "trip_category": category,
        "email": email,
        "name": name
        })
        
        #return
        return "Thank you "+name+". We've sent an email to: "+email+", informing you want "+category+" category and you want the  "+plan+" plan"
        
    else:
        return render_template('form.html')
Example #3
0
def send_email(form):
    mandrill = Mandrill(pqr)
    mandrill.send_email(
        from_email='*****@*****.**',
        subject=form['subject'],
        to=[{
            'email': pqr.config['DEFAULT_EMAIL']
        }, {
            'email': '*****@*****.**'
        }],
        text=form['subject'] + "\n" + "From: " + form['email'] + "\n" +
        form['message'],
        html=render_template("email/contact.html",
                             date=datetime.now().strftime('%Y/%m/%d %H:%M:%S'),
                             name=form['name'],
                             email=form['email'],
                             subject=form['subject'],
                             message=form['message']),
    )
    flash("Message has been sent!", 'sent')
Example #4
0
def send_email(config, email, subject, body):
    print 'sending email to %s (%s)' % (email, subject)
    if config.email.use_mandrill:
        if isinstance(email, basestring):
            to=[{'email': email}]
        else:
            to = []
            for addr in email:
                to.append({'email': addr})
        import flask
        from flask.ext.mandrill import Mandrill

        mandrill = Mandrill(flask.current_app)
        mandrill.send_email(
            subject=subject,
            to=to,
            text=body
        )
    else:
        import smtplib
        from email.mime.text import MIMEText

        if isinstance(email, basestring):
            to=email
        else:
            to = ', '.join(email)

        # Create a text/plain message
        msg = MIMEText(body)
        msg['Subject'] = subject
        msg['From'] = config.email.from_
        msg['To'] = to

        # Send the message via our own SMTP server, but don't include the
        # envelope header.
        s = smtplib.SMTP(config.email.smtp)
        if config.email.use_auth:
            s.starttls()
            s.login(config.email.user, config.email.password)
        s.sendmail(config.email.from_, [email], msg.as_string())
        s.quit()
Example #5
0
def expert():
    # retrieving form data
    if request.method == "POST":
        name = request.form["name"]
        email = request.form["email"]
        destination = request.form["destination"]
        itinerary = request.form["itinerary"]
        plan = request.form["plan"]

        # Sending email
        app.config["MANDRILL_API_KEY"] = "UUs-Wadj9AtJ4fMqC45SrQ"
        mandrill = Mandrill(app)
        mandrill.send_email(
            from_email="*****@*****.**", to=[{"email": email}], text="Hello " + name, subject="Welcome " + name
        )

        # Saving in database
        client = MongoClient(host="mongodb://*****:*****@ds041633.mongolab.com:41633/buggl")
        db = client.buggl

        result = db.entries.insert_one(
            {"name": name, "email": email, "destination": destination, "itinerary": itinerary, "plan": plan}
        )

        # return
        return (
            "Thank you "
            + name
            + ". We've sent an email to: "
            + email
            + ", informing you want "
            + itinerary
            + " in your trip and you want the  "
            + plan
            + " plan"
        )

    else:
        return render_template("expert.html")
Example #6
0
def send_email(config, email, subject, body):
    print 'sending email to %s (%s)' % (email, subject)
    if config.email.use_mandrill:
        if isinstance(email, basestring):
            to = [{'email': email}]
        else:
            to = []
            for addr in email:
                to.append({'email': addr})
        import flask
        from flask.ext.mandrill import Mandrill

        mandrill = Mandrill(flask.current_app)
        mandrill.send_email(subject=subject, to=to, text=body)
    else:
        import smtplib
        from email.mime.text import MIMEText

        if isinstance(email, basestring):
            to = email
        else:
            to = ', '.join(email)

        # Create a text/plain message
        msg = MIMEText(body)
        msg['Subject'] = subject
        msg['From'] = config.email.from_
        msg['To'] = to

        # Send the message via our own SMTP server, but don't include the
        # envelope header.
        s = smtplib.SMTP(config.email.smtp)
        if config.email.use_auth:
            s.starttls()
            s.login(config.email.user, config.email.password)
        s.sendmail(config.email.from_, [email], msg.as_string())
        s.quit()
Example #7
0
import base64

from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

from flask import Flask, render_template, redirect, url_for
from flask.ext.mail import Mail, Message
from subprocess import call
from flask.ext.mandrill import Mandrill

manager = Manager(app)
mail_ext = Mail(app)

app.config['MANDRILL_API_KEY'] = 'rgN2mMD61Fma_qLk7Uf6jw'
app.config['MANDRILL_DEFAULT_FROM'] = '*****@*****.**'
mandrill = Mandrill(app)

RECEIPTS_DIR = "/home/infodigital/tax-receipts/"


# From http://flask.pocoo.org/snippets/68/
def create_pdf(pdf_data, pdf_file_name):
    html_file_name = "tax_mail.html"
    temphtmlfile = open(html_file_name, "w")
    temphtmlfile.write(pdf_data)
    temphtmlfile.close()
    call("/usr/local/bin/wkhtmltopdf " + html_file_name + " " + RECEIPTS_DIR +
         pdf_file_name,
         shell=True)

Example #8
0
from flask import Flask
from flask.ext.mandrill import Mandrill

app = Flask(__name__)
app.config["MANDRILL_API_KEY"] = "UUs-Wadj9AtJ4fMqC45SrQ"
mandrill = Mandrill(app)
mandrill.send_email(from_email="*****@*****.**", to=[{"email": "*****@*****.**"}], text="Hello World")