def save_mail(self, message): # msg = email.message.Message() # msg['Subject'] = 'subject of the message' # msg['From'] = self.userid # msg['To'] = MY_EMAIL # msg.set_payload(message) # # append the message to the drafts folder # now = imaplib.Time2Internaldate(time.time()) # imap.append('[Gmail]/Drafts', '', now, msg.as_bytes()) msg = MIMEMultipart("alternative") msg.set_charset("utf-8") msg.attach(MIMEText(message, "plain", "utf-8")) msg['Subject'] = "SUBJECT" msg['From'] = self.userid msg['To'] = "*****@*****.**" conn = imaplib.IMAP4_SSL('imap.gmail.com', port=993) conn.login(self.userid, self.password) conn.select('[Gmail]/Drafts') conn.append("[Gmail]/Drafts", '', imaplib.Time2Internaldate(time.time()), msg.as_bytes()) ts.t2s("Saved to drafts")
def compose_mail(self): print("incompose") ts.t2s("Welcome to compose mail. Speak subject of message") print(" Speak your message") subject = ts.get_command() ts.t2s("Now speak the email content") text = ts.get_command() # ts.t2s("Your message is:"+msg) # ts.t2s("If corect say yes else say no") print("Your message is:" + text) print("If correct say yes else say no") msg = 'Subject: {}\n\n{}'.format(subject, text) # msg = email.message.Message() # msg['Subject'] = 'subject of the message' # msg['From'] = self.userid # # msg.set_payload(text) ts.t2s( "Your message has been recorded. Say send to send this mail and save to save it to drafts" ) choice = ts.get_command(["send", "save"]) if choice == "send": self.send_mail(msg) elif choice == "save": self.save_mail(msg) return
def readAll(mail_list): #print("readAll") tm.readAll_msg() for i in mail_list: mail = i.from_addr + " " + i.title ts.t2s(mail) cmd = ts.get_command( ["read", "next", "forward", "delete", "reply", "stop"]) if cmd == "read": mail = i.body ts.t2s(mail) elif cmd == "next": continue elif cmd == "forward": smtp.forward_mail(i.body) elif cmd == "delete": account.delete_mail(i.from_addr, i.from_addr) print("deleted") elif cmd == "reply": smtp.reply_mail(i.from_addr) elif cmd == "stop": break
def reply_mail(self, recepient_id): ts.t2s("Please provide your reply") print(" Speak your reply") reply = ts.get_command() # ts.t2s("Your message is:"+msg) # ts.t2s("If corect say yes else say no") #print("Your message is:" + reply) #print("If correct say yes else say no") ts.t2s("Your reply has been recorded. Say send to send the reply") choice = ts.get_command(["send", "save"]) if choice == "send": server = smtplib.SMTP('smtp.gmail.com', 587) print("Connected to gmail server") server.starttls() server.login(self.userid, self.password) print("logged in") server.sendmail(self.userid, recepient_id, reply) ts.t2s("your reply has been sent to " + recepient_id) return else: ts.t2s("Reply not sent")
def forward_mail(self, msg): ts.t2s(" Speak recepient's email id") print(" Speak recepient's email id") receiever = ts.get_email() print(receiever) reciever = "*****@*****.**" ts.t2s("Your message reciever is:" + reciever) server = smtplib.SMTP('smtp.gmail.com', 587) print("Connected to gmail server") server.starttls() server.login(self.userid, self.password) print("logged in") server.sendmail(self.userid, "*****@*****.**", msg) ts.t2s("your message has been sent") return
def send_mail(self, msg): print("in send_mail") ts.t2s(" Speak recepient's email address") print(" Speak recepient's email address") receiver = ts.get_email() print(receiver) ts.t2s("Your message reciever is:" + receiver) receiver = "*****@*****.**" server = smtplib.SMTP('smtp.gmail.com', 587) print("Connected to gmail server") server.starttls() server.login(self.userid, self.password) print("logged in") server.sendmail(self.userid, receiver, msg) ts.t2s("your message has been sent") return
def box_msg(self, ): ts.t2s( "Please listen your choice. Read all to read all mails. Dashboard to go to your mail dashboard." )
def readAll_msg(self, ): ts.t2s( "reading all mails give command after each mail information after you listen speak now, read to read complete message next to read next mail forward to forward mail Delete to delete mail reply to reply mail stop to stop reading all mails." )
def inbox_msg(self, ): ts.t2s( "Welcome to your inbox. Please listen your choice. Read all k to read all mails. Unseen to read unseen mails." )
def mailboxes_msg(self, ): ts.t2s( "This is your mailbox. Please listen your choices. Inbox to choose inbox. Sent to choose sent box. Important to choose important mailbox. Drafts to choose draftbox." )
def dashboard_msg(self): ts.t2s( "Welcome to your email account. Please listen your choices. Compose to compose. Inbox to access your inbox. Logout to logout form this account " )