changed task parsing and handling

This commit is contained in:
RafTim 2013-11-03 04:57:09 +01:00
commit a670770dde
7 changed files with 82 additions and 73 deletions

View file

@ -51,17 +51,20 @@ class MailTask(Task):
#self.set_task_type(kwargs["type"])
#self.recipient = kwargs["args"]["rcpt"]
def execute(self, msg, core):
def execute(self, msg, taskArgs):
if "recipient" not in taskArgs:
raise "could not execute Mail Task! No recipient given!"
message = MIMEText(msg)
message['Subject'] = msg
now = datetime.datetime.now()
message['Date'] = now.strftime("%a, %d %b %Y %H:%M:%S")
#TODO: totally unstable just to use values from core. make checks before...!
message['From'] = self.fromName
message['To'] = self.recipient
message['To'] = taskArgs["recipient"]
s = smtplib.SMTP(self.host, self.port)
s.login(self.userName, self.password)
s.sendmail(self.fromName, self.recipient, message.as_string())
s.sendmail(self.fromName, taskArgs["recipient"], message.as_string())
s.quit()