Skip to content

Commit

Permalink
Merge branch 'release/1.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
fedelemantuano committed Jul 10, 2017
2 parents 6b634fe + 4525710 commit fda29a6
Show file tree
Hide file tree
Showing 9 changed files with 361 additions and 203 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ script:
- python tests/test_main.py
- python -m mailparser -v
- python -m mailparser -h
- python -m mailparser -f tests/mails/mail_malformed_3 -j

after_success:
coveralls

notifications:
email: false
slack:
secure: eawY0ibL+ldzr+lL+QQHicUaoQwom01P7g57avv9ebZ256VMzTuiIYkkNuyetTmjU7oACgrzmIJiuYdeyYYqJDfGBLS/Z6KeIb11iAa9vAmAjmoarP1eyR6XcyIOpAxRXDFDGaqjEqyjikI3P8HQvnv24YFRdpR0jd8kf9rZ9DHVMIOKRi4okBmZvCCgS5YhZJEdOujHwPlF71ZIOk26S7dGRu4gJeLRMPnhwcM2TKqcsU+cZaaRP9n/0sQ/gqDbb+SKtENGLNfTuTuJvhrhsGcbGpFH4M5RDpvJvvlUZQhJBc3ordFXYGT0IQcAn4Os4gOXgcy0JD+74uh/uICohvWKJio5diwH91FVkTF/gODOKSfyEfO2nAKHLF8KRkYoPitecR9KdUbEALeHRxNxWLfumivzJxOK4QLo94qx6LvSIA9j3o137U0POA7gRHYmZCSdDrkxBI5eFqBbivLNGKN6v0a5tZIRSCLfNsr6ZiNcxM5KO9vUIMJ6HdpNTZDqKsd9JFdV2wI/q/yy7vhoocxAtk+H88jdvrqiA9B5jwoHaQ7lGsgmkvPNLeuNsarr3VDGZGzMmqnssx9G4F8jQP52n4t2RfZqe6xE2867J4tt1H/5YkWJiacoxquAe7DcCn1qXko9q9Mbs6lDN9fumb3J5HmG7R/yeX79zAGPE5w=

52 changes: 26 additions & 26 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ Description
-----------

mail-parser takes as input a raw mail and generates a parsed object.
This object is a tokenized mail with the all parts of mail and some
indicator: - body - headers - subject - from - to - attachments -
message id - date - charset mail - sender IP address
This object is a tokenized email with some indicator:
- body - headers - subject - from - to - attachments - message id - date
- charset mail - sender IP address

We have also two indicator: - anomalies: mail without message id or date
We have also two types of indicator: - anomalies: mail without message id or date
- `defects`_: mail with some not compliance RFC part

Defects
Expand Down Expand Up @@ -70,37 +70,37 @@ or use ``pip``:
Usage in a project
-------------------

Import ``MailParser`` class:
Import ``mailparser`` module:

::

from mailparser import MailParser
import mailparser

parser = MailParser()
parser.parse_from_file(f)
parser.parse_from_string(raw_mail)
mail = mailparser.parse_from_file(f)
mail = mailparser.parse_from_string(raw_mail)
mail = mailparser.parse_from_bytes(byte_mail)

Then you can get all parts

::

parser.body
parser.headers
parser.message_id
parser.to_
parser.from_
parser.subject
parser.text_plain_list: only text plain mail parts in a list
parser.attachments_list: list of all attachments
parser.date_mail
parser.parsed_mail_obj: tokenized mail in a object
parser.parsed_mail_json: tokenized mail in a JSON
parser.defects: defect RFC not compliance
parser.defects_category: only defects categories
parser.has_defects
parser.anomalies
parser.has_anomalies
parser.get_server_ipaddress(trust="my_server_mail_trust")
mail.body
mail.headers
mail.message_id
mail.to_
mail.from_
mail.subject
mail.text_plain_list: only text plain mail parts in a list
mail.attachments_list: list of all attachments
mail.date_mail
mail.parsed_mail_obj: tokenized mail in a object
mail.parsed_mail_json: tokenized mail in a JSON
mail.defects: defect RFC not compliance
mail.defects_category: only defects categories
mail.has_defects
mail.anomalies
mail.has_anomalies
mail.get_server_ipaddress(trust="my_server_mail_trust")

.. _email: https://docs.python.org/2/library/email.message.html
.. _SpamScope: https://github.com/SpamScope/spamscope
Expand Down
48 changes: 24 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ From version 1.0.0rc1 mail-parser supports Python 3.

## Description

mail-parser takes as input a raw mail and generates a parsed object. This object is a tokenized mail with the all parts of mail and some indicator:
mail-parser takes as input a raw email and generates a parsed object. This object is a tokenized email with some indicator:
- body
- headers
- subject
Expand All @@ -24,7 +24,7 @@ mail-parser takes as input a raw mail and generates a parsed object. This object
- charset mail
- sender IP address

We have also two indicator:
We have also two types of indicator:
- anomalies: mail without message id or date
- [defects](https://docs.python.org/2/library/email.message.html#email.message.Message.defects): mail with some not compliance RFC part

Expand Down Expand Up @@ -68,36 +68,36 @@ pip install mail-parser

## Usage in a project

Import `MailParser` class:
Import `mailparser` module:

```
from mailparser import MailParser
import mailparser
parser = MailParser()
parser.parse_from_file(f)
parser.parse_from_string(raw_mail)
mail = mailparser.parse_from_file(f)
mail = mailparser.parse_from_string(raw_mail)
mail = mailparser.parse_from_bytes(byte_mail)
```

Then you can get all parts

```
parser.body
parser.headers
parser.message_id
parser.to_
parser.from_
parser.subject
parser.text_plain_list: only text plain mail parts in a list
parser.attachments_list: list of all attachments
parser.date_mail
parser.parsed_mail_obj: tokenized mail in a object
parser.parsed_mail_json: tokenized mail in a JSON
parser.defects: defect RFC not compliance
parser.defects_category: only defects categories
parser.has_defects
parser.anomalies
parser.has_anomalies
parser.get_server_ipaddress(trust="my_server_mail_trust")
mail.body
mail.headers
mail.message_id
mail.to_
mail.from_
mail.subject
mail.text_plain_list: only text plain mail parts in a list
mail.attachments_list: list of all attachments
mail.date_mail
mail.parsed_mail_obj: tokenized mail in a object
mail.parsed_mail_json: tokenized mail in a JSON
mail.defects: defect RFC not compliance
mail.defects_category: only defects categories
mail.has_defects
mail.anomalies
mail.has_anomalies
mail.get_server_ipaddress(trust="my_server_mail_trust")
```

## Usage from command-line
Expand Down
4 changes: 3 additions & 1 deletion mailparser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@
limitations under the License.
"""

from .mailparser import MailParser

from .mailparser import (MailParser, parse_from_file,
parse_from_string, parse_from_bytes)
13 changes: 4 additions & 9 deletions mailparser/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@
import os
import runpy

try:
import simplejson as json
except ImportError:
import json
import simplejson as json

from mailparser import MailParser
import mailparser
from .utils import fingerprints

current = os.path.realpath(os.path.dirname(__file__))
Expand Down Expand Up @@ -179,12 +176,10 @@ def print_attachments(attachments, flag_hash):
def main():
args = get_args().parse_args()

parser = MailParser()

if args.file:
parser.parse_from_file(args.file)
parser = mailparser.parse_from_file(args.file)
elif args.string:
parser.parse_from_string(args.string)
parser = mailparser.parse_from_string(args.string)

if args.json:
j = json.loads(parser.parsed_mail_json)
Expand Down
25 changes: 0 additions & 25 deletions mailparser/exceptions.py

This file was deleted.

Loading

0 comments on commit fda29a6

Please sign in to comment.