def send_emails(self, emails, person, special_day): day_type = self.special_day_type(special_day) email = Email( '*****@*****.**', emails, day_type.capitalize(), f'Hoy es el {day_type} de {person.name}. Emails: {emails}') return email.send_email()
def process_script(self): """Process the standard output for any scripting commands to be handled.""" if len(self.script) == 0: return False to = self.message.sender subject = "RE: {0}".format(self.message.subject) body = self.reply_message email = Email(receiver=to, subject=subject, body=body) attach_pattern = re.compile(r'attach_file (\S+)', re.IGNORECASE) reply_pattern = re.compile(r'change_reply_address (\S+)', re.IGNORECASE) for line in self.script.split('\n'): result = attach_pattern.search(line) if result: email.attach_file(result.groups()[0]) else: result = reply_pattern.search(line) if result: email.receiver = result.groups()[0] email.sender = self.sender.username self.sender.send_email(email) return True
def populate(self): #populates inbox self.table.insert(self.emailToRow(Email('Help With Programming','12','zoe','Will you come over to the suite tomorrow and help me with a programming assignment?','chris'))) self.table.insert(self.emailToRow(Email('Dinner Tonight','102','zoe','Do you want to go off campus tonight to grab dinner?','tony'))) self.table.insert(self.emailToRow(Email('Happy Birthday!','40','zoe','Happy 21st birthday! We should go out and grab drinks later!','tony'))) self.table.insert(self.emailToRow(Email('Thai Food','265','zoe','Do you want to go to Ruk Mai down the street to get Pad Thai and maybe some shrimp fried rice?','tony'))) self.table.insert(self.emailToRow(Email('Self Note','93','zoe','Remember to finish your email system it is due on Friday for web prograaming class','zoe'))) self.db.commit()
def populate1(self): #populates outbox self.table1.insert(self.emailToRow(Email('Ice Cream','39','chris','Would you want to go to Daddy Dairy on Friday Night?','zoe'))) self.table1.insert(self.emailToRow(Email('Frisbee','10','chris','I am not going to be able to go to frisbee practive on Tuesday night','zoe'))) self.table1.insert(self.emailToRow(Email('Birthday Gift','138','chris','What should we get Erin for her birthday? I have no clue and I have been looking all over amazon.','zoe'))) self.table1.insert(self.emailToRow(Email('Computer Science','17','chris','I am bored in class','zoe'))) self.table1.insert(self.emailToRow(Email('Bachelor','827','tony','Do you want to watch the Bachelor on Sunday night? It is almost the season finale!','zoe'))) self.db1.commit()
def send_email(self): host = 'smtp.gmail.com' port = '587' user = '******' password = '' subject = 'Teste' body = 'Teste 123' to = '*****@*****.**' copied = ['*****@*****.**', '*****@*****.**'] self.email = Email(host, port, user, password, subject, body, to, copied) self.email.configs() self.email.message() self.email.html() self.email.attachment() self.email.send()
def manage_accounting(self, file): if not self.user_data.get('is_admin') and is_protected_file(file): self.client.send(str.encode('550 File unavailable.')) return False target_file_size = os.stat(file).st_size if accounting.enable: # Read config file with open("config.json", "r") as config_file: data = config_file.read() # Parse the data data_obj = json2obj(data) # Find user (index, current_user) = next( ((i, x) for i, x in enumerate(data_obj.accounting.users) if x.user == self.user_data.get('name')), None) if not current_user: pass else: # In this case user has not enough data if target_file_size > int(current_user.size): self.client.send( str.encode('425 Can\'t open data connection.')) return False else: with open('config.json', 'r+') as f: new_data = json.load(f) new_size = int(current_user.size) - target_file_size new_data['accounting'].get('users')[index]['size'] = \ str(new_size) f.seek(0) json.dump(new_data, f, indent=4) f.truncate() # remove remaining part if current_user.alert and new_size < data_obj.accounting.threshold: email = Email(current_user.email, current_user.user) email.send_internet_data_notification( data_obj.accounting.threshold) return True
def newMessage(): dao = OutboxDao() if ('back' in request.form): return redirect(url_for('inbox')) if ('submit' in request.form): if (request.form['recepient'] is not None) and (request.form['new_message'] is not None): if (isValidRecepient(request.form['recepient'])): idNum = dao.determineId() newemail = Email(str(request.form['subject']), str(idNum), str(request.form['recepient']), str(request.form['new_message']), str(session['userid'])) dao.insertOutbox(newemail) #also submit into other users inbox #dao.ToRecepient(newemail) return redirect(url_for('outbox')) else: return render_template('invalidview.html', **locals()) return render_template('newMessage.html', **locals())
def rowToEmail(self, row): email = Email(row['subject'], row['Num'], row['recepient'], row['message'], row['sender']) return email
from emails import Email from classifier import Bayes Email.load_emails() Bayes.train(Email.emails_list) ham_list = list(Bayes.ham_words_dict.items()) ham_list = sorted(ham_list, key=lambda entry: entry[1]) print(ham_list[-10:]) spam_list = list(Bayes.spam_words_dict.items()) spam_list = sorted(spam_list, key=lambda entry: entry[1]) print(spam_list[-10:])
import unittest from emails import Email, reply_to_parent, subject_parent, get_subject email1 = Email("1", None, "2017-11-02 00:00:00+00:00", "*****@*****.**", ["*****@*****.**"], "test") email2 = Email("2", None, "2017-11-02 01:00:00+00:00", "*****@*****.**", ["*****@*****.**"], "test") email3 = Email("3", "1", "2017-11-02 02:00:00+00:00", "*****@*****.**", ["*****@*****.**", "*****@*****.**"], "test") email4 = Email("4", "", "2017-11-02 03:00:00+00:00", "*****@*****.**", ["*****@*****.**"], "test") email5 = Email("5", "", "2017-11-02 04:00:00+00:00", "*****@*****.**", ["*****@*****.**"], "re: test") email6 = Email("6", "", "2017-11-02 05:00:00+00:00", "*****@*****.**", ["*****@*****.**"], "fw: test") mails = [email1, email2, email3, email4, email5, email6] class MyTest(unittest.TestCase): def test_no_parent(self): self.assertEqual(reply_to_parent(email1, mails), None) def test_reply_to(self): self.assertEqual(reply_to_parent(email3, mails).message_id, "1")
def populate2(self): #populates trash self.table2.insert(self.emailToRow(Email('Welcome!','1234','chris','Welcome to Zmail! So glad you can join our community! ','zmail'))) self.db2.commit()
def populate2New(self,username): #populates inbox Num = self.determineId() self.table.insert(self.emailToRow(Email('Welcome',str(Num),str(username),'This is your trash. This is where all the deleted messages from your outbox and inbox come to until you delete them forever.','Zmail Team'))) self.db.commit()
def populate1New(self,username): #populates new outbox Num = self.determineId() self.table.insert(self.emailToRow(Email('Welcome',str(Num),str(username),'This is your outbox where you can see all the messages you have sent.','Zmail Team'))) self.db.commit()
def populateNew(self,username): #populates inbox Num =self.determineId() self.table.insert(self.emailToRow(Email('Welcome',str(Num),str(username),'Welcome To Zmail! We are so glad to have you be a part of our community!','Zmail Team'))) self.db.commit()