Ignore:
Timestamp:
7 Oct 2012, 08:32:45 (12 years ago)
Author:
Henrik Bettermann
Message:

Enable sending emails to several email addresses all the with the same rcpt_name (Import Manager, Clearance Officer ...).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/smtp.py

    r8382 r9306  
    149149    return MIMEText(text, 'plain', charset)
    150150
    151 def send_mail(from_name, from_addr, rcpt_name, rcpt_addr,
     151def send_mail(from_name, from_addr, rcpt_name, rcpt_addrs,
    152152              subject, body, config=None):
    153153    """Send mail.
    154154    """
    155155    # format message
     156    rcpt_addrs = rcpt_addrs.replace(' ','').split(',')
     157    body_to = ''
     158    for email in rcpt_addrs:
     159        body_to += '%s, ' % encode_address(email, rcpt_name)
    156160    body = encode_body(body)
    157161    body["From"] = encode_address(from_addr, from_name)
    158     body["To"] = encode_address(rcpt_addr, rcpt_name)
     162    body["To"] = body_to.strip(', ')
    159163    body["Subject"] = encode_header_item(subject)
    160164
    161165    mailer = getUtility(IMailService)
    162     result = mailer().send(from_addr, [rcpt_addr], body.as_string())
     166    result = mailer().send(from_addr, rcpt_addrs, body.as_string())
    163167    return result
Note: See TracChangeset for help on using the changeset viewer.