Ejemplo n.º 1
0
 def send_email(email, subject, message):
     o365_auth = ('*****@*****.**', 'Notreset2017!')
     m = Message(auth=o365_auth)
     m.setRecipients(email)
     m.setSubject(subject)
     m.setBodyHTML(message)
     m.sendMessage()
     print("Email was send on {}, with message: {}".format(email, message))
Ejemplo n.º 2
0
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()
Ejemplo n.º 3
0
 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()
Ejemplo n.º 4
0
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()
Ejemplo n.º 5
0
    def send(self, subject, body, to=None):
        """
        Envia email
        :param subject: titulo de mensagem
        :param body: corpo do email
        :return: objeto de email
        """
        m = Message(auth=(self.user, self.pwd))
        emails = self.to_email if to is None else to

        for i in emails.split(';'):
            m.addRecipient(i)
        m.setSubject(subject)
        m.setBodyHTML(body)
        try:
            m.sendMessage()
        except Exception as e:
            self.error = f'Falha ao enviar o email{e}'
Ejemplo n.º 6
0
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()
Ejemplo n.º 7
0
        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()
Ejemplo n.º 9
0
def SendMail(sender, msg, subject, filenmame=None):

    outlook_config_data = cs.readConfig('outlook_mail')
    emailId = outlook_config_data.get('emailId')
    password = outlook_config_data.get('emailPassword')

    if emailId == None or password == None:
        cs.warn('unable to retrive mail cred')
        cs.reConfig('outlook_mail')
        return SendMail(sender, msg, subject, filenmame)

    authenticiation = (emailId, password)
    m = Message(auth=authenticiation)
    m.setRecipients(sender)
    m.setSubject(subject)
    m.setBodyHTML(msg)
    m.setSenderName()

    if filenmame:
        att = Attachment(path=filenmame)
        m.attachments.append(att)

    mailSendStatus = m.sendMessage()

    return mailSendStatus
Ejemplo n.º 10
0
    write_log(failMsg, log)
    failMsg += arcpy.GetMessages() + '\n'
    write_log(failMsg, log)
    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()