from config import config
import util
+import log
def recode(s):
if s.__class__ == ''.__class__:
if subject != None:
self.set_header("Subject", subject)
+ def remove_header(self, n):
+ if n in self.headers:
+ del self.headers[n]
+
def write_line(self, l):
self.body.write(recode("%s\n" % l))
util.sendfile(self.body, f)
def send(self):
- send_sendmail = "/usr/sbin/sendmail -i -t -f %s" % config.admin_email
+ if not os.path.exists("/usr/lib/sendmail"):
+ # TODO: dump to file?
+ log.alert("/usr/lib/sendmail doesn't exist: Can't send email")
+ return False
+ send_sendmail = "/usr/lib/sendmail -i -t -f %s" % config.admin_email
f = os.popen(send_sendmail, "w")
- self.write_to(f)
- f.close()
+ try:
+ self.write_to(f)
+ except IOError, e:
+ log.alert("sending email message failed: %s" % e)
+ f.close()
+ return False
+ return f.close()