Fix dumb timestamp issue in email send

This commit is contained in:
Brandon Myers 2017-05-11 18:19:38 -05:00
Родитель 453c3069ad
Коммит 984ee5b701
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 8AA79AD83045BBC7
2 изменённых файлов: 7 добавлений и 4 удалений

Просмотреть файл

@ -1,4 +1,4 @@
[options]
smtpserver = <add_smtpserver>
sender = <add_sender_email>
recipients = <add_recipient_email>
recipients = <add_recipient_email>,<add_recipient2_email>

Просмотреть файл

@ -1,7 +1,7 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Copyright (c) 2014 Mozilla Corporation
# Copyright (c) 2017 Mozilla Corporation
#
# Contributors:
# Alicia Smith <asmith@mozilla.com>
@ -14,6 +14,8 @@ from datetime import datetime
from configlib import getConfig, OptionParser
import smtplib
from email.mime.text import MIMEText
from email.Utils import formatdate
import time
class message(object):
@ -52,8 +54,9 @@ class message(object):
emailMessage = MIMEText(message['summary'] + ' on ' + message['events'][0]['documentsource']['utctimestamp'])
emailMessage['Subject'] = 'MozDef Alert: Releng Restricted Servers Successful SSH Access'
emailMessage['From'] = self.options.sender
emailMessage['To'] = self.options.recipients
emailMessage['Date'] = datetime.utcnow().isoformat()
emailMessage['To'] = ','.join(self.options.recipients)
nowtuple = time.mktime(datetime.utcnow().timetuple())
emailMessage['Date'] = formatdate(nowtuple)
smtpObj = smtplib.SMTP(self.options.smtpserver, 25)
try:
smtpObj.sendmail(self.options.sender, self.options.recipients, emailMessage.as_string())