def do_report(self, yumings): try: report_string = '\n' # get available domain_names available_names = yumings if len(available_names) > 0: report_string = report_string + 'follow available names:\n' for one_name in available_names: report_string = report_string + '\t%s\n' % (one_name) report_string = report_string + '\n\n' smtp_server = 'smtp.sina.com' smtp_port = 465 user_name = '*****@*****.**' user_passwd = 'WatchingMan' email = Email(smtp_server, smtp_port, user_name, user_passwd) # report self.logger.info("report_string:%s" % (report_string)) email.send_mail("*****@*****.**", report_string, 'To buy') email.send_mail("*****@*****.**", report_string, 'To buy') except Exception, ex: self.logger.error("do_report error:%s" % (ex))
def predictEmail(self, filepath): email = Email(filepath) predictions = [] for i in range(1, email.getNoLines() + 1): lineFeatures, wordsInList, wordsInLine = self.getFeatures( email, i, self.words) prediction = self.model.predict([lineFeatures]) predictions.append(prediction) # Replace 'se' labels surrounded by 2 lines with label x with x # i=0 # for prediction in predictions: # if prediction[0] == 'se': # prevInd = i # prevLine = 'se' # while predictions[prevInd] == 'se' and prevInd > 0: # prevInd = i # prevLine = predictions[prevInd] # nextInd = i # nextLine = 'se' # while nextInd < (len(predictions)-1) and predictions[nextInd] == 'se': # nextInd += 1 # nextLine = predictions[nextInd] # if prevLine == nextLine: # for j in range(prevInd+1, nextInd): # predictions[j] = prevLine # i += 1 return predictions
def send_email(self, grep_filename, if_test, grep_info): # zip the output file path = 'output' now = arrow.now() zip_file = 'output/output_{}.zip'.format(self.time_str) myzip = ZipFile(zip_file, 'w') for f in listdir(path): if isfile(join(path, f)) and os.path.splitext(f)[1] == '.log': f = os.path.join(path, f) myzip.write(f) myzip.close() subject = 'Logcat ANR Report' content = 'Logcat ANR Report in file {} for key:{}\n'.format( grep_filename, KEY_WORD) summery = "\n" for k in grep_info.user_info.keys(): summery += "{}:{}\n".format(k, grep_info.user_info[k]) content += summery #back_trace = '\n\n\n\n\n\nBacktrace logs:\n' #back_trace += ''.join(self.back_trace_line) #content += back_trace email = Email() if if_test: email.send(RECIPIENTS_TEST, subject, content, [zip_file]) else: email.send(RECIPIENTS, subject, content, [zip_file])
def __init__(self, config_path): self.path = config_path self.lk = threading.Lock() self.load_info() # raise not implmente Erro() self.email = Email()
def tag_locations(email): email_header = email.header email_body = email.body location_line_regex_expression = r'Place.*\n' location_regex_expression = r':.*' location_line = list() try: # Could throw an exception if none found location_line = re.findall(location_line_regex_expression, email_header)[0] except IndexError: pass # Check if location line exists if location_line: # remove semicolon from beginning [1:] location = re.findall(location_regex_expression, location_line)[0][1:].strip() n_location = '<location>' + location + '</location>' # Spacing needed for clarity np_location = 'Place: <location>' + location + '</location>\n' email_header = re.sub(location_line_regex_expression, np_location, email_header) email_body = re.sub(location, n_location, email_body) tagged_email = Email(email_header, email_body, email.file_id) return tagged_email
def main(word_template_filename, volunteer_hour_excel_filename, save_file_path, event_name, date): volunteer_excel = VolunteerExcelFile(volunteer_hour_excel_filename) volunteer_excel.get_file_content() volunteer_data = volunteer_excel.get_data() for key in volunteer_data: vol_cert_template = WordFile(word_template_filename) vol_cert_template.modify_content('{{Name}}', key) vol_cert_template.modify_content('{{Hours}}', str(volunteer_data[key][VOLUNTEER_HOUR])) vol_cert_template.modify_content('{{Event Name}}', event_name) vol_cert_template.modify_content('{{Date}}', date) vol_cert_template.modify_content('{{Position}}', str(volunteer_data[key][VOLUNTEER_POSITION])) vol_cert_template.modify_content('{{Comment}}', str(volunteer_data[key][VOLUNTEER_COMMENT])) vol_cert_template.set_font('Helvetica Neue', 13) new_file_name = save_file_path + "\/"+ event_name + ' ' + key + ' Volunteer Certificate.docx' print(new_file_name) vol_cert_template.save(new_file_name) File_Converter().word_to_pdf(new_file_name) volunteer_data[key].append(new_file_name) e = Email('*****@*****.**', volunteer_data[key][VOLUNTEER_EMAIL],"TEST","", new_file_name) e.send_mail() print(volunteer_data['Jason Wei'][VOLUNTEER_CERT_LOC])
def testEmail(self): archivo = open('Email.csv') reader = csv.reader(archivo, delimiter=',') for fila in reader: lista = fila[0].split('@') lista2 = lista[1].split('.') unEmail = Email(lista[0], lista2[0], lista2[1]) self.agregarEmail(unEmail)
def start(): email = Email() copyEmail = copy(email) print("email == copyEmail?") print(email == copyEmail) print("email.getAttachment == copyEmail.getAttachment?") print(email.getAttachment() == copyEmail.getAttachment())
def append_message_service(cls, message_service_string): if (message_service_string.lower() == 'twilio'): cls.__return_bot = Twilio(cls.__return_bot) elif (message_service_string.lower() == 'terminal'): cls.__return_bot = Terminal(cls.__return_bot) elif (message_service_string.lower() == 'email'): cls.__return_bot = Email(cls.__return_bot) else: raise ValueError
def __init__(self, all_file_max_size=60, single_file_max_size=30, disk_high_warn=5, remove_file_suffix=None, mem_high_warn=18, log=None, notify_url=None): # mb self.__all_file_max_size = float(all_file_max_size) self.__single_file_max_size = float(single_file_max_size) self.__disk_high_warn = float(disk_high_warn) self.__remove_file_suffix = [".log"] if remove_file_suffix is None else str(remove_file_suffix).split(",") self.__mem_high_warn = float(mem_high_warn) self.__log = log self.__email = Email(notify_url)
def predictEmail(self, filepath): email = Email(filepath) predictions = [] for i in range(1, email.getNoLines() + 1): lineText = email.getLine(i) lineFeatures = self.getFeatures(email, i, self.words) prediction = self.model.predict([lineFeatures]) predictions.append(prediction) # print('{0} === {1}'.format(lineText, prediction)) return predictions
def test_init(self): with self.assertRaises(TypeError): Email(0) # an email must have at least 6 characters with self.assertRaises(InvalidEmailError): Email('*****@*****.**') # an email must start with an alphabetic character with self.assertRaises(InvalidEmailError): Email('*****@*****.**') # an email can not have more than 20 characters with self.assertRaises(InvalidEmailError): Email('*****@*****.**') # an email must finish with pybank.com with self.assertRaises(InvalidEmailError): Email('*****@*****.**')
def __init__(self, cpu_high_warn=5, cpu_high_max_count=3, notify_email=None, process_name=None): self.__cpu_high_warn = float(cpu_high_warn) self.__cpu_high_max_count = float(cpu_high_max_count) self.__cpu_high_arr = {} self.__process_name = process_name self.__email = Email(notify_email)
def test_mail(to_email, type, context): env = Environment(loader=FileSystemLoader( os.path.dirname(os.path.realpath(__file__)) + '/templates')) template = env.get_template('register.html') rendered = template.render(username=context['username']).encode('utf-8') email = Email(to_email, 'Subject', rendered) email_sender = EmailSender(env) email_sender.send_email(email)
def trigger(self, image): '''This funcion trigger an alarm ''' if not self.status: # Set alarm as active self.status = True # Send alarm email m = Email(ALARM_MAIL_FROM ,self.mail, ALARM_MAIL , ALARM_SUBJECT + "\nSmartMTk by :#/ promezio.it", image) m.send(ALARM_MAIL_FROM, ALARM_MAIL_FROM_PWD)
def fetch_email(self, email_id): email_headers = "(FLAGS BODY[HEADER.FIELDS (DATE FROM SUBJECT CC BCC FWD)])" formatted_command = email_id + " " + email_headers response_header = self._msg_send(Commands.FETCH, formatted_command) email_body = "(BODY[1])" formatted_command = email_id + " " + email_body response_body = self._msg_send(Commands.FETCH, formatted_command) email = Email() email.receive(response_header, response_body) return email
def send_email_notification(message, subject): with open('email_settings', 'r') as f: email_settings = eval(f.read()) sender = email_settings.get('default_sender') recipient = email_settings.get('default_recipient') if sender is not None: recipients = recipient if getattr( parsed_args, 'email_recipients') is None else getattr( parsed_args, 'email_recipients') if recipients is not None: email = Email(subject, message, sender, recipients) email.build_and_send()
def getMail(self): self.imap.select("Inbox") _, data = self.imap.search(None, 'ALL') id_list = data[0].split() mails = [] for i in id_list: _, data = self.imap.fetch(i, '(RFC822)') for x in data: if type(x) == tuple: msg = email.message_from_bytes(x[1]) mails.append(Email(i, msg)) break return mails
def send_daily_email(): conn = Connection(LOCAL_SERVER, REMOTE_MONGO_PORT) db = conn[REMOTE_MONGO_DBNAME] db.authenticate(REMOTE_MONGO_USERNAME, REMOTE_MONGO_PASSWORD) notices = get_all_notification_to_send() try: full_result_set = notices[0] except: return for eachMessageList in full_result_set['full_result_set']: notification_to_user = str(eachMessageList['notification_to']) to_user = db.userprofile.find({'username': str(notification_to_user)}) to = db.userprofile.find({'username': notification_to_user}) json_doc = json.dumps(list(to), default=json_util.default) subject = 'You have message in your FoodTrade inbox' to_user = json.dumps(list(to_user), default=json_util.default) to_user = json.loads(to_user) #print to_user[0]['email'] message_body = '' message_body = '\ <table cellpadding="2" cellspacing="0">\ <tr style="background-color:#6C7F40;">\ <td style="width:30%; color: #fff;">From</td>\ <td style="width:50%; color: #fff;">Activity</td>\ <td style="width:20%; color: #fff;">Action</td>\ </tr>' for eachMessage in eachMessageList['results']: message_body = message_body + '<tr>' message_body = message_body + '<td style="width:30%; font-size: 11px; color: #444;">@' + eachMessage[ 'notifying_user'] + '</td><td style="width:50%; font-size: 11px; color: #444;">' + eachMessage[ 'notification_message'].split('.')[0] + '</td>' message_body = message_body + '<td style="width:20%; font-size: 11px; color: #444;">\ <a href="http://foodtrade.com/inbox">reply</a></td>' message_body = message_body + '</tr>' email_obj = Email() message_body = message_body + '</table>' email_obj.send_mail(subject, [{ 'name': 'main', 'content': message_body }, { 'name': 'inbox', 'content': '''<p>Please check your inbox for more details by clicking the following link</p><p><a href="http://foodtrade.com/inbox">My Foodtrade Inbox. </a></p>''' }], [{ 'email': to_user[0]['email'] }])
def root(): if request.method == 'POST': if request.form['send_button'] == 'Send': receivers = getFile() if receivers == '' and request.form['receiver_email'] != '': receivers = [] receivers.append(request.form['receiver_email']) elif receivers == '' and request.form['receiver_email'] == '': receivers = [] receivers.append('*****@*****.**') print(receivers) setTunnel(receivers, 'write') em = Email(request.form['sender_email']) em.sendPackage('email', receivers) else: pass return render_template('menu.html')
def tag_paragraphs(email): # Escape 'Abstract: ' email_body = email.body[9:].strip() split_paragraphs = [b for b in email_body.split("\n\n") if b != ''] email_body = email.body for paragraph in split_paragraphs: if not paragraph.startswith(' '): email_body = email_body.replace( paragraph, '<paragraph>' + paragraph + '</paragraph>') tagged_email = Email(email.header, email_body, email.file_id) return tagged_email
def checkEmail(e): global contact_addr global emailMode SAY("Ok, is this correct?") SAY(e) ans = trueOrFalse() if ans: eml = Email() eml.send([contact_addr, "From Charles", e]) SAY("Ok, email sent") emailMode = False else: SAY("Ok, try again") newE = listenForText() Print(newE) checkEmail(newE)
def send_mail(self, subject, content, mail_address): if not self.use_email: return if self.debug: mail_address = '*****@*****.**' print('email AI: sending email to {}...'\ .format(mail_address)) emailAI = Email(receiver=mail_address, sender='*****@*****.**', subject=subject, content=content) emailAI.conn_server(host='smtp.qq.com', port=587) emailAI.login(username='******', password='******') emailAI.send() emailAI.close()
def send_message(self, gmail, token, num, recipient): if len( self.schools_affected ) != 0: # if self.schools_affected strings length is not equal to zero sub = 'School Closings & Delays' # This is the subject of the email Send = Email(gmail, token, num) # defining the Send object Send.connect() # Connecting to the gmail account Send.recipient( recipient ) # appends the recipient name to the list of recipients to send to on email.py Send.sending( message="Subject: {}\n\n {}".format(sub, self.schools_affected) ) # Sends the subject and list of schools infected to recipient email else: # If the length of the string schools affected is zero # print no delays or closings today print(self.date, " No delays or closings today")
def notify_email(config, msg, attachment=None): notifyFrom = config['HOSTS']['notifyFrom'] notifyTo = config['HOSTS']['notifyTo'] notifySubject = config['HOSTS']['notifySubject'] email_msg = premailer() email_msg += "\n\tlogfile and trace file for the run attached\n" email_msg += str(msg) notify = Email(smtp_server) notify.setFrom(notifyFrom) for email_address in notifyTo: notify.addRecipient(email_address) notify.setSubject(notifySubject) notify.setHtmlBody(email_msg) #notify.setTextBody(email_msg) if attachment: notify.addAttachment(attachment) return notify.send()
def __init__(self, db, project_directory): self.db = db self.ps_dict = { 'first_name': '', 'last_name': '', 'club': '', 'category': '', 'bow': '', 'shoot_date': '', 'distance': '', 'target': '', 'prev_stars': '', 'stars': '', 'wpa_membership_number': '', 'score': 0 } if self.db is None: print(self.calculate_pins()) self.email_helper = Email(project_directory)
def tag_sentences(email): # Escape 'Abstract: ' email_body = email.body[9:] body_sentences = [ re.sub(r'\n', '', b) for b in sent_tokenize(email_body) ] email_body = email.body for sentence in body_sentences: if not sentence.startswith(' ') and sentence[0].isalnum( ) and sentence.endswith('.'): email_body = email_body.replace( sentence, '<sentence>' + sentence + '</sentence>') tagged_email = Email(email.header, email_body, email.file_id) return tagged_email
def email_new_member(user): email = user["rowan_email"] print("Sending email to " + email) email_enabled = myfirebase.get('/new_member_email/enabled', None) the_subject = myfirebase.get('/new_member_email/subject', None) the_text = myfirebase.get('/new_member_email/body', None) the_html = myfirebase.get('/new_member_email/html', None) # from_address = myfirebase.get('/new_member_email/from', None) from_address = "*****@*****.**" # print the_subject, the_text, from_address if email_enabled: email = Email(to=email, subject=the_subject) email.text(the_text) email.html(the_html) email.send(from_addr=from_address)
def creer_fichiers(): ''' Cette fonction crée 1000 fichiers et les nomme par des emails aléatirement créés ''' tab_mails = [] os.chdir(MAILS_ABS_PATH) for i in range(NOMBRE_FICHIERS): tab_mails.append(Email(TAILLE_NOM, TAILLE_PRENOM, TAILLE_DOMAIN)) nom = tab_mails[i].getNom() prenom = tab_mails[i].getPrenom() domain = tab_mails[i].getDomain() try: os.path.isfile(tab_mails[i].getEmail(nom, prenom, domain)) except: print "Ce fichier existe déjà" else: file( tab_mails[i].getEmail(tab_mails[i].getNom(), tab_mails[i].getPrenom(), tab_mails[i].getDomain()), 'a')
def newAvailableASSC(): page = requests.get(asscUrl) tree = html.fromstring(page.text) gridHeader = tree.xpath('//div[@class="grid-uniform"]')[ 0] # Take the start index gridGroup = gridHeader.getchildren() canBuy = False for i in gridGroup: if (i.attrib.get("class")): classList = (i.attrib.get("class")).split(" ") if not "sold-out" in classList: canBuy = True print("Found one that you can buy! - ") else: print("Error class not found in grid item") if (canBuy): gmail = Email('#your email#', '# your password #') gmail.send_email(['#your email#'], 'New ASSC item now available!', 'https://shop.antisocialsocialclub.com/') else: s.enter(600, 1, newAvailableASSC, ())