def ftpUpload(fileName, save, serverComm): upload_start_time = time.time() ftp = ftplib.FTP('') ftp.connect(keys.IP_ADDRESS_CLIENT,keys.PORT) ftp.login(keys.USER[0],keys.PASSWORD[0]) transfer_size = 0 # Get size of data being uploaded # for file in fileName: file = fileName transfer_size += os.path.getsize(file) ftp.storbinary('STOR '+file,open(file,'rb')) ftp.quit() upload_end_time = time.time() upload_time = upload_end_time - upload_start_time # Upload speed in megabytes per second upload_speed = (transfer_size / 1000000) / upload_time save.save_upload_speed(upload_speed) rem_storage_percent = serverComm.get_rem_percentage("./") if rem_storage_percent > 85: smtp.send("VBAC NAS Storage Message", "Your VBAC NAS unit is currently at %s percent used." % rem_storage_percent) return
def consume(): bouquet = config.bouquet bRef = bouquets.getBRef(bouquet) if bouquet else bouquets.getDefaultBRef() if config.debug: print("Using bRef: " + bRef) terms = [term.parse(arg) for arg in config.popArgs(1)] if config.debug: for item in terms: print("Filtering: " + unicode(item)) response = utils.requestJson("epgmulti", params={"bRef": bRef}) timeTable = timetable.of(response["events"], terms) if config.skipNotified: notified = config.createNotified() timeTable.notified(notified, config.emailTo if config.emailTo else "console") notified.store() if len(timeTable) == 0: print("No (new) items found.") elif config.emailTo: if config.debug: print("Sending result to: " + config.emailTo) smtp.send(config.emailTo, "OpenWebIF Client", timeTable.toHumanReadable(), timeTable.toHtml()) else: print(timeTable.toHumanReadable())
def consume(): bouquet = config.bouquet bRef = bouquets.getBRef(bouquet) if bouquet else bouquets.getDefaultBRef() if config.debug: print("Using bRef: " + bRef) intersections = map(compileIntersections, config.popArgs(1)) if config.debug: for intersection in intersections: print("Filtering: " + formatIntersection(intersection)) response = utils.requestJson("epgmulti", params={"bRef": bRef}) result = u"" if intersections == None or len(intersections) == 0: for event in response["events"]: result += report(event) else: for event in response["events"]: matches = matching(intersections, event) if matches: result += report(event, matches) if config.emailTo: if config.debug: print("Sending result to: " + config.emailTo) smtp.send(config.emailTo, "OpenWebIF Client", result) else: print(result)
def do_GET(self): query_string = urlparse(self.path).query fields = parse_qs(query_string) if query_string else {} min_fields = {"sender", "recipient"} if set(fields.keys()).issuperset(min_fields): domain = "google.com" sender = fields.get("sender", [""])[0] send_name = fields.get("name", [""])[0] recipient = fields.get("recipient", [""])[0] subject = fields.get("subject", [""])[0] message = fields.get("message", [""])[0] smtp.send(domain, sender, send_name, recipient, subject, message) return http.server.SimpleHTTPRequestHandler.do_GET(self)
def sendEmail(debug): bodyf = open("recents.txt", "r+") body = [] nextl = bodyf.readline() body.append(nextl) while len(nextl) > 0: print(nextl) nextl = bodyf.readline() body.append(nextl) bodyf.close() bodyf = open("recents.txt", "w+") bodyf.write("") bodyf.close() if debug: for r in debrecipients: smtp.send(body, r) else: for r in recipients: smtp.send(body, r) return 0
def task(): companies = [] message = '' # iterate through multidimentional pages dictionary for key, data in pages_dict.items(): url = data['url'] page = http_get(url) soup = BeautifulSoup(page.content, 'html.parser') availability = eval(data['availability']) condition = data['condition'] # appends job/apprenticeship info to email message string if availability is detected if condition not in availability: companies.append('\n' + key + '\n') companies.append("Link: " + url + '\n') message = ''.join(companies) if companies: smtp.message += message smtp.send()
def deliver_smtp(self, header, body, fromm, smtp): tmpfile = open(tempfile.mktemp(), 'w+') os.chmod(tmpfile.name, 600) if self.__class__.__name__ != "Pop3Server": tmpfile.write(header) tmpfile.write(self.process_body(body)) spamreject = smtp.send(tmpfile, self.optresend, self.towho) if spamreject != None: if spamreject[1] != "": aprint(_("The SMTP rejected the message using a configured SMTPSpamCode (%d): Deleting it from the remote server (SMTP: %s)") % (spamreject[0], spamreject[1]),general.RED) tmpfile.close() os.unlink(tmpfile.name)
def deliver_smtp(self, header, body, fromm, smtp): tmpfile = open(tempfile.mktemp(), 'w+') os.chmod(tmpfile.name, 0600) if self.__class__.__name__ != "Pop3Server": tmpfile.write(header) tmpfile.write(self.process_body(body)) spamreject = smtp.send(tmpfile, self.optresend, self.towho) if spamreject != None: if spamreject[1] != "": aprint(_("The SMTP rejected the message using a configured SMTPSpamCode (%d): Deleting it from the remote server (SMTP: %s)") % (spamreject[0], spamreject[1]),general.RED) tmpfile.close() os.unlink(tmpfile.name)
import smtp domain = input("Specify a domain or leave empty and press enter: ") if not domain: domain = "google.com" sender = input("From what email address should the email be sent? ") while not sender: sender = input("Please specify the sender's email address: ") send_name = input("What should the sender's name be? ") recipient = input("To what email address should the email be sent? ") while not recipient: recipient = input("Please specify the recipient's email address: ") subject = input("What should the subject line be? ") content = [] print( "Type the email message body below. End the message with a single period on a line." ) while True: line = input() if line == ".": break content.append(line) message = "\r\n".join(content) smtp.send(domain, sender, send_name, recipient, subject, message)
def test_full_storage(self): rem_storage_percent = 12 if rem_storage_percent < 15: smtp.send("VBAC NAS Storage Message", "Your VBAC NAS unit currently has %s percent of remaining storage." % rem_storage_percent) return
import config import smtp log = open('status.log', 'w') client = Client(config.account_sid, config.auth_token) for contact in config.userList: try: name = contact[0] number = contact[1] print(f'Messaging {name} at {number}...') message = client.messages \ .create ( body = config.body, from_= config.outbound_number, to = number ) log.write( f'SUCCESS - Message ID {message.sid} sent to {name} at {number}\n\n' ) except: log.write(f'FAILURE - Unable to message {name} at {number}\n\n') log.close() smtp.send()
def sendmail(): to = '*****@*****.**' subject = '报警' contect = 'this is测试 a test2' send(to, subject, contect)