Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #8010

Can't make a message/feedback-report content type on a IMEMultipart Message

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rnavarro@tusprofesionales.es>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'string.': 0.04; 'sysadmin': 0.04; 'automate': 0.05; 'way:': 0.05; 'python': 0.08; 'subject:report': 0.09; 'thu': 0.09; '(attached': 0.16; 'email name:test': 0.16; 'file).': 0.16; 'smtplib': 0.16; 'tries': 0.16; 'convert': 0.19; 'skip:m 30': 0.21; 'trying': 0.23; 'wrong?': 0.23; 'function': 0.25; 'modules': 0.26; 'reporting': 0.26; "i'm": 0.27; 'import': 0.29; 'skip:( 20': 0.30; 'roberto': 0.30; 'x-mailer:microsoft outlook express 6.00.2900.5931': 0.30; "skip:' 10": 0.32; 'to:addr:python-list': 0.33; 'skip:# 10': 0.34; 'fails': 0.35; 'actual': 0.36; 'subject:/': 0.36; 'skip:e 20': 0.37; 'url:org': 0.38; 'but': 0.38; 'doing': 0.39; 'skip:s 20': 0.39; 'should': 0.39; 'abuse': 0.39; 'sets': 0.39; 'skip:m 40': 0.39; 'to:addr:python.org': 0.39; 'report': 0.40; 'custom': 0.60; 'skip:+ 10': 0.67; 'url:3': 0.67; 'subject:Message': 0.67; 'subject:make': 0.73; 'generation.': 0.84; 'subject:content': 0.84; 'format)': 0.91
X-Spam-Status No, hits=3.0 required=5.0
X-Spam-Level +++
X-Spam-Report SA TESTS 0.2 HOT_NASTY BODY: Possible porn - Hot, Nasty, Wild, Young 0.0 BAYES_50 BODY: Bayesian spam probability is 40 to 60% [score: 0.5000] 6.0 FORGED_MUA_OUTLOOK Forged mail pretending to be from MS Outlook -3.1 AWL AWL: From: address is in the auto white-list
X-Antivirus-MYDOMAIN-Mail-From rnavarro@tusprofesionales.es via correo.tusprofesionales.es
X-Antivirus-MYDOMAIN 1.25-st-qms (Clear:RC:0(86.109.160.35):SA:0(3.0/5.0):. Processed in 0.571812 secs Process 8272)
From "Roberto Navarro - TusProfesionales.es" <rnavarro@tusprofesionales.es>
To <python-list@python.org>
Subject Can't make a message/feedback-report content type on a IMEMultipart Message
Date Mon, 20 Jun 2011 12:17:49 +0200
MIME-Version 1.0
Content-Type text/plain; format=flowed; charset="iso-8859-1"; reply-type=original
Content-Transfer-Encoding 7bit
X-Priority 3
X-MSMail-Priority Normal
X-Mailer Microsoft Outlook Express 6.00.2900.5931
X-MimeOLE Produced By Microsoft MimeOLE V6.00.2900.6109
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.179.1308565473.1164.python-list@python.org> (permalink)
Lines 70
NNTP-Posting-Host 82.94.164.166
X-Trace 1308565474 news.xs4all.nl 49046 [::ffff:82.94.164.166]:39612
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:8010

Show key headers only | View raw


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@email.com"
Mensaje['To'] = "test@email.com"
Mensaje.add_header('Reply-To','test@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@email.com\nReport-ID: 
1308219334@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 

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Can't make a message/feedback-report content type on a IMEMultipart Message "Roberto Navarro - TusProfesionales.es" <rnavarro@tusprofesionales.es> - 2011-06-20 12:17 +0200

csiph-web