From a9eaa7927fd22dc2e68016c725a04ebe3988b7c4 Mon Sep 17 00:00:00 2001 From: Andrew Engelbrecht Date: Tue, 1 Dec 2015 17:01:34 -0500 Subject: [PATCH] proper email sending methodology i am now using the smtp facilities of python rather than calling sendmail. this resolves a bug induced by any human name in a from address beginning with a '-' (dash). this confused sendmail, as it interpreted the dash as an unknown command line option. --- edward | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/edward b/edward index 1622e42..cdab0b4 100755 --- a/edward +++ b/edward @@ -37,8 +37,8 @@ import os import sys import enum import gpgme +import smtplib import importlib -import subprocess import email.parser import email.message @@ -1351,16 +1351,9 @@ def generate_encrypted_mime (plaintext, email_to, email_subject, encrypt_to_key, def send_reply(email_txt, subject, reply_to, reply_from): - email_bytes = email_txt.encode('ascii') - - p = subprocess.Popen(["/usr/sbin/sendmail", "-f", reply_from, "-F", "Edward, GPG Bot", "-i", reply_to], stdin=subprocess.PIPE) - - (stdout, stderr) = p.communicate(email_bytes) - - if stdout != None: - debug("sendmail stdout: " + str(stdout)) - if stderr != None: - error("sendmail stderr: " + str(stderr)) + s = smtplib.SMTP('localhost') + s.sendmail(reply_from, reply_to, email_txt) + s.quit() def email_quote_text (text): -- 2.25.1