X-Git-Url: https://git.sthu.org/?p=smailq.git;a=blobdiff_plain;f=smailq;h=def0a0a9c312d490727d2f455104d416f2a4e5e6;hp=c42b98010829077e6910abe41ffd6b7f3da5366a;hb=072170e749aa6a7a62ac99f25b5cac9e066ad2c5;hpb=6033099316d2081a9502bb066908a1ac670e519b diff --git a/smailq b/smailq index c42b980..def0a0a 100755 --- a/smailq +++ b/smailq @@ -160,9 +160,11 @@ class MailQueue: info = {} info['ctime'] = time.ctime(os.path.getctime(mailfn)) info['size'] = os.path.getsize(mailfn) + info['to'] = "" + info['subject'] = "" - with open(mailfn, "r") as f: - mail = f.readlines() + with open(mailfn, "rb") as f: + mail = f.read().decode('utf8', 'replace').splitlines() for l in mail: if l.startswith("Subject:"): @@ -173,6 +175,8 @@ class MailQueue: if l.startswith("To:"): info['to'] = l[3:].strip() break + if l.startswith("Cc:"): + info['to'] = l[3:].strip() return info @@ -230,7 +234,7 @@ class MailQueue: # Read the mail mailfn = self.conf.getmailfn(id) - mailf = open(mailfn, "r") + mailf = open(mailfn, "rb") # Read the options msaargsfn = self.conf.getmsaargsfn(id) @@ -280,7 +284,7 @@ class MailQueue: # Write the mail mailfn = self.conf.getmailfn(id) - with open(mailfn, "w") as f: + with open(mailfn, "wb") as f: f.write(mail) # Write the options @@ -454,7 +458,7 @@ if __name__ == "__main__": mq = MailQueue(conf) if cmd == "--send": - mail = sys.stdin.read() + mail = sys.stdin.buffer.read() mq.sendmail(mail, nooptargs) elif cmd == "--list": mq.listqueue()