Further improved software
[mail.git] / savemail.py
1 #!/usr/bin/python
2 # This script takes email mesages from stdin and
3 # saves them in a maildir.
4 # Copyright (c) 2014 Gabriel Perez-Cerezo <http://gpcf.eu>
5
6 import sys, mailbox
7 from shutil import move
8 from os import path, listdir, popen
9 # read configuration from config file.
10 maildir = popen(". $HOME/.mail_config.sh; echo $queue").read()[:-1]
11 md = mailbox.Maildir(maildir)
12 md.add(sys.stdin.read())
13
14 for i in listdir(path.join(maildir, "new")) :
15 # move the messages into the 'cur' folder. This prevents Wanderlust
16 # from messing with the messages.
17 move(path.join(maildir, "new", i), path.join(maildir, "cur", i))
18