Esempio n. 1
0
def confirmation (m, key):
    recipient = wlemail.senders(m)[0]
    recipient_email = recipient[1]
    if not can_send_confirmation (recipient_email):
        wlelog.log (3, "Not sending duplicate confirmation to %s" % \
                    email.Utils.formataddr (recipient))
        return None
    wlelog.log (3, "Sending confirmation request to %s" % \
                email.Utils.formataddr (recipient))
    r = MIMEMultipart ()
    subject = m.get ('subject')
    if not subject: subject = '...'
    rsubject = '[confirm #%s] %s' % (key, wlemail.make_answer (subject))
    r['X-WLE-confirmation'] = 'yes'
    r['Precedence'] = 'bulk'
    rfrom = email.Utils.formataddr \
            ((wleconfig.config.get ('DEFAULT', 'myname'),
              confirmation_sender (m)))
    rto = email.Utils.formataddr (recipient)
    wlemail.complete_message (r, rfrom, rto, rsubject)
    try: r['In-Reply-To'] = m.get ('message-id')
    except: pass
    excuse = MIMEText (makeup_excuse (key), 'plain',
                       wleconfig.config.get ('DEFAULT', 'charset'))
    excuse['Content-Disposition'] = 'inline'
    r.attach (excuse)
    origin = MIMEMessage (m)
    origin['Content-Disposition'] = 'attachment'
    r.attach (origin)
    db = wledb.connect_db ()
    c = db.cursor ()
    c.execute ("insert into confirmations values ('%s', %f)" %
               (recipient_email, time.time ()))
    db.commit ()
    return r
Esempio n. 2
0
def confirmation(m, key):
    recipient = wlemail.senders(m)[0]
    recipient_email = recipient[1]
    if not can_send_confirmation(recipient_email):
        wlelog.log (3, "Not sending duplicate confirmation to %s" % \
                    email.Utils.formataddr (recipient))
        return None
    wlelog.log (3, "Sending confirmation request to %s" % \
                email.Utils.formataddr (recipient))
    r = MIMEMultipart()
    subject = m.get('subject')
    if not subject: subject = '...'
    rsubject = '[confirm #%s] %s' % (key, wlemail.make_answer(subject))
    r['X-WLE-confirmation'] = 'yes'
    r['Precedence'] = 'bulk'
    rfrom = email.Utils.formataddr \
            ((wleconfig.config.get ('DEFAULT', 'myname'),
              confirmation_sender (m)))
    rto = email.Utils.formataddr(recipient)
    wlemail.complete_message(r, rfrom, rto, rsubject)
    try:
        r['In-Reply-To'] = m.get('message-id')
    except:
        pass
    excuse = MIMEText(makeup_excuse(key), 'plain',
                      wleconfig.config.get('DEFAULT', 'charset'))
    excuse['Content-Disposition'] = 'inline'
    r.attach(excuse)
    origin = MIMEMessage(m)
    origin['Content-Disposition'] = 'attachment'
    r.attach(origin)
    db = wledb.connect_db()
    c = db.cursor()
    c.execute("insert into confirmations values ('%s', %f)" %
              (recipient_email, time.time()))
    db.commit()
    return r
Esempio n. 3
0
def vacation_message (m):
    db = wledb.connect_db ()
    recipient = wlemail.senders(m)[0]
    recipient_email = recipient[1]
    target = email.Utils.formataddr (recipient)
    c = db.cursor ()
    c.execute ("select stamp from vacation where email='%s'" % recipient_email)
    if c.rowcount > 0 and time.time () - float(c.fetchone()[0]) < \
       86400 * wleconfig.config.getint ('DEFAULT', 'vacation_days'):
        wlelog.log (8, "Not sending duplicate vacation message to %s" % target)
        return None
    c.execute ("insert into vacation values ('%s', %f)" %
               (recipient_email, time.time ()))
    db.commit ()
    my_name = wleconfig.config.get ('DEFAULT', 'myname')
    my_addr = wleconfirm.confirmation_sender (m)
    subject = m['subject'] or "..."
    subject = wleconfirm.decoded_header (subject)
    trimmed_subject = wlemail.canonical_subject (subject)
    t = open (wleconfig.config.get('DEFAULT', 'vacation_msg'), 'r').read() % \
        {'target_name' :    recipient[0],
         'target_email':    recipient_email,
         'target':          target,
         'subject':         subject,
         'trimmed_subject': trimmed_subject,
         'my_name':         my_name,
         'my_addr':         my_addr}
    r = MIMEText (t, 'plain', wleconfig.config.get ('DEFAULT', 'charset'))
    try: r['In-Reply-To'] = m.get ('message-id')
    except: pass
    rsubject = wlemail.make_answer (subject)
    r['Precedence'] = 'junk'
    rfrom = email.Utils.formataddr ((my_name, my_addr))
    wlelog.log (3, "Sending vacation message to %s" % target)
    wlemail.complete_message (r, rfrom, target, rsubject)
    wlemail.add_action (m, "Vacation message sent")
    return r