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
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)
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'))
def SendEmail(EmailId): try: html_string="" with open('EmailTemplate.html', 'r') as f: html_string = f.read() #mail_content = 'Body' mail_content=html_string sender_address = '*****@*****.**' sender_pass = '******' receiver_address = EmailId message = MIMEMultipart() message['From'] = sender_address message['To'] = receiver_address message['Subject'] = 'Reset Password - Quick E Park' message.attach(MIMEText(mail_content, 'html')) session = smtplib.SMTP('smtp.gmail.com', 587) session.starttls() session.login(sender_address, sender_pass) text = message.as_string() session.sendmail(sender_address, receiver_address, text) session.quit() flag=0 except Exception as e: flag="1" print(e) return flag
def HiringMail(jid): if request.method == 'POST': user_id = request.form['user'] company_name = jobs[jid]['company'] job_title = jobs[jid]['title'] html_content = """\ <html> <head></head> <body> <h2>Warm wishes !</h2><br><br> <p>This is to inform you that you have been selected by the company <b>'""" + company_name + """''</b> for the job profile - <b>'""" + job_title + """'</b>.<br><br></p> </body> </html> """ receiver = user_id[6:] message = MIMEMultipart() message['From'] = sender_email message['To'] = receiver message['Subject'] = "Confirmation" part2 = MIMEText(html_content, 'html') message.attach(part2) session = smtplib.SMTP('smtp.gmail.com', 587) session.starttls() session.login(sender_email, sender_password) text = message.as_string() sentMail = session.sendmail(sender_email, receiver, text) session.quit() doc = db1[user_id] doc[jid]['status'] = 'Hired' doc.save() return 'mail sent'
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")
def _login(self, session, user): session.login(user.user_id) self.db.login(user.user_id) self._maybe_associate_device(session) resp = make_response(json.dumps(user.json()), 200) resp.mimetype = 'application/json' self.app.signals['user-login'].send(self, id=user.user_id) return resp
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!"})
def send_recovery_email(username, email): #generate random password including uppercase lowercase and numbers password = ''.join( random.choices(string.ascii_uppercase + string.ascii_lowercase + string.digits, k=8)) salt = os.urandom(32) key = hashlib.pbkdf2_hmac('sha512', password.encode(), salt, 10000) storage = salt + key #passwors hash to be stored conn = sqlite3.connect('vulnerabilityDB.sqlite') cur = conn.cursor() #update hash in database cur.execute('''UPDATE adminhash SET hash = ? WHERE username = ? ''', (storage, username)) conn.commit() conn.close() #send email mail_content = "Password Recovery:\nDear {}\nYour New password is:\n\t{}\nPlease login to your account and change your password.\nThank You".format( username.upper(), password) # The mail addresses and password sender_address = "*****@*****.**" #Add sender Address Here sender_pass = "******" #Add sender password Here receiver_address = email #Add receiver/admin Address Here # Setup the MIME message = MIMEMultipart() message['From'] = sender_address message['To'] = receiver_address message['Subject'] = 'Password Reset' # The subject line # The body and the attachments for the mail message.attach(MIMEText(mail_content, 'plain')) # Create SMTP session for sending the mail session = smtplib.SMTP('smtp.gmail.com', 587) # use gmail with port session.starttls() # enable security session.login(sender_address, sender_pass) # login with mail_id and password text = message.as_string() session.sendmail(sender_address, receiver_address, text) session.quit() print('Mail Sent') return
def send_notification(receiver, noti): #receiver_address = 'receiver' #Setup the MIME message = MIMEMultipart() message['From'] = os.getenv('SENDER_ADDRESS') message['To'] = receiver message['Subject'] = 'EzHire Update' #The subject line #The body and the attachments for the mail message.attach(MIMEText(noti, 'plain')) #Create SMTP session for sending the mail session = smtplib.SMTP('smtp.gmail.com', 587) #use gmail with port session.starttls() #enable security sender_address = os.getenv('SENDER_ADDRESS') sender_pass = os.getenv('SENDER_PASS') session.login(sender_address, sender_pass) #login with mail_id and password text = message.as_string() session.sendmail(sender_address, receiver, text) session.quit()
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 login(username=None): if request.method == "POST": password = validateInput(request.form["password"]) session = SessionManager() try: loginResult = session.login(username, password) return returnResult(loginResult) except Exception as e: return returnError(e)
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)
# Configure session to use filesystem (instead of signed cookies) app.config["SESSION_FILE_DIR"] = mkdtemp() app.config["SESSION_PERMANENT"] = False app.config["SESSION_TYPE"] = "filesystem" Session(app) #Log in to HippoBOTamus insta ''' Details not included for public repo,see youtube demo in readme or enter your own details to test. ''' username = "" password = "" session = InstaPy(username=username, password=password, headless_browser=True) session.login() session.like_by_tags(["cs50"], amount=-9) @app.route("/") def index(): #Show Homepage return render_template("index.html") @app.route("/follow", methods=["GET", "POST"]) def instagram(): #Show follow page if request.method == "POST": #Follow the handle submitted