Beispiel #1
0
def try_mail(text, logtext, attachment=None, subject=None):
    ### Try send e-mail ###   
    log.clear(NAME)
    try:
        email(text, subject, attachment)  # send email with attachment from
        log.info(NAME, _(u'E-mail was sent') + ':\n' + logtext)
        if not options.run_logEM:
            log.info(NAME, _(u'E-mail logging is disabled in options...'))
        else:    
            logEM.save_email_log(subject or email_options['emlsubject'], logtext, _(u'Sent'))

    except Exception:
        log.error(NAME, _(u'E-mail was not sent! Connection to Internet not ready.'))
        logEM.save_email_log(subject or email_options['emlsubject'], logtext, _(u'E-mail was not sent! Connection to Internet not ready.'))
        if not options.run_logEM:
            log.info(NAME, _(u'E-mail logging is disabled in options...'))
            
        if email_options["emlrepeater"]: # saving e-mails is enabled  
            data = {}
            data['date'] = str(datetime.now().strftime('%d.%m.%Y'))
            data['time'] = str(datetime.now().strftime('%H:%M:%S'))   
            data['text'] = u'%s' % text
            data['logtext'] = u'%s' % logtext
            data['subject'] = u'%s' % email_options['emlsubject']
            data['attachment'] = u'%s' % attachment

            update_saved_emails(data)    # saving e-mail data to file: saved_emails.json
Beispiel #2
0
    def try_mail(self, text, attachment=None, subject=None):
        log.clear(NAME)
        try:
            email(text, attach=attachment)  # send email with attachment from
            log.info(NAME, _('Email was sent') + ':\n' + text)
            if not options.run_logEM:
                log.info(NAME, _('Email logging is disabled in options...'))
            logEM.save_email_log(subject or email_options['emlsubject'], text, _('Sent'))

        except Exception:
            log.error(NAME, _('Email was not sent!') + '\n' + traceback.format_exc())
            logEM.save_email_log(subject or email_options['emlsubject'], text, _('Unsent'))
            if not options.run_logEM:
                log.info(NAME, _('Email logging is disabled in options...'))
Beispiel #3
0
def send_email(msg):
    """Send email"""
    message = datetime_string() + ': ' + msg
    try:
        from plugins.email_notifications import email

        Subject = plugin_options['eml_subject']

        email(message, subject=Subject) # send email

        if not options.run_logEM:
           log.info(NAME, _('Email logging is disabled in options...'))
        else:        
           logEM.save_email_log(Subject, message, _('Sent'))

        log.info(NAME, _('Email was sent') + ': ' + message)

    except Exception:
        if not options.run_logEM:
           log.info(NAME, _('Email logging is disabled in options...'))
        else:
           logEM.save_email_log(Subject, message, _('Sent'))

        log.info(NAME, _('Email was not sent') + '! ' + traceback.format_exc())
Beispiel #4
0
def send_email(msg, msglog):
    message = datetime_string() + ': ' + msg
    Subject = plugin_options['emlsubject']
    try:
        email = None
        if plugin_options['eplug']==0: # email_notifications
            from plugins.email_notifications import email
        if plugin_options['eplug']==1: # email_notifications SSL
            from plugins.email_notifications_ssl import email
        if email is not None:        
            email(message, subject=Subject)
            if not options.run_logEM:
                log.info(NAME, _(u'Email logging is disabled in options...'))
            else:
                logEM.save_email_log(Subject, msglog, _('Sent'))
            log.info(NAME, _(u'Email was sent') + ': ' + msglog)

    except Exception:
        if not options.run_logEM:
           log.info(NAME, _(u'Email logging is disabled in options...'))
        else:
           logEM.save_email_log(Subject, msglog, _('Email was not sent'))

        log.info(NAME, _(u'Email was not sent') + '! ' + traceback.format_exc())