projects
/
smailq.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
smailq: Look for global configuration under /etc
[smailq.git]
/
smailq
diff --git
a/smailq
b/smailq
index c42b98010829077e6910abe41ffd6b7f3da5366a..d719d43a283e916d2a15299ba3a5218242eee328 100755
(executable)
--- 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 = {}
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, "r
b
") as f:
+ mail = f.read
().decode('utf8', 'replace').split
lines()
for l in mail:
if l.startswith("Subject:"):
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("To:"):
info['to'] = l[3:].strip()
break
+ if l.startswith("Cc:"):
+ info['to'] = l[3:].strip()
return info
return info
@@
-230,7
+234,7
@@
class MailQueue:
# Read the mail
mailfn = self.conf.getmailfn(id)
# Read the mail
mailfn = self.conf.getmailfn(id)
- mailf = open(mailfn, "r")
+ mailf = open(mailfn, "r
b
")
# Read the options
msaargsfn = self.conf.getmsaargsfn(id)
# Read the options
msaargsfn = self.conf.getmsaargsfn(id)
@@
-280,7
+284,7
@@
class MailQueue:
# Write the mail
mailfn = self.conf.getmailfn(id)
# Write the mail
mailfn = self.conf.getmailfn(id)
- with open(mailfn, "w") as f:
+ with open(mailfn, "w
b
") as f:
f.write(mail)
# Write the options
f.write(mail)
# Write the options
@@
-391,7
+395,7
@@
OPTIONS:
if __name__ == "__main__":
if __name__ == "__main__":
- conffn
= os.path.expanduser("~/.smailq.conf")
+ conffn
_list = [os.path.expanduser("~/.smailq.conf"), "/etc/smailq.conf"]
cmd = "--list"
nooptargs = []
cmd = "--list"
nooptargs = []
@@
-412,7
+416,7
@@
if __name__ == "__main__":
'--deliver']:
cmd = opt
elif opt in ['-C', '--config']:
'--deliver']:
cmd = opt
elif opt in ['-C', '--config']:
- conffn
= arg
+ conffn
_list = [arg]
elif opt in ['-v', '--verbose']:
verbose = True
quiet = False
elif opt in ['-v', '--verbose']:
verbose = True
quiet = False
@@
-428,8
+432,9
@@
if __name__ == "__main__":
sys.exit(os.EX_USAGE)
# Reading config file
sys.exit(os.EX_USAGE)
# Reading config file
- if not os.path.isfile(conffn):
- printerr("No such config file:", conffn)
+ conffn = next((f for f in conffn_list if os.path.isfile(f)), None)
+ if conffn is None:
+ printerr("No config file found: " + str(conffn_list))
sys.exit(os.EX_IOERR)
conf = None
try:
sys.exit(os.EX_IOERR)
conf = None
try:
@@
-454,7
+459,7
@@
if __name__ == "__main__":
mq = MailQueue(conf)
if cmd == "--send":
mq = MailQueue(conf)
if cmd == "--send":
- mail = sys.stdin.read()
+ mail = sys.stdin.
buffer.
read()
mq.sendmail(mail, nooptargs)
elif cmd == "--list":
mq.listqueue()
mq.sendmail(mail, nooptargs)
elif cmd == "--list":
mq.listqueue()