summaryrefslogtreecommitdiff
path: root/alot/account.py
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2011-08-30 13:13:54 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2011-08-30 13:13:54 +0100
commitd4c67504b31d8a4c6a89f02425f50c28970fcd43 (patch)
tree84c96c9acf79ede5ba80aa5c95096a9c4806710d /alot/account.py
parentb65d427c2af72d1894bb1d465cb61325e28c732c (diff)
unifies pipe to cmd in send_mail and print.
issue #39
Diffstat (limited to 'alot/account.py')
-rw-r--r--alot/account.py20
1 files changed, 6 insertions, 14 deletions
diff --git a/alot/account.py b/alot/account.py
index 0447d0a8..dcf971b4 100644
--- a/alot/account.py
+++ b/alot/account.py
@@ -29,6 +29,7 @@ from ConfigParser import SafeConfigParser
from urlparse import urlparse
from helper import cmd_output
+import helper
class Account:
@@ -151,20 +152,11 @@ class SendmailAccount(Account):
def send_mail(self, mail):
mail['Date'] = email.utils.formatdate(time.time(), True)
- # no unicode in shlex on 2.x
- args = shlex.split(self.cmd.encode('ascii'))
- try:
- proc = subprocess.Popen(args, stdin=subprocess.PIPE,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- out, err = proc.communicate(mail.as_string())
- except OSError, e:
- return str(e) + '. sendmail_cmd set to: %s' % self.cmd
- if proc.poll(): # returncode is not 0
- return err.strip()
- else:
- self.store_sent_mail(mail)
- return None
+ out, err = helper.pipe_to_command(self.cmd, mail.as_string())
+ if err:
+ return err + '. sendmail_cmd set to: %s' % self.cmd
+ self.store_sent_mail(mail)
+ return None
class AccountManager: