/bin/dash does not recognize the source command.
[mail.git] / savemail.py
1 #!/usr/bin/python
2 # -*- encoding: utf-8 -*-
3 # This script takes email mesages from stdin and
4 # saves them in a maildir.
5
6 # Copyright (C) 2014 Gabriel PĂ©rez-Cerezo <gabriel@gpcf.eu>
7 # See LICENSE file for license details.
8
9 import sys, mailbox
10 from shutil import move
11 from os import path, listdir, popen
12 # read configuration from config file.
13 maildir = popen(". $HOME/.mail_config.sh; echo $queue").read()[:-1]
14 md = mailbox.Maildir(maildir)
15 md.add(sys.stdin.read())
16
17 for i in listdir(path.join(maildir, "new")) :
18 # move the messages into the 'cur' folder. This prevents Wanderlust
19 # from messing with the messages.
20 move(path.join(maildir, "new", i), path.join(maildir, "cur", i))
21