Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import smtplib
- import imaplib
- import sched, time
- from email.mime.multipart import MIMEMultipart
- from email.mime.text import MIMEText
- import json
- from pymongo import MongoClient
- qa = {}
- client = MongoClient()
- db = client.questions
- collection = db.qcollection
- def input_questions():
- maxlength = 0
- i = 0
- while True:
- try:
- maxlength = int(input("How many questions do you want to ask? "))
- except ValueError:
- print ("You must type a number.")
- else:
- break
- for i in range(maxlength):
- q = input("Enter a question: ")
- a = input("Enter the expected answer: ")
- qa[q] = a
- print ('Question: ' + q + ' ' + 'Answer: ' + a)
- def email_questions():
- print ("Thank you. You will receive the response shortyly.")
- server = smtplib.SMTP('smtp.gmail.com', 587)
- server.ehlo()
- server.starttls()
- server. ehlo()
- server.login("j@gmail.com", "")
- fromaddr = "@gmail.com"
- toaddr = "j@gmail.com"
- msg = MIMEMultipart()
- msg['Fromaddr'] = fromaddr
- msg['Toaddr'] = toaddr
- msg['Subject'] = "Questions"
- body = "Answer these questions"
- message = [body] + qa
- formatted_message = '\n'.join(message)
- msg.attach(MIMEText(formatted_message, 'plain'))
- text = msg.as_string()
- server.sendmail(fromaddr, toaddr, text)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement