Ejemplo n.º 1
0
def send_email(emails, usernames):
    GMAIL_USERNAME = '******'
    GMAIL_PASSWORD = '******'
    recipients = ", ".join(emails)
    print recipients
    email_subject = "Ride Together!"
    body_of_email = (" and ".join(usernames) + ", \nYou two are riding within 1km of eachother." + 
        "You should meet up and Ride With Friends!" + 
        "\n\nHave Fun!" +
        "\n-RideWithFriends")

    session = smtplib.SMTP('smtp.gmail.com', 587)
    session.ehlo()
    session.starttls()
    session.login(GMAIL_USERNAME, GMAIL_PASSWORD)

    headers = "\r\n".join(["from: " + GMAIL_USERNAME,
                           "subject: " + email_subject,
                           "to: " + recipients,
                           "mime-version: 1.0",
                           "content-type: text/html"])

    content = headers + "\r\n\r\n" + body_of_email
    session.sendmail(GMAIL_USERNAME, emails[0], content)
    session.sendmail(GMAIL_USERNAME, emails[1], content)
Ejemplo n.º 2
0
def forgot_password():
    status = None;
    if request.method == 'GET':
        status = "Please enter your email address here, and we will send you an email containing a link which you can click to reset your password."
        return render_template('forgot_password.html', status=status)
    else: #request.method == 'POST':
        user = db.session.query(User).filter_by(email=request.form['email']).first()
        if user == None:
            status = Markup("That email address has not been registered! Please <a href=\"/register\"> register. </a> ")
            return render_template('forgot_password.html', status=status)
        if user != None:
            #Send email containing link to /reset_password/<validation_code>, which will display a form with a password field, 
            #   which will reset the user's password upon submit.
            session = smtplib.SMTP('smtp.gmail.com', 587)
            session.ehlo()
            session.starttls()
            session.ehlo()
            session.login('*****@*****.**', 'tor3nc45')
            headers = ["from: [email protected]",
                        "subject: Password reset for whereintheworldiswillie",
                        "to: " + request.form['email'],
                        "mime-version: 1.0",
                        "content-type: text/html"]
            headers = "\r\n".join(headers)
            body = "Hello! <br> Please click this link to reset your password: http://whereintheworldiswillie.herokuapp.com/reset_password/" + db.session.query(User).filter_by(email=request.form['email']).first().validation_code + "<br><br> Thanks, <br> whereintheworldiswillie"
            session.sendmail("*****@*****.**", request.form['email'], headers + "\r\n\r\n" + body)

            return redirect(url_for('login'))
Ejemplo n.º 3
0
def enviar_alerta( email , mensaje ):
    import smtplib
    correo_gmail = "*****@*****.**"
    contrasenia_gmail = "Aasdf12345"
    servidor = 'smtp.gmail.com'
    puerto = 587

    session = smtplib.SMTP( servidor , puerto )

    session.ehlo()
    session.starttls()
    session.ehlo

    session.login( correo_gmail , contrasenia_gmail )

    headers = [
        "From: " + correo_gmail,
        "Subject: Mensaje de alerta >> TSO",
        "To: " + email,
        "MIME-Version: 1.0",
        "Content-Type: text/html"]
    headers = "\r\n".join( headers )

    session.sendmail( correo_gmail , email ,  headers + "\r\n\r\n" + mensaje )
    print "mensaje enviado a : " + email
Ejemplo n.º 4
0
def quote_request():
    if request.method=="GET":
        return render_template("quote_request.html")
    else: #request.method=="POST"
        msg = MIMEMultipart('related')
        session = smtplib.SMTP('smtp.gmail.com', 587)
        session.ehlo()
        session.starttls()
        session.ehlo()
        session.login('*****@*****.**', os.environ['GMAIL_PASSWORD'])
        msg['From'] = "*****@*****.**"
        msg['Subject'] = "Someone has filled out the quote request form!"
        msg['To'] = "[email protected];[email protected];[email protected];[email protected];[email protected];[email protected]"
        body = "Name: " + request.form['name'] + "<br>" + "Procedure: " + request.form['procedure'] + "<br>" + "Weight: " + request.form['weight'] + "<br>" + "Zip: " + request.form['zip'] + "<br>" + "Breed: " + request.form['breed'] + "<br>" + "Age: " + request.form['age'] + "<br>" + "Sex: " + request.form['sex'] + "<br>" + "Customer's email address: " + request.form['email_addr'] + "<br>" + "Customer's First Name: " + request.form['user_fname'] + "<br>" + "Customer's Last Name: " + request.form['user_lname']
        content = MIMEText(body, 'html')
        msg.attach(content)

        f = request.files['the_file']
        f = MIMEImage(f.read())
        msg.attach(f)

        session.sendmail("*****@*****.**", recipients, msg.as_string())


        flash("Thanks! Your quote request has been successfully submitted.")
        return render_template("quote_request.html")
Ejemplo n.º 5
0
def feedback():
    msg = MIMEMultipart('alternative')
    session = smtplib.SMTP('smtp.gmail.com', 587)
    session.ehlo()
    session.starttls()
    session.ehlo()
    session.login('*****@*****.**', os.environ['GMAIL_PASSWORD'])
    msg['From'] = sender
    msg['Subject'] = "VetCompare feedback: " + request.form['subject']
    msg['To'] = "[email protected];[email protected];[email protected];[email protected];[email protected];[email protected]"
    body = "From: " + request.form['email'] + "<br><br>" + "What are you thinking: " + request.form['description']
    content = MIMEText(body, 'html')
    msg.attach(content)
    session.sendmail(sender, recipients, msg.as_string())
    return jsonify({"message": "Thanks!"})
Ejemplo n.º 6
0
def sendEmailV4():
    # subject = ''
    recipient=', '.join(['*****@*****.**'])
    body='html text'
    subject = 'subjectline'
    headers = ["From: " + '*****@*****.**',
               "Subject: " + 'subject',
               "To: " + '*****@*****.**',
               "MIME-Version: 1.0",
               "Content-Type: text/html"]
    headers = "\r\n".join(headers)
    session = smtplib.SMTP("allsmtp.acgov.org",25)
    session.ehlo()
    session.starttls()
    session.ehlo
    session.sendmail('*****@*****.**', ['*****@*****.**'], headers + "\r\n\r\n" + body)
    session.quit()
    return "it worked"
Ejemplo n.º 7
0
def register():
    status = None
    if request.method == 'POST':
        rand_str = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(10))
        new_user = User(request.form['fname'], request.form['lname'], request.form['email'], request.form['password'], rand_str, '0')
        
        if('*****@*****.**' not in request.form['email']):
        #if(False):
            status = "Sorry, that didn't work! Please use your \"[email protected]\" email address (the same one that you got on the first day of school). Thanks :)"
            return render_template('register.html', status=status)
        #If not empty:
        if (db.session.query(User).filter_by(email=request.form['email']).first()!=None):
            #Mark as invalid
            status = "Sorry, that didn't work! A user with that email address has already been verified."
            return render_template('register.html', status=status)
        else:   #User is using his/her corect email address, and there isn't already a user in the system with that email address  
            db.session.add(new_user)
            db.session.commit()

            url_to_send = 'http://whereintheworldiswillie.herokuapp.com/validate/' + rand_str     ##replace this url 
            session = smtplib.SMTP('smtp.gmail.com', 587)
            session.ehlo()
            session.starttls()
            session.ehlo()
            session.login('*****@*****.**', 'tor3nc45')
            headers = ["from: [email protected]",
                        "subject: Please validate your account with whereintheworldiswillie",
                        "to: " + request.form['email'],
                        "mime-version: 1.0",
                        "content-type: text/html"]
            headers = "\r\n".join(headers)
            body = "Hello! <br> Please click the following link to activate your account with whereintheworldiswillie: "  + url_to_send + ". <br><br> Thanks! <br> Best, <br> whereintheworldiswillie"
            session.sendmail("*****@*****.**", request.form['email'], headers + "\r\n\r\n" + body)

            status = "Success! Please check your email, and click the link in the message we sent you to validate your account. "
            return render_template('register.html', status=status)
    else:  #(if request.method == 'GET')
        status = "Please register here to add your information :)"
        return render_template('register.html', status=status)
def email(email_subject,body_of_email):
	users = Users_config.query.first()
	GMAIL_USERNAME = users.email
	GMAIL_PASSWORD = users.password_email
	email_subject = email_subject
	body_of_email = body_of_email
	recipient = users.email
	# The below code never changes, though obviously those variables need values.
	session = smtplib.SMTP(users.smtp,users.port)
	type(session)
	session.ehlo()
	session.starttls()                              
	session.login(GMAIL_USERNAME, GMAIL_PASSWORD)
	headers = "\r\n".join(["from: " + GMAIL_USERNAME,
	                   "subject: " + email_subject,
	                   "to: " + recipient,
	                   "mime-version: 1.0",
	                   "content-type: text/html"])

	# body_of_email can be plaintext or html!                    
	content = headers + "\r\n\r\n" + body_of_email 
	session.sendmail(GMAIL_USERNAME, recipient, content)