changed task parsing and handling
This commit is contained in:
parent
4be1a6ecb9
commit
a670770dde
7 changed files with 82 additions and 73 deletions
|
|
@ -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()
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue