def reply_comands(para, asunto = "Comando recibido"): m = Mail(para, asunto) m.create_initialize_server() m.login() if (asunto == "INFO"): m.attach_file() m.send_mail() m.quit_server()
def send_old_msg(path): l_files = ls1(path) if (len(l_files) <= 1): return else: m = Mail(TO_EMAIL, "Fallas remanentes") m.create_initialize_server() m.login() if (ARCH_DIA in l_files): l_files.remove(ARCH_DIA) for f in l_files: m.attach_file(f) remove(path + f) m.send_mail() m.quit_server()
logging.info("The scrapping is completed for the item '" + str(item[0]) + "'") logging.info("Old price : " + str(item[2][len(item[2]) - 1]) + "\nNew price : " + str(scraping.price)) except Exception as error: logging.warning("Error in the scrapper ->") logging.warning(error) if (scraping.price == 'Épuisé' & scraping.price != item[2][len(item[2]) - 1]): print('no') logging.info('Price is sold out') mail = Mail(item[5]) mail.send_mail(item[4], str(item[2][len(item[2]) - 1]), 'SOLD OUT', item[3]) scraping.price = 0.0 logging.info("Updating of the price for " + str(item[0]) + " in the database...") query = ("UPDATE item " + "SET prix = array_append(prix, " + str(scraping.price) + ")" + ", date_up = CURRENT_DATE" + " WHERE id_item = " + str(item[0])) cur.execute(query) elif (float(scraping.price) < float( item[2][len(item[2]) - 1])) & (float(scraping.price) != 0): mail = Mail(item[5]) mail.send_mail(item[4], str(item[2][len(item[2]) - 1]),
# New Mail() instance MM = Mail() # Get hostname host = socket.gethostname() # Create log file logging.basicConfig(filename="logs/log.txt", level=logging.INFO, format='%(asctime)s:%(message)s') while 1 == 1: res = os.popen("netstat -ano | grep SYN_RECV | awk {'print $4,$5'} | awk -F: {'print $1,$2'} | sort -k 3 | uniq -c | sort -k 1 | tail -1").read() if res != "": str = res.rstrip() logging.info(str) # Transform a string into an array arr = str.split() # If the first element of array it's >= 50 SynFB alert the admin mail configured at the top of this script. if int(arr[0]) >= 50: # Get timestamp with email format header = email.utils.formatdate(localtime=True) # Compile content of message msg = "%s - %s have %s SYN packets into netstat. Manually intervene." % (header, arr[3], arr[0]) # Create message for send this one with send_mail messaggio = MM.crea_messaggio_mail(header, DEST, "SYN - %s", msg) % host # Send alert mail MM.send_mail(SMTP, PORT, FROM, PWD, DEST, messaggio) print ("Mail sended") else: continue time.sleep(40)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import smtplib import time import imaplib import sys import email from Mail import Mail from manejador_salidas import Manejador_Salidas FROM_EMAIL = '*****@*****.**' TO_EMAIL = '*****@*****.**' FROM_PWD = 'edi@pru01' SMTP_SERVER = 'imap.gmail.com' m = Mail(TO_EMAIL, "Fallas" + " " + time.strftime("%d/%m/%y")) m.create_initialize_server() m.login() m.attach_file() m.send_mail() m.quit_server()
message['Date'] = formatdate() current_file_size = os.path.getsize( current_file_name) / 1000 / 1000 previous_file_size = os.path.getsize( previous_file_name) / 1000 / 1000 if current_file_size + previous_file_size <= 25: message.attach(MIMEText('今回')) current = MIMEBase('image', 'png') file = open(current_file_name, 'rb+') current.set_payload(file.read()) file.close() encoders.encode_base64(current) message.attach(current) message.attach( MIMEText('---------------------------------------------')) message.attach(MIMEText('前回')) previous = MIMEBase('image', 'png') file = open(previous_file_name, 'rb+') previous.set_payload(file.read()) file.close() encoders.encode_base64(previous) message.attach(previous) else: message.attach(MIMEText('差分あり(ファイルサイズが大きいため添付不可)')) mail.send_mail(to_address, message)