FAQ
I'mt trying to automate arf (abuse reporting format) generation.

RFC5965 (http://www.rfc-editor.org/rfc/rfc5965.txt) sets that the email
message should contain three parts:

- Human-readable (text/plain)
- Machine-Readable (message/feedback-report)
- Evidence (attached as a file).

I'm trying this way:

#!/usr/bin/python

# Import smtplib for the actual sending function
import smtplib

# Import the email modules we'll need
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.MIMEBase import MIMEBase
from email.MIMENonMultipart import MIMENonMultipart
from email.Message import Message


Mensaje = MIMEMultipart()
Mensaje['From'] = "test at email.com"
Mensaje['To'] = "test at email.com"
Mensaje.add_header('Reply-To','test at email.com')
Mensaje.add_header('X-Data-Format','X-ARF')
Mensaje.add_header('X-ARF','Yes')
Mensaje['Subject'] = "abuse report about XX.XXX.XXX.XX - Thu Jun 16 10:15:34
2011 +02:00"
Mensaje.add_header('Auto-Submitted', 'auto-generated')

humanPart = MIMEText('','plain')
humanPart.set_payload("text message\n")
humanPart.set_charset('utf8')
Mensaje.attach(humanPart)

machinePart = Message()
machinePart.set_default_type('message/feedback-report')
machinePart.add_header('Content-Disposition','inline')
machinePart.add_header('Content-Transfer-Encoding','7bit')
payload= ("Reported-From: test at email.com\nReport-ID:
1308219334 at h0056.domain.com\nCategory: abuse\nReport-Type:
malware-attack\nDestination-System: real-world\nUser-Agent: python abuse arf
script\nDate: Thu Jun 16 10:15:34 2011 +02:00\nSource:
xx.xxx.xxx.xx\nSource-Type: IPv4\nAntivirus-Result:
FIRMA_DETECTADA\nAntivirus-Vendor:ClamAV with Custom Signatures\nSchema-URL:
http://www.x-arf.org/schema/abuse_malware-attack_0.1.3.json\n")
machinePart.set_payload(payload)
Mensaje.attach(machinePart)

s = smtplib.SMTP("127.0.0.1")
s.sendmail(Mensaje['From'], Mensaje['To'], Mensaje.as_string())
s.quit()





But it fails when it tries to convert the machinePart as a string.

What I'm doing wrong?

_________________
Regards,
Roberto Navarro Reyes
SysAdmin - Tusprofesionales, SL

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJun 20, '11 at 10:17a
activeJun 20, '11 at 10:17a
posts1
users1
websitepython.org

People

Translate

site design / logo © 2022 Grokbase