def report_error(self, error_message): """Send a specified message to the admininistrator via email (as specified in the settings)""" message = Message(auth=self.auth) message.setSubject('!! Email Processor Error !!') message.setBody(str(error_message)) message.setRecipients(str(self.settings.admin_email_addresses)) message.sendMessage()
def email(to, subject, body, path): authenticiation = ('email', 'password') m = Message(auth=authenticiation) m.setRecipients(to) m.setSubject(subject) m.setBody(body) att = Attachment(path=path) m.attachments.append(att) m.sendMessage()
def message(): # Basic variables for authorization: user = "******" # For shits and giggles... email = '*****@*****.**' pwd = 'yoursupersecretpassword' auth = (email, pwd) # Message object: m = Message(auth=auth) # Recipients m.setRecipients('I generally create a list and pass it through here.') # Subject: m.setSubject('Automation rules') # Body: m.setBody('Good morning, {}.\n\nHAL-9000'.format(user)) # Send: m.sendMessage()
def message(new_user): # Basic variables for authorization: email = config.EMAIL pwd = config.PW auth = (email, pwd) # Message object: m = Message(auth=auth) # Recipients m.setRecipients(new_user) # Subject: m.setSubject('Thanks for Signing Up') # Body: user = Users.query.filter_by(email=new_user).first() uname = user.usname name = user.name m.setBody( 'Hello, {}.\n\n Thanks for signing up for an account on PicShare.\n\nYour user name is: {}\n\nLogin and start sharing pictures!\n -Ava' .format(name, uname)) # Send: m.sendMessage()
at specified interval forever""" log.debug("Starting main loop") if self.main_thread and self.main_thread.isAlive(): # Stop the thread if it's already running log.debug("main loop already running") self.stop() self.main_thread = threading.Thread(target=self._run) self.main_thread.start() def stop(self): """Stop automatically checking messages""" log.debug("Stopping main loop") self.main_thread_stop.set() self.main_thread.join() if __name__ == "__main__": client = Client() client.auth = ('username', 'password') message = Message() message.setSubject('Test') message.setBody('This is a test message') message.setRecipients([{'EmailAddress': { 'Name': 'Craig', 'Address': '*****@*****.**'}}]) client.send_email(message) #client._run()
# temp: to avoid ssl error import urllib3 urllib3.disable_warnings() import password_list user = password_list.user password = password_list.password from O365 import Message authenticiation = (user, password) m = Message(auth=authenticiation) m.setRecipients(user) ### m.setSubject('test.') m.setBody('test.') m.sendMessage()
failMsg += '\nTraceback messages below.\n' write_log(failMsg, log) failMsg += traceback.format_exc().splitlines()[-1] write_log(failMsg, log) #send email from O365 import Message authentication = ('*****@*****.**', 'QPX123!!') #Send a summary using the send email function and the messages that have been created. if scriptSuccess == True: authentication = ('*****@*****.**', 'QPX123!!') m = Message(auth=authenticiation) m.setRecipients('*****@*****.**') m.setSubject = 'Geodatabase maintenance script summary.' m.setBody = recMsg + compressMsg + rebuildSystemMsg + analyzeSystemMsg + rebuildUserMsg + analyzeUserMsg write_log("Sending email report", log) m.sendMessage() else: authentication = ('*****@*****.**', 'QPX123!!') m = Message() m = Message(auth=authenticiation) m.setRecipients('*****@*****.**') m.setSubject = 'Geodatabase maintenance script failed.' m.setBody = failMsg write_log("Sending email report", log) m.sendMessage() print("Done.") write_log("Maintenance completed for {0} at {1}".format(Date, Time), log)