~mvo/unattended-upgrades/minimal-upgrades-speedup

« back to all changes in this revision

Viewing changes to unattended-upgrade

  • Committer: Michael Vogt
  • Date: 2013-02-12 05:33:32 UTC
  • Revision ID: michael.vogt@ubuntu.com-20130212053332-wus35b8xf8d4jlyn
simplify, thanks to Sam Morris

Show diffs side-by-side

added added

removed removed

Lines of Context:
597
597
def _send_mail_using_sendmail(to_address, subject, body):
598
598
    # format as a proper mail
599
599
    msg = Message()
 
600
    msg.set_payload(body)
 
601
    msg['Subject'] = subject
 
602
    msg['To'] = to_address
 
603
    # order is important here, Message() first, then Charset() 
 
604
    #  then msg.set_charset()
600
605
    charset = email.Charset.Charset("utf-8")
601
606
    charset.body_encoding = email.Charset.QP
602
607
    msg.set_charset(charset)
603
 
    encoded_body = charset.body_encode(body)
604
 
    msg.set_payload(encoded_body)
605
 
    msg['Subject'] = subject
606
 
    msg['To'] = to_address
 
608
    # and send it away
607
609
    sendmail = subprocess.Popen(
608
610
        [SENDMAIL_BINARY, "-oi", "-t"], stdin=subprocess.PIPE)
609
611
    sendmail.stdin.write(msg.as_string())