[arpwatch_sendmail] MIMEage
Ignore-this: cfb544fab3408f8ee088a5fa577b3b56 darcs-hash:20091011023953-ffbb2-f48620ff625f569cdbdddab2724ca6c2c16d78ed.gz
This commit is contained in:
parent
4bc4fbf3c3
commit
36c523e640
1 changed files with 13 additions and 5 deletions
|
@ -21,21 +21,29 @@ def get_machine(unformated_mac):
|
|||
|
||||
if __name__ == "__main__":
|
||||
texte = sys.stdin.read().decode('ISO-8859-15')
|
||||
textes = texte.splitlines(True)
|
||||
i = textes.index(u'\n')
|
||||
textes[i-1:i-1] = [
|
||||
u'MIME-Version: 1.0\n',
|
||||
u'Content-Type: text/plain; charset=UTF-8; format=flowed\n',
|
||||
u'Content-Transfer-Encoding: 8bit\n',
|
||||
]
|
||||
|
||||
# On récupère les destinataires dans les arguments (très ad hoc)
|
||||
recipients = sys.argv[2].split(',')
|
||||
# On complète le message
|
||||
try:
|
||||
macs = find_mac.findall(texte)
|
||||
for mac in macs:
|
||||
texte += get_machine(mac)
|
||||
textes.append(get_machine(mac))
|
||||
except:
|
||||
# En cas d'exception, on envoie le traceback
|
||||
import traceback
|
||||
texte += u'\n'
|
||||
texte += u''.join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
|
||||
texte += '\n-- \narpwatch_sendmail.py\n'
|
||||
textes.append(u'\n')
|
||||
textes.append(u''.join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)))
|
||||
textes.append('\n-- \narpwatch_sendmail.py\n')
|
||||
|
||||
smtp = smtplib.SMTP()
|
||||
smtp.connect()
|
||||
smtp.sendmail("arpwatch@crans.org", recipients, texte.encode('ISO-8859-15'))
|
||||
smtp.sendmail("arpwatch@crans.org", recipients, u''.join(textes).encode('UTF-8'))
|
||||
smtp.quit()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue