├── tests ├── __init__.py ├── spam │ ├── polish-plain.txt │ ├── russian-html.txt │ ├── check.py │ ├── english-plain.txt │ ├── english-multi.txt │ └── english-html.txt ├── send-test-emails.py ├── helpers.py └── test_localmail.py ├── kill_localmail.sh ├── .bumpversion.cfg ├── TODO ├── tox.ini ├── .bzrignore ├── MANIFEST.in ├── setup.cfg ├── localmail.tac ├── AUTHORS.rst ├── muttrc ├── HISTORY.rst ├── COPYRIGHT.txt ├── Makefile ├── localmail ├── http.py ├── cred.py ├── smtp.py ├── imap.py ├── templates │ └── index.html ├── __init__.py └── inbox.py ├── CONTRIBUTING.rst ├── twisted └── plugins │ └── localmail_tap.py ├── README.rst ├── setup.py └── LICENSE.txt /tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /kill_localmail.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | kill `cat twistd.pid` 3 | -------------------------------------------------------------------------------- /.bumpversion.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | current_version = 0.4.1 3 | files = setup.py 4 | 5 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | improve logging output 2 | Add SSL support back in 3 | better tests using twisted.trial 4 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = py26,py27,pypy 3 | [testenv] 4 | commands = python setup.py test 5 | -------------------------------------------------------------------------------- /tests/spam/polish-plain.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mistio/localmail/HEAD/tests/spam/polish-plain.txt -------------------------------------------------------------------------------- /tests/spam/russian-html.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mistio/localmail/HEAD/tests/spam/russian-html.txt -------------------------------------------------------------------------------- /.bzrignore: -------------------------------------------------------------------------------- 1 | twisted/plugins/*.cache 2 | twistd.* 3 | dist 4 | localmail.egg-info 5 | _trial_temp 6 | build 7 | .tox 8 | *.egg 9 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include *.tac 2 | include *.txt 3 | include *.rst 4 | include muttrc 5 | include twisted/plugins/*.py 6 | recursive-include localmail/templates *.html 7 | 8 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [wheel] 2 | universal = 1 3 | 4 | [check-manifest] 5 | ignore = 6 | tests* 7 | Makefile 8 | tox.ini 9 | TODO 10 | kill_localmail.sh 11 | 12 | -------------------------------------------------------------------------------- /localmail.tac: -------------------------------------------------------------------------------- 1 | from twisted.application import service 2 | 3 | import localmail 4 | 5 | application = service.Application("localmail") 6 | smtp, imap = localmail.get_services(2025, 2143) 7 | smtp.setServiceParent(application) 8 | imap.setServiceParent(application) 9 | -------------------------------------------------------------------------------- /AUTHORS.rst: -------------------------------------------------------------------------------- 1 | Credits 2 | ======= 3 | 4 | “localmail” is written and maintained by Simon Davy 5 | 6 | 7 | Contributors 8 | ------------ 9 | 10 | The following people contributed directly or indirectly to this project: 11 | 12 | - `Ed Jannoo ` 13 | -------------------------------------------------------------------------------- /muttrc: -------------------------------------------------------------------------------- 1 | set imap_user = "user@anywhere.com" 2 | set imap_pass = "pass" 3 | set folder = "imap://127.0.0.1:2143" 4 | 5 | set smtp_url = "smtp://user@127.0.0.1:2025/" 6 | set smtp_pass = "pass" 7 | set from = "localmail@localmail.com" 8 | set realname = "Localmail Test User" 9 | set spoolfile = "+INBOX" 10 | set move=no 11 | -------------------------------------------------------------------------------- /tests/send-test-emails.py: -------------------------------------------------------------------------------- 1 | import glob 2 | import sys 3 | from email.parser import Parser 4 | import smtplib 5 | 6 | if __name__ == '__main__': 7 | port = int(sys.argv[1]) if len(sys.argv) > 1 else 2025 8 | smtp = smtplib.SMTP("localhost", port) 9 | for file in glob.glob('spam/*.txt'): 10 | msg = Parser().parse(open(file, 'rb')) 11 | smtp.sendmail('a@b.com', ['a@b.com'], msg.as_string()) 12 | -------------------------------------------------------------------------------- /tests/spam/check.py: -------------------------------------------------------------------------------- 1 | from email.parser import Parser 2 | import glob 3 | 4 | for file in glob.glob('*.txt'): 5 | print file 6 | msg = Parser().parse(open(file, 'rb')) 7 | print "Type: ", msg.get_content_type() 8 | for k, v in msg.items(): 9 | print("%s: %s" % (k, v)) 10 | for part in msg.walk(): 11 | if part.get_content_maintype() == 'multipart': 12 | continue 13 | print "PART:" 14 | print part.get_content_type() 15 | print part.get_payload()[:150] 16 | print 17 | print 18 | print "-------------------------------------------------" 19 | print 20 | -------------------------------------------------------------------------------- /HISTORY.rst: -------------------------------------------------------------------------------- 1 | .. :changelog: 2 | 3 | History 4 | ======= 5 | 6 | 0.4 (2015-08-14) 7 | ---------------- 8 | 9 | * support for using random port numbers 10 | * available as a universal wheel, general packaging improvements 11 | * Simple HTTP interface for browsing mail (requires jinja2) 12 | * Support writing to mbox file 13 | * Fixed date to work with mutt, example muttrc included in package. 14 | 15 | 16 | 0.3 (2013-05-24) 17 | ---------------- 18 | 19 | * Multipart message support [via Ed Jannoo] 20 | * IMAP UID support 21 | * Support python 2.6, 2.7 and pypy, tested via tox 22 | 23 | 24 | 0.2 (2012-11-13) 25 | ---------------- 26 | 27 | * Initial public release 28 | * Basic SMTP/IMAP server 29 | 30 | -------------------------------------------------------------------------------- /COPYRIGHT.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2012- Canonical Ltd 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; either version 2 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program; if not, write to the Free Software 15 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PUBLISHING_DEPENDENCIES=wheel bumpversion twine 2 | TOX=$(shell which detox || which tox) 3 | 4 | 5 | .PHONY: test 6 | test: lint 7 | $(TOX) 8 | 9 | .PHONY: lint 10 | lint: 11 | flake8 localmail tests twisted 12 | 13 | .PHONY: publishing-dependencies 14 | publishing-dependencies: 15 | pip install -U $(PUBLISHING_DEPENDENCIES) 16 | 17 | .PHONY: bump 18 | bump: publishing-dependencies 19 | $(eval OLD=$(shell python -c "import setup; print setup.__VERSION__")) 20 | bumpversion minor 21 | $(MAKE) __finish_bump OLD=$(OLD) 22 | 23 | __finish_bump: 24 | $(eval NEW=$(shell python -c "import setup; print setup.__VERSION__")) 25 | bzr commit -m "bump version: $(OLD) to $(NEW)" 26 | bzr tag "v$(NEW)" 27 | 28 | .PHONY: update 29 | update: 30 | python setup.py register 31 | 32 | .PHONY: upload 33 | upload: publishing-dependencies 34 | python setup.py sdist bdist_wheel 35 | twine upload dist/* 36 | 37 | .PHONY: release 38 | release: bump upload 39 | 40 | 41 | -------------------------------------------------------------------------------- /localmail/http.py: -------------------------------------------------------------------------------- 1 | from pkg_resources import resource_string 2 | from twisted.web.server import Site 3 | from twisted.web.resource import Resource 4 | 5 | from localmail.inbox import INBOX 6 | 7 | 8 | class TestServerHTTPFactory(Site): 9 | noisy = False 10 | 11 | 12 | class Index(Resource): 13 | isLeaf = True 14 | index_template = None 15 | 16 | def __init__(self, *args, **kwargs): 17 | Resource.__init__(self, *args, **kwargs) 18 | 19 | # defer import so is optional 20 | try: 21 | from jinja2 import Template 22 | self.index_template = Template(resource_string( 23 | __name__, 'templates/index.html').decode('utf8')) 24 | except ImportError: 25 | pass 26 | 27 | def render_GET(self, request): 28 | if self.index_template is None: 29 | return "Web interface not available: Jinja2 not installed" 30 | 31 | request.setHeader('Content-type', 'text/html; charset=utf-8') 32 | return self.index_template.render(msgs=INBOX.msgs).encode('utf8') 33 | 34 | 35 | index = Index() 36 | -------------------------------------------------------------------------------- /CONTRIBUTING.rst: -------------------------------------------------------------------------------- 1 | Contributing 2 | ============ 3 | 4 | To set up a development environment, create a virtualenv and then run the 5 | following in it. The main dependency is twisted, and tox for running tests, 6 | and flake8 for linting. Unittest2 is pulled in of you are on python 2.6. 7 | 8 | :: 9 | python setup.py develop 10 | 11 | Testing 12 | ------- 13 | 14 | The test suite is very simple. It starts localmail in a thread listening on 15 | random ports. The tests then run in the main thread using the python stdlib 16 | imaplib and smtplib modules as clients, so it's more integration tests rather 17 | than unit tests. 18 | 19 | I probably should add some proper unit tests and use twisted's SMTP/IMAP 20 | clients as well, but twisted.trial scares me a little. 21 | 22 | To run the full suite, use tox to run on python 2.6, 2.7, and pypy. Works in 23 | parallel with detox too, thanks to using random ports, for faster runs. 24 | 25 | :: 26 | 27 | make test 28 | 29 | Note: this will also run flake8, which is required to pass to merge. 30 | 31 | To run the suite manually, or with specific tests, use: 32 | 33 | :: 34 | python setup.py test [-s tests.test_localmail.SomeTestCase.test_something] 35 | -------------------------------------------------------------------------------- /localmail/cred.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2012- Canonical Ltd 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; either version 2 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program; if not, write to the Free Software 15 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 | from zope.interface import implements 17 | from twisted.internet import defer 18 | from twisted.cred import portal, checkers, credentials 19 | from twisted.mail import smtp, imap4 20 | 21 | from imap import IMAPUserAccount 22 | from smtp import MemoryDelivery 23 | 24 | 25 | class TestServerRealm(object): 26 | implements(portal.IRealm) 27 | avatarInterfaces = { 28 | imap4.IAccount: IMAPUserAccount, 29 | smtp.IMessageDelivery: MemoryDelivery, 30 | } 31 | 32 | def requestAvatar(self, avatarId, mind, *interfaces): 33 | for requestedInterface in interfaces: 34 | if requestedInterface in self.avatarInterfaces: 35 | avatarClass = self.avatarInterfaces[requestedInterface] 36 | avatar = avatarClass() 37 | # null logout function: take no arguments and do nothing 38 | logout = lambda: None 39 | return defer.succeed((requestedInterface, avatar, logout)) 40 | 41 | # none of the requested interfaces was supported 42 | raise KeyError("None of the requested interfaces is supported") 43 | 44 | 45 | class CredentialsNonChecker(object): 46 | implements(checkers.ICredentialsChecker) 47 | credentialInterfaces = (credentials.IUsernamePassword, 48 | credentials.IUsernameHashedPassword) 49 | 50 | def requestAvatarId(self, credentials): 51 | """automatically validate *any* user""" 52 | return credentials.username 53 | -------------------------------------------------------------------------------- /localmail/smtp.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2012- Canonical Ltd 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; either version 2 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program; if not, write to the Free Software 15 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 | 17 | from cStringIO import StringIO 18 | 19 | from twisted.internet import defer 20 | from twisted.mail import smtp 21 | from twisted.mail.imap4 import LOGINCredentials, PLAINCredentials 22 | from zope.interface import implements 23 | 24 | from inbox import INBOX 25 | 26 | 27 | class MemoryMessage(object): 28 | """Reads a message into a StringIO, and passes on to global inbox""" 29 | implements(smtp.IMessage) 30 | 31 | def __init__(self): 32 | self.file = StringIO() 33 | 34 | def lineReceived(self, line): 35 | self.file.write(line + '\n') 36 | print(line) 37 | 38 | def eomReceived(self): 39 | self.file.seek(0) 40 | INBOX.addMessage(self.file, [r'\Recent', r'\Unseen']) 41 | self.file.close() 42 | return defer.succeed(None) 43 | 44 | def connectionLost(self): 45 | self.file.close() 46 | 47 | 48 | class MemoryDelivery(object): 49 | """Null-validator for email address - always delivers succesfully""" 50 | implements(smtp.IMessageDelivery) 51 | 52 | def validateTo(self, user): 53 | return MemoryMessage 54 | 55 | def validateFrom(self, helo, origin): 56 | return origin 57 | 58 | def receivedHeader(self, helo, origin, recipients): 59 | return 'Received: Test Server.' 60 | 61 | 62 | class TestServerESMTPFactory(smtp.SMTPFactory): 63 | """Factort for SMTP connections that authenticates any user""" 64 | protocol = smtp.ESMTP 65 | challengers = { 66 | "LOGIN": LOGINCredentials, 67 | "PLAIN": PLAINCredentials 68 | } 69 | noisy = False 70 | 71 | def buildProtocol(self, addr): 72 | p = smtp.SMTPFactory.buildProtocol(self, addr) 73 | p.challengers = self.challengers 74 | return p 75 | -------------------------------------------------------------------------------- /localmail/imap.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2012- Canonical Ltd 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; either version 2 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program; if not, write to the Free Software 15 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 | from twisted.internet import protocol 17 | from twisted.mail import imap4 18 | from zope.interface import implements 19 | 20 | from inbox import INBOX 21 | 22 | 23 | class IMAPUserAccount(object): 24 | implements(imap4.IAccount) 25 | 26 | def listMailboxes(self, ref, wildcard): 27 | "only support one folder" 28 | return [("INBOX", INBOX)] 29 | 30 | def select(self, path, rw=True): 31 | "return the same mailbox for every path" 32 | return INBOX 33 | 34 | def create(self, path): 35 | "nothing to create" 36 | pass 37 | 38 | def delete(self, path): 39 | "delete the mailbox at path" 40 | raise imap4.MailboxException("Permission denied.") 41 | 42 | def rename(self, oldname, newname): 43 | "rename a mailbox" 44 | pass 45 | 46 | def isSubscribed(self, path): 47 | "return a true value if user is subscribed to the mailbox" 48 | return True 49 | 50 | def subscribe(self, path): 51 | return True 52 | 53 | def unsubscribe(self, path): 54 | return True 55 | 56 | 57 | class IMAPServerProtocol(imap4.IMAP4Server): 58 | "Subclass of imap4.IMAP4Server that adds debugging." 59 | 60 | def lineReceived(self, line): 61 | imap4.IMAP4Server.lineReceived(self, line) 62 | 63 | def sendLine(self, line): 64 | imap4.IMAP4Server.sendLine(self, line) 65 | 66 | 67 | class TestServerIMAPFactory(protocol.Factory): 68 | protocol = IMAPServerProtocol 69 | portal = None # placeholder 70 | noisy = False 71 | 72 | def buildProtocol(self, address): 73 | p = self.protocol() 74 | # self.portal will be set up already "magically" 75 | p.portal = self.portal 76 | p.factory = self 77 | return p 78 | -------------------------------------------------------------------------------- /twisted/plugins/localmail_tap.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2012- Canonical Ltd 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; either version 2 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program; if not, write to the Free Software 15 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 | from zope.interface import implements 17 | 18 | from twisted.application import service 19 | from twisted import plugin 20 | from twisted.python import usage 21 | 22 | import localmail 23 | 24 | 25 | class Options(usage.Options): 26 | optFlags = [ 27 | ["random", "r", "Use random ports. Overides any other port options"], 28 | ] 29 | optParameters = [ 30 | ["smtp", "s", 2025, "The port number the SMTP server will listen on"], 31 | ["imap", "i", 2143, "The port number the IMAP server will listen on"], 32 | ["http", "h", 8880, "The port number the HTTP server will listen on"], 33 | ["file", "f", None, "File to write messages to"], 34 | ] 35 | 36 | 37 | class LocalmailServiceMaker(object): 38 | implements(service.IServiceMaker, plugin.IPlugin) 39 | tapname = "localmail" 40 | description = "A test SMTP/IMAP server" 41 | options = Options 42 | 43 | def makeService(self, options): 44 | svc = service.MultiService() 45 | svc.setName("localmail") 46 | if options['random']: 47 | smtp_port = imap_port = http_port = 0 48 | else: 49 | smtp_port = int(options['smtp']) 50 | imap_port = int(options['imap']) 51 | http_port = int(options['http']) 52 | 53 | smtp, imap, http = localmail.get_services( 54 | smtp_port, imap_port, http_port 55 | ) 56 | if options['file']: 57 | from localmail.inbox import INBOX 58 | INBOX.setFile(options['file']) 59 | imap.setServiceParent(svc) 60 | smtp.setServiceParent(svc) 61 | http.setServiceParent(svc) 62 | return svc 63 | 64 | 65 | # The name of this variable is irrelevant, as long as there is *some* 66 | # name bound to a provider of IPlugin and IServiceMaker. 67 | localmailServiceMaker = LocalmailServiceMaker() 68 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | Localmail 2 | ========= 3 | 4 | For local people. 5 | 6 | Localmail is an SMTP and IMAP server that stores all messages into a single 7 | in-memory mailbox. It is designed to be used to speed up running test suites on 8 | systems that send email, such as new account sign up emails with confirmation 9 | codes. It can also be used to test SMTP/IMAP client code. 10 | 11 | Features: 12 | 13 | * Fast and robust IMAP/SMTP implementations, including multipart 14 | messages and unicode support. 15 | 16 | * Includes simple HTTP interface for reading messages, which is useful for 17 | checking html emails. 18 | 19 | * Compatible with python's stdlib client, plus clients like mutt and 20 | thunderbird. 21 | 22 | * Authentication is supported but completely ignored, all message go in 23 | single mailbox. 24 | 25 | * Messages not persisted by default, and will be lost on shutdown. 26 | Optionally, you can log messages to disk in mbox format. 27 | 28 | Missing features/TODO: 29 | 30 | * SSL support 31 | 32 | WARNING: not a real SMTP/IMAP server - not for production usage. 33 | 34 | 35 | Running localmail 36 | ----------------- 37 | 38 | .. code-block:: bash 39 | 40 | twistd localmail 41 | 42 | This will run localmail in the background, SMTP on port 2025 and IMAP on 2143, 43 | It will log to a file ./twistd.log. Use the -n option if you want to run in 44 | the foreground, like so. 45 | 46 | .. code-block:: bash 47 | 48 | twistd -n localmail 49 | 50 | 51 | You can pass in arguments to control parameters. 52 | 53 | .. code-block:: bash 54 | 55 | twistd localmail --imap --smtp --http --file localmail.mbox 56 | 57 | 58 | You can have localmail use random ports if you like. The port numbers will be logged. 59 | TODO: enable writing random port numbers to a file. 60 | 61 | .. code-block:: bash 62 | 63 | twisted -n localmail --random 64 | 65 | 66 | Embedding 67 | --------- 68 | 69 | If you want to embed localmail in another non-twisted program, such as test 70 | runner, do the following. 71 | 72 | .. code-block:: python 73 | 74 | import threading 75 | import localmail 76 | 77 | thread = threading.Thread( 78 | target=localmail.run, 79 | args=(2025, 2143, 8880, 'localmail.mbox') 80 | ) 81 | thread.start() 82 | 83 | ... 84 | 85 | localmail.shutdown_thread(thread) 86 | 87 | This will run the twisted reactor in a separate thread, and shut it down on 88 | exit. 89 | 90 | If you want to use random ports, you can pass a callback that will have the 91 | ports the service is listening on. 92 | 93 | .. code-block:: python 94 | 95 | import threading 96 | import localmail 97 | 98 | def report(smtp, imap, http): 99 | """do stuff with ports""" 100 | 101 | thread = threading.Thread( 102 | target=localmail.run, 103 | args=(0, 0, 0, None, report) 104 | ) 105 | thread.start() 106 | 107 | 108 | -------------------------------------------------------------------------------- /localmail/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | localmail 5 | 6 | 7 | 8 | 9 | 32 | 44 | 45 | 46 |
47 |
48 |
49 | 59 |
60 |
61 | {% for msg in msgs %} 62 |
63 |
{{ msg.unicode('Subject') }}
64 |
65 |

66 | From: {{ msg.unicode('From') }} 67 | To: {{ msg.unicode('To') }} 68 | {{ msg.date }} 69 |

70 |

Show headers

71 | 72 | {% for header in msg.msg.keys() %} 73 | 74 | {% endfor %} 75 |
{{ header }}{{ msg.unicode(header) }}
76 | {% for payload in msg.payloads() %} 77 |
78 | {{ payload }} 79 |
80 | {% endfor %} 81 |
82 | {% endfor %} 83 |
84 |
85 |
86 | 87 | 88 | -------------------------------------------------------------------------------- /tests/helpers.py: -------------------------------------------------------------------------------- 1 | import smtplib 2 | import imaplib 3 | from email import message_from_string 4 | 5 | 6 | class ContextHelper(object): 7 | def __enter__(self): 8 | return self.start() 9 | 10 | def __exit__(self, type=None, value=None, traceback=None): 11 | return self.stop() 12 | 13 | 14 | def clean_inbox(host, port): 15 | imap = imaplib.IMAP4(host, port) 16 | imap.login('x', 'y') 17 | imap.select() 18 | success, data = imap.search(None, 'ALL') 19 | for msgs in data: 20 | if msgs: 21 | for id in msgs.split(): 22 | imap.store(id, '+FLAGS', r'(\Deleted)') 23 | imap.expunge() 24 | imap.close() 25 | imap.logout() 26 | 27 | 28 | class SMTPClient(ContextHelper): 29 | def __init__(self, host='localhost', port=2025, user='x', password='y'): 30 | self.host = host 31 | self.port = port 32 | self.user = user 33 | self.password = password 34 | 35 | def start(self): 36 | self.client = smtplib.SMTP(self.host, self.port) 37 | #self.client.set_debuglevel(1) 38 | self.client.login(self.user, self.password) 39 | return self 40 | 41 | def stop(self): 42 | self.client.quit() 43 | 44 | def send(self, msg): 45 | self.client.sendmail(msg['From'], msg['To'], msg.as_string()) 46 | 47 | 48 | class IMAPClient(ContextHelper): 49 | def __init__(self, 50 | host='localhost', 51 | port=2143, 52 | username='x', 53 | password='y', 54 | uid=False): 55 | self.host = host 56 | self.port = port 57 | self.username = username 58 | self.password = password 59 | self.uid = uid 60 | 61 | def start(self): 62 | self.client = imaplib.IMAP4(self.host, self.port) 63 | self.client.login(self.username, self.password) 64 | self.client.select() 65 | return self 66 | 67 | def stop(self): 68 | self.client.close() 69 | self.client.logout() 70 | 71 | def call(self, func, *args): 72 | assert func in ('store', 'fetch', 'search') 73 | if self.uid: 74 | success, data = self.client.uid(func, *args) 75 | else: 76 | success, data = getattr(self.client, func)(*args) 77 | assert success == 'OK' 78 | return data 79 | 80 | def fetch(self, id): 81 | data = self.call('fetch', self.msgid(id), '(RFC822)') 82 | return message_from_string(data[0][1]) 83 | 84 | def search(self, *terms): 85 | data = self.call('search', None, *terms) 86 | if data and data[0]: 87 | return data[0].split() 88 | else: 89 | return [] 90 | 91 | def store(self, id, flags, type='+FLAGS'): 92 | return self.call('store', self.msgid(id), type, flags) 93 | 94 | def msgid(self, seq): 95 | seq = int(seq) 96 | if self.uid: 97 | msgs = self.search('ALL') 98 | if seq > len(msgs): 99 | return None 100 | msg_set = msgs[seq - 1] 101 | else: 102 | msg_set = str(seq) 103 | return msg_set 104 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright (C) 2012- Canonical Ltd 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 2 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | __VERSION__ = "0.4.2" 20 | 21 | # hide behind main to setup can be imported to find __VERSION__ 22 | if __name__ == '__main__': 23 | 24 | import sys 25 | from setuptools import setup, find_packages 26 | 27 | DESCRIPTION = """Test SMTP/IMAP server for local integration testing""" 28 | 29 | LONG_DESCRIPTION = (open('README.rst').read() + '\n\n' + 30 | open('HISTORY.rst').read() + '\n\n' + 31 | open('AUTHORS.rst').read()) 32 | 33 | test_requirements = ['tox', 'flake8'] 34 | if sys.version_info[1] < 7: 35 | test_requirements.append('unittest2') 36 | test_suite = 'unittest2.collector' 37 | else: 38 | test_suite = 'tests' 39 | 40 | setup( 41 | name='localmail', 42 | version=__VERSION__, 43 | author='Simon Davy', 44 | author_email='simon.davy@canonical.com', 45 | url='https://launchpad.net/localmail', 46 | description=DESCRIPTION, 47 | long_description=LONG_DESCRIPTION, 48 | license='GPLv3', 49 | packages=find_packages(exclude=["tests*"]) + ['twisted.plugins'], 50 | classifiers=[ 51 | 'Development Status :: 4 - Beta', 52 | 'Environment :: Console', 53 | 'Framework :: Twisted', 54 | 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', 55 | 'Intended Audience :: Developers', 56 | 'Operating System :: POSIX', 57 | 'Programming Language :: Python :: 2.6', 58 | 'Programming Language :: Python :: 2.7', 59 | 'Programming Language :: Python :: Implementation :: CPython', 60 | 'Programming Language :: Python :: Implementation :: PyPy', 61 | 'Topic :: Communications :: Email', 62 | 'Topic :: Communications :: Email :: Mail Transport Agents', 63 | 'Topic :: Communications :: Email :: Post-Office :: IMAP', 64 | 'Topic :: Software Development :: Testing', 65 | ], 66 | include_package_data=True, 67 | install_requires=[ 68 | 'Twisted >= 11.0.0', 69 | 'jinja2 >= 2.0.0', 70 | ], 71 | tests_require=test_requirements, 72 | test_suite=test_suite, 73 | ) 74 | 75 | # Make Twisted regenerate the dropin.cache, if possible. This is necessary 76 | # because in a site-wide install, dropin.cache cannot be rewritten by 77 | # normal users. 78 | try: 79 | from twisted.plugin import IPlugin, getPlugins 80 | except ImportError: 81 | pass 82 | else: 83 | list(getPlugins(IPlugin)) 84 | -------------------------------------------------------------------------------- /localmail/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2012- Canonical Ltd 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; either version 2 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program; if not, write to the Free Software 15 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 | from twisted.application import service 17 | from twisted.internet import reactor 18 | from twisted.cred import portal, checkers 19 | from .cred import TestServerRealm, CredentialsNonChecker 20 | from .smtp import TestServerESMTPFactory 21 | from .imap import TestServerIMAPFactory 22 | from .http import TestServerHTTPFactory, index 23 | 24 | 25 | class PortReporterTCPServer(service.Service, object): 26 | 27 | def __init__(self, name, port, factory, reportPort): 28 | self.name = name 29 | self.port = port 30 | self.factory = factory 31 | self.reportPort = reportPort 32 | 33 | def privilegedStartService(self): 34 | self.listeningPort = reactor.listenTCP(self.port, self.factory) 35 | if self.reportPort is not None: 36 | self.reportPort(self.name, self.listeningPort.getHost().port) 37 | return super(PortReporterTCPServer, self).privilegedStartService() 38 | 39 | def stopService(self): 40 | self.listeningPort.stopListening() 41 | return super(PortReporterTCPServer, self).stopService() 42 | 43 | 44 | def get_portal(): 45 | localmail_portal = portal.Portal(TestServerRealm()) 46 | localmail_portal.registerChecker(CredentialsNonChecker()) 47 | localmail_portal.registerChecker(checkers.AllowAnonymousAccess()) 48 | return localmail_portal 49 | 50 | 51 | def get_factories(): 52 | auth = get_portal() 53 | smtpServerFactory = TestServerESMTPFactory(auth) 54 | imapServerFactory = TestServerIMAPFactory() 55 | imapServerFactory.portal = auth 56 | httpServerFactory = TestServerHTTPFactory(index) 57 | return smtpServerFactory, imapServerFactory, httpServerFactory 58 | 59 | 60 | def get_services(smtp_port, imap_port, http_port, callback=None): 61 | smtpFactory, imapFactory, httpFactory = get_factories() 62 | 63 | smtp = PortReporterTCPServer('smtp', smtp_port, smtpFactory, callback) 64 | imap = PortReporterTCPServer('imap', imap_port, imapFactory, callback) 65 | http = PortReporterTCPServer('http', http_port, httpFactory, callback) 66 | 67 | return smtp, imap, http 68 | 69 | 70 | def run(smtp_port=2025, 71 | imap_port=2143, 72 | http_port=8880, 73 | mbox_path=None, 74 | callback=None): 75 | from twisted.internet import reactor 76 | if mbox_path is not None: 77 | from localmail.inbox import INBOX 78 | INBOX.setFile(mbox_path) 79 | smtpFactory, imapFactory, httpFactory = get_factories() 80 | smtp = reactor.listenTCP(smtp_port, smtpFactory) 81 | imap = reactor.listenTCP(imap_port, imapFactory) 82 | http = reactor.listenTCP(http_port, httpFactory) 83 | if callback is not None: 84 | callback(smtp.getHost().port, imap.getHost().port, http.getHost().port) 85 | reactor.run(installSignalHandlers=0) 86 | 87 | 88 | def shutdown_thread(thread): 89 | from twisted.internet import reactor 90 | reactor.callFromThread(reactor.stop) 91 | thread.join() 92 | -------------------------------------------------------------------------------- /tests/spam/english-plain.txt: -------------------------------------------------------------------------------- 1 | Reply-To: 2 | From: "James B. Comey, Jr."<99@jut.com.tw> 3 | Subject: Anti-Terrorist And Monitory Crime Division? 4 | Date: Sun, 7 Sep 2014 21:28:24 -0700 5 | MIME-Version: 1.0 6 | Content-Type: text/plain; 7 | charset="Windows-1251" 8 | Content-Transfer-Encoding: 7bit 9 | X-Priority: 3 10 | X-MSMail-Priority: Normal 11 | X-Mailer: Microsoft Outlook Express 6.00.2600.0000 12 | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 13 | Message-Id: <20140908042825.3076C30F9625@mail.jut.com.tw> 14 | To: undisclosed-recipients:; 15 | X-Spam-Status: No 16 | 17 | Federal Bureau of Investigation (FBI) 18 | Anti-Terrorist And Monitory Crime Division. 19 | Federal Bureau Of Investigation. 20 | J.Edgar.Hoover Building Washington Dc 21 | 22 | Attention Beneficiary, 23 | 24 | I am James Brien. Comey Jr, the new FBI director nominated by President Barack Obama to replace the previous director Robert 25 | S. Mueller due to internal logical protocols guiding international and local transactions, my tenure represent peace, equity 26 | and justice and rule of law shall prevail, my duty is to ensure global maximum security and to protect fundamental human 27 | rights. FBI has increased their priorities because of the recent terrorist global threat, And Records here show that you are among one of the individuals and organizations who are yet to receive their overdue payment from overseas which includes those of Lottery/Gambling,Contract and Inheritance. Through our Fraud Monitory Unit we have noticed that you have been transacting with some impostors and fraudsters who have been impersonating the likes of Prof. Soludo/Mr.Lamido Sanusi of the Central Bank Of Nigeria,Rev. Obinna,Senator. David Mark, Iburahim Lamode of EFCC, Mr. Patrick Aziza, Bode Williams,Percy Jones, Mr John Freeman, Frank, Anderson, none officials of Oceanic Bank,Barclay's Bank Plc, Zenith Banks, Kelvin Young of HSBC, Ben of FedEx, Ibrahim Sule, Dr. Usman Shamsuddeen and some impostors claiming to be The Federal Bureau ofInvestigation. 28 | 29 | The Cyber Crime Division of the FBI gathered information from the Internet Fraud Complaint Center (IFCC) on how some people have lost outrageous sums of money to these impostors. As a result of this, we hereby advise you to stop communication with any one not referred to you by us. We have negotiated with the Federal Ministry of Finance that your payment totaling $10.5,000,000.00(Ten Million five Hundred Thousand Dollars). will be released to you via a custom pin based ATM card with a maximum withdrawal limit of $15,000 a day which is powered by Visa Card and can be used anywhere in the world where you see a Visa Card Logo on the Automatic Teller Machine (ATM). 30 | 31 | We guarantee receipt of your payment. This is as a result of the mandate from US/EU Government to make sure all debts owed to citizens of American, Europe and also Asia and Australia which includes Inheritance, Contract, Gambling/Lottery etc are been cleared.To redeem your funds, you are hereby advised to contact the ATM Card Center via email for their requirement to proceed and procure your Approval of Payment Warrant and Endorsement of your ATM Release Order on your behalf which will cost you $490 Usd only and nothing more as everything else has been taken care of by the Federal Government including taxes, custom paper and clearance duty so all you will ever need to pay is $490.00 only. 32 | 33 | ATM CARD COMPENSATION PAYMENT AWARD AUTHORITY 34 | Name: Lawyer Advocate Bobby Isaac. 35 | Email: advocatebobbyisaac@qq.com 36 | 37 | 38 | Do contact Mr. Bobby Isaac of the ATM Card Center via his contact details above and furnish him with your details as listed below: 39 | 40 | 1.NAME IN FULL:................................ 41 | 2.ADDRESS:....................................... 42 | 3.NATIONALITY:.................................. . 43 | 4.AGE:............................................. 44 | 5.SEX.............................................. 45 | 6.OCCUPATION:...................................... 46 | 7.MARITAL STATUS:.................................. 47 | 8.PRIVATE PHONE NO................................. 48 | 9.PRIVATE FAX NO:.................................. 49 | 10.ATTACH COPY OF YOUR IDENTIFICATION.............. 50 | 51 | On contacting him with your details your file would be updated and he will be sending you the payment information in which you will use in making payment of $490.00 via Money-Gram or Western Union Money Transfer for the procurement of your Approval of Payment Warrant and Endorsement of your ATM Release Order, after which the delivery of your ATM card will be effected to your designated home address without any further delay. 52 | 53 | Regards, 54 | James B. Comey, Jr. 55 | New Director FBI 56 | C-C -. Homeland Security Council 57 | C-C. CIA 58 | C-C- International Police Unit 59 | 60 | Note: Disregard any email you get from any impostors or offices claiming to be in possession of your ATM card, you are hereby advice only to be in contact with Mr. Bobby Isaac of the ATM card center who is the rightful person to deal with in regards to your payment and forward any emails you get from impostors to this office so we could act upon it immediately. Help stop cyber crime. 61 | -------------------------------------------------------------------------------- /tests/test_localmail.py: -------------------------------------------------------------------------------- 1 | import os 2 | import time 3 | import threading 4 | import imaplib 5 | import smtplib 6 | from email.mime.text import MIMEText 7 | from email.mime.multipart import MIMEMultipart 8 | 9 | try: 10 | import unittest2 as unittest 11 | except ImportError: 12 | import unittest # NOQA 13 | 14 | import localmail 15 | 16 | from helpers import ( 17 | SMTPClient, 18 | IMAPClient, 19 | clean_inbox, 20 | ) 21 | 22 | thread = None 23 | 24 | HOST = 'localhost' 25 | SMTP_PORT = 2025 26 | IMAP_PORT = 2143 27 | HTTP_PORT = 8880 28 | 29 | if 'LOCALMAIL' in os.environ: 30 | # use external server 31 | LOCALMAIL = os.getenv('LOCALMAIL') 32 | if ':' in LOCALMAIL: 33 | HOST, ports = LOCALMAIL.split(':') 34 | SMTP_PORT, IMAP_PORT, HTTP_PORT = ports.split(',') 35 | else: 36 | # use random ports 37 | def report(smtp, imap, http): 38 | global SMTP_PORT, IMAP_PORT, HTTP_PORT 39 | SMTP_PORT = smtp 40 | IMAP_PORT = imap 41 | HTTP_PORT = http 42 | 43 | def setUpModule(): 44 | global thread 45 | thread = threading.Thread( 46 | target=localmail.run, args=(0, 0, 0, None, report)) 47 | thread.start() 48 | time.sleep(1) 49 | 50 | def tearDownModule(): 51 | localmail.shutdown_thread(thread) 52 | 53 | 54 | class BaseLocalmailTestcase(unittest.TestCase): 55 | 56 | def setUp(self): 57 | super(BaseLocalmailTestcase, self).setUp() 58 | self.addCleanup(clean_inbox, HOST, IMAP_PORT) 59 | 60 | 61 | class AuthTestCase(BaseLocalmailTestcase): 62 | 63 | def test_smtp_any_auth_allowed(self): 64 | smtp = smtplib.SMTP(HOST, SMTP_PORT) 65 | smtp.login('a', 'b') 66 | smtp.sendmail('a@b.com', ['c@d.com'], 'Subject: test\n\ntest') 67 | smtp.quit() 68 | smtp = smtplib.SMTP(HOST, SMTP_PORT) 69 | smtp.login('c', 'd') 70 | smtp.sendmail('a@b.com', ['c@d.com'], 'Subject: test\n\ntest') 71 | smtp.quit() 72 | 73 | def test_smtp_anonymous_allowed(self): 74 | smtp = smtplib.SMTP(HOST, SMTP_PORT) 75 | smtp.sendmail('a@b.com', ['c@d.com'], 'Subject: test\n\ntest') 76 | smtp.quit() 77 | 78 | def test_imap_any_auth_allowed(self): 79 | imap = imaplib.IMAP4(HOST, IMAP_PORT) 80 | imap.login('any', 'thing') 81 | imap.select() 82 | self.assertEqual(imap.search('ALL'), ('OK', [None])) 83 | imap.close() 84 | imap.logout() 85 | 86 | imap = imaplib.IMAP4(HOST, IMAP_PORT) 87 | imap.login('other', 'something') 88 | imap.select() 89 | self.assertEqual(imap.search('ALL'), ('OK', [None])) 90 | imap.close() 91 | imap.logout() 92 | 93 | def test_imap_anonymous_not_allowed(self): 94 | imap = imaplib.IMAP4(HOST, IMAP_PORT) 95 | with self.assertRaises(imaplib.IMAP4.error): 96 | imap.select() 97 | self.assertEqual(imap.search('ALL'), ('OK', [None])) 98 | 99 | 100 | class SequentialIdTestCase(BaseLocalmailTestcase): 101 | uid = False 102 | 103 | def setUp(self): 104 | super(SequentialIdTestCase, self).setUp() 105 | self.smtp = SMTPClient(HOST, SMTP_PORT) 106 | self.smtp.start() 107 | self.imap = IMAPClient(HOST, IMAP_PORT, uid=self.uid) 108 | self.imap.start() 109 | msgs = self.imap.search('ALL') 110 | self.assertEqual(msgs, []) 111 | self.addCleanup(self.smtp.stop) 112 | self.addCleanup(self.imap.stop) 113 | 114 | def _testmsg(self, n): 115 | msg = MIMEText("test %s" % n) 116 | msg['Subject'] = "test %s" % n 117 | msg['From'] = 'from%s@example.com' % n 118 | msg['To'] = 'to%s@example.com' % n 119 | return msg 120 | 121 | def assert_message(self, msg, n): 122 | expected = self._testmsg(n) 123 | self.assertEqual(msg['From'], expected['From']) 124 | self.assertEqual(msg['To'], expected['To']) 125 | self.assertEqual(msg['Subject'], expected['Subject']) 126 | self.assertEqual(msg.is_multipart(), expected.is_multipart()) 127 | if msg.is_multipart(): 128 | for part, expected_part in zip(msg.walk(), expected.walk()): 129 | self.assertEqual(part.get_content_maintype(), 130 | expected_part.get_content_maintype()) 131 | if part.get_content_maintype() != 'multipart': 132 | self.assertEqual(part.get_payload().strip(), 133 | expected_part.get_payload().strip()) 134 | else: 135 | self.assertEqual(msg.get_payload().strip(), 136 | expected.get_payload().strip()) 137 | 138 | def test_simple_message(self): 139 | self.smtp.send(self._testmsg(1)) 140 | msg = self.imap.fetch(1) 141 | self.assert_message(msg, 1) 142 | 143 | def test_multiple_messages(self): 144 | self.smtp.send(self._testmsg(1)) 145 | self.smtp.send(self._testmsg(2)) 146 | msg1 = self.imap.fetch(1) 147 | msg2 = self.imap.fetch(2) 148 | self.assert_message(msg1, 1) 149 | self.assert_message(msg2, 2) 150 | 151 | def test_delete_single_message(self): 152 | self.smtp.send(self._testmsg(1)) 153 | self.imap.store(1, '(\Deleted)') 154 | self.imap.client.expunge() 155 | self.assertEqual(self.imap.search('ALL'), []) 156 | 157 | def test_delete_with_multiple(self): 158 | self.smtp.send(self._testmsg(1)) 159 | self.smtp.send(self._testmsg(2)) 160 | self.imap.store(1, '(\Deleted)') 161 | self.imap.client.expunge() 162 | self.assertEqual(self.imap.search('ALL'), [self.imap.msgid(1)]) 163 | 164 | def test_search_deleted(self): 165 | self.smtp.send(self._testmsg(1)) 166 | self.smtp.send(self._testmsg(2)) 167 | self.imap.store(1, '(\Deleted)') 168 | self.assertEqual( 169 | self.imap.search('(DELETED)'), 170 | [self.imap.msgid(1)] 171 | ) 172 | self.assertEqual( 173 | self.imap.search('(NOT DELETED)'), 174 | [self.imap.msgid(2)] 175 | ) 176 | 177 | 178 | class UidTestCase(SequentialIdTestCase): 179 | uid = True 180 | 181 | 182 | class MultipartTestCase(SequentialIdTestCase): 183 | 184 | def _testmsg(self, n): 185 | msg = MIMEMultipart('alternative') 186 | msg['Subject'] = 'test %s' % n 187 | msg['From'] = 'from%s@example.com' % n 188 | msg['To'] = 'to%s@example.com' % n 189 | html = MIMEText('test %s' % n, 'html') 190 | text = MIMEText('test %s' % n, 'plain') 191 | msg.attach(html) 192 | msg.attach(text) 193 | return msg 194 | -------------------------------------------------------------------------------- /localmail/inbox.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2012- Canonical Ltd 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; either version 2 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program; if not, write to the Free Software 15 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 | 17 | import random 18 | import email 19 | from email.header import decode_header 20 | import mailbox 21 | import email.utils 22 | from itertools import count 23 | from cStringIO import StringIO 24 | 25 | from zope.interface import implements 26 | 27 | from twisted.mail import imap4 28 | from twisted.python import log 29 | 30 | UID_GENERATOR = count() 31 | LAST_UID = UID_GENERATOR.next() 32 | 33 | SEEN = r'\Seen' 34 | UNSEEN = r'\Unseen' 35 | DELETED = r'\Deleted' 36 | FLAGGED = r'\Flagged' 37 | ANSWERED = r'\Answered' 38 | RECENT = r'\Recent' 39 | 40 | 41 | def get_counter(): 42 | global LAST_UID 43 | LAST_UID = UID_GENERATOR.next() 44 | return LAST_UID 45 | 46 | 47 | class MemoryIMAPMailbox(object): 48 | implements(imap4.IMailbox) 49 | 50 | mbox = None 51 | 52 | def addMessage(self, msg_fp, flags=None, date=None): 53 | if flags is None: 54 | flags = [] 55 | if date is None: 56 | date = email.utils.formatdate() 57 | msg = Message(msg_fp, flags, date) 58 | if self.mbox is not None: 59 | self.mbox.add(msg.msg) 60 | self.msgs.append(msg) 61 | self.flush() 62 | 63 | def setFile(self, path): 64 | log.msg("creating mbox file %s" % path) 65 | self.mbox = mailbox.mbox(path) 66 | 67 | def flush(self): 68 | if self.mbox is not None: 69 | log.msg("flushing mailbox") 70 | self.mbox.flush() 71 | 72 | def __init__(self): 73 | # can't use OrderedDict as need to support 2.6 :( 74 | self.msgs = [] 75 | self.listeners = [] 76 | self.uidvalidity = random.randint(1000000, 9999999) 77 | 78 | def _get_msgs(self, msg_set, uid): 79 | if not self.msgs: 80 | return {} 81 | if uid: 82 | msg_set.last = LAST_UID 83 | uids = set(msg_set) 84 | return dict((i, msg) for i, msg in enumerate(self.msgs) 85 | if msg.uid in uids) 86 | else: 87 | msg_set.last = len(self.msgs) 88 | return dict((i, self.msgs[i - 1]) for i in msg_set) 89 | 90 | def getHierarchicalDelimiter(self): 91 | return "." 92 | 93 | def getFlags(self): 94 | "return list of flags supported by this mailbox" 95 | return [SEEN, UNSEEN, DELETED, FLAGGED, ANSWERED, RECENT] 96 | 97 | def getMessageCount(self): 98 | return len(self.msgs) 99 | 100 | def getRecentCount(self): 101 | return len([m for m in self.msgs if RECENT in m.getFlags()]) 102 | 103 | def getUnseenCount(self): 104 | return len([m for m in self.msgs if UNSEEN in m.getFlags()]) 105 | 106 | def isWriteable(self): 107 | return True 108 | 109 | def getUIDValidity(self): 110 | return self.uidvalidity 111 | 112 | def getUID(self, messageNum): 113 | return self.msgs[messageNum - 1].uid 114 | 115 | def getUIDNext(self): 116 | return LAST_UID + 1 117 | 118 | def fetch(self, msg_set, uid): 119 | messages = self._get_msgs(msg_set, uid) 120 | return messages.items() 121 | 122 | def addListener(self, listener): 123 | self.listeners.append(listener) 124 | return True 125 | 126 | def removeListener(self, listener): 127 | self.listeners.remove(listener) 128 | return True 129 | 130 | def requestStatus(self, path): 131 | return imap4.statusRequestHelper(self, path) 132 | 133 | def store(self, msg_set, flags, mode, uid): 134 | messages = self._get_msgs(msg_set, uid) 135 | setFlags = {} 136 | for seq, msg in messages.items(): 137 | if mode == 0: # replace flags 138 | msg.flags = set(flags) 139 | else: 140 | for flag in flags: 141 | # mode 1 is append, mode -1 is delete 142 | if mode == 1 and flag not in msg.flags: 143 | msg.flags.add(flag) 144 | elif mode == -1 and flag in msg.flags: 145 | msg.flags.remove(flag) 146 | setFlags[seq] = msg.flags 147 | return setFlags 148 | 149 | def expunge(self): 150 | "remove all messages marked for deletion" 151 | removed = [] 152 | for i, msg in enumerate(self.msgs[:]): 153 | if DELETED in msg.flags: 154 | # use less efficient remove() because the indexes are changing 155 | self.msgs.remove(msg) 156 | removed.append(msg.uid) 157 | self.flush() 158 | return removed 159 | 160 | def destroy(self): 161 | "complete remove the mailbox and all its contents" 162 | raise imap4.MailboxException("Permission denied.") 163 | 164 | 165 | INBOX = MemoryIMAPMailbox() 166 | 167 | 168 | class MessagePart(object): 169 | implements(imap4.IMessagePart) 170 | 171 | def __init__(self, msg): 172 | self.msg = msg 173 | 174 | def getHeaders(self, negate, *names): 175 | headers = {} 176 | if negate: 177 | for header in self.msg.keys(): 178 | if header.upper() not in names: 179 | headers[header.lower()] = self.msg.get(header, '') 180 | else: 181 | for name in names: 182 | headers[name.lower()] = self.msg.get(name, '') 183 | return headers 184 | 185 | def getBodyFile(self): 186 | if self.msg.is_multipart(): 187 | raise TypeError("Requested body file of a multipart message") 188 | return StringIO(self.msg.get_payload()) 189 | 190 | def getSize(self): 191 | return len(self.msg.as_string()) 192 | 193 | def isMultipart(self): 194 | return self.msg.is_multipart() 195 | 196 | def getSubPart(self, part): 197 | if self.msg.is_multipart(): 198 | return MessagePart(self.msg.get_payload()[part]) 199 | raise TypeError("Not a multipart message") 200 | 201 | def parse_charset(self, default='utf8'): 202 | charset = self.msg.get_charset() 203 | if charset is not None: 204 | return charset 205 | 206 | if self.msg.get('Content-type'): 207 | for chunk in self.msg['Content-type'].split(';'): 208 | if 'charset' in chunk: 209 | return chunk.split('=')[1] 210 | return default 211 | 212 | def unicode(self, header): 213 | """Converts a header to unicode""" 214 | value = self.msg[header] 215 | orig, enc = decode_header(value)[0] 216 | if enc is None: 217 | enc = self.parse_charset() 218 | return orig.decode(enc) 219 | 220 | 221 | class Message(MessagePart): 222 | implements(imap4.IMessage) 223 | 224 | def __init__(self, fp, flags, date): 225 | super(Message, self).__init__(email.message_from_file(fp)) 226 | self.data = str(self.msg) 227 | self.uid = get_counter() 228 | self.flags = set(flags) 229 | self.date = date 230 | 231 | def getUID(self): 232 | return self.uid 233 | 234 | def getFlags(self): 235 | return self.flags 236 | 237 | def getInternalDate(self): 238 | return self.date 239 | 240 | def __repr__(self): 241 | h = self.getHeaders(False, 'From', 'To') 242 | return "" % (h['from'], h['to'], self.uid) 243 | 244 | def payloads(self): 245 | for part in self.msg.walk(): 246 | if part.get_content_maintype() == 'multipart': 247 | continue 248 | payload = part.get_payload(decode=True) 249 | enc = self.parse_charset() 250 | yield payload.decode(enc) 251 | -------------------------------------------------------------------------------- /tests/spam/english-multi.txt: -------------------------------------------------------------------------------- 1 | From: "CleverCards" 2 | To: 3 | Subject: Simon, Make 'em smile with an eCard for Grandparents Day! 4 | Date: Sat, 06 Sep 2014 02:31:55 -0600 5 | List-Unsubscribe: 6 | MIME-Version: 1.0 7 | Reply-To: "Cleverbug" 8 | x-job: 6162544_216723 9 | Message-ID: <79b99bff-a114-4b4f-9286-429db558a268@xtinp2mta1217.xt.local> 10 | Content-Type: multipart/alternative; 11 | boundary="6sVZg4ihw3eq=_?:" 12 | 13 | This is a multi-part message in MIME format. 14 | 15 | --6sVZg4ihw3eq=_?: 16 | Content-Type: text/plain; 17 | charset="utf-8" 18 | Content-Transfer-Encoding: 8bit 19 | 20 | To view this email as a web page, go to the link below, or copy and paste it into your browser's address window. 21 | http://click.email.cleverbug.com/?qs=bf955edeea291903ad02639833060a5fe4b205a5067f22a42e8ab31430be805dCleverBug 22 | 23 | http://click.email.cleverbug.com/?qs=bf955edeea291903c03a91c37038ad450775d715a3fd87a130de60540a9c4f39 24 | 25 | Simon, tomorrow is Grandparents Day! 26 | 27 | 28 | Don't worry if you forgot to send a printed card - you can send an eCard right now to share on Facebook or send by email. 29 | 30 | http://click.email.cleverbug.com/?qs=bf955edeea291903c03a91c37038ad450775d715a3fd87a130de60540a9c4f39 31 | 32 | What are you waiting for? It's easy. It's fast. And it's FREE! 33 | 34 | http://click.email.cleverbug.com/?qs=bf955edeea291903c03a91c37038ad450775d715a3fd87a130de60540a9c4f39 35 | 36 | http://click.email.cleverbug.com/?qs=435c69e6fe8cf81fdc19e9c49b453ac37938e2b5c088f51de453477362b96827 37 | 38 | http://click.email.cleverbug.com/?qs=bf955edeea2919039c1f5274b2a19a2eeeef5546b7e59c348bd40e15eb13f7cf 39 | 40 | http://click.email.cleverbug.com/?qs=435c69e6fe8cf81fbf4080575066232d82a60357dcf43cc83f4fecfc04f31f6a 41 | 42 | mailto:maria@cleverbug.com?subject=My question for CleverCards 43 | 44 | 45 | 46 | ---------------------------------------- 47 | 48 | This email was sent by: 49 | Cleverbug 50 | Suite 1200,1000 N West Street 51 | Wilmington, Delaware, 19801, United States 52 | 53 | We respect your right to privacy - visit the following URL to view our policy. 54 | ( http://click.email.cleverbug.com/?qs=bf955edeea291903c6f5f218a70b6e7b30f2e12f24ff3d0367967c43c9fc1173 ) 55 | 56 | ---------------------------------------- 57 | 58 | Visit the following URL to manage your subscriptions. 59 | ( http://click.email.cleverbug.com/?qs=bf955edeea291903408c34021b8a064b47c6be66fe9d1a51931abc4ca18ae9e3 ) 60 | 61 | Visit the following URL to update your profile. 62 | ( http://click.email.cleverbug.com/?qs=bf955edeea2919036af207b6b937056406474a4caeff2b077b42f8be8967ce96 ) 63 | 64 | Visit the following URL to unsubscribe. 65 | ( http://click.email.cleverbug.com/?qs=bf955edeea2919035018c366d7fb9887c8da605077edeca278cb4c8028d61834 ) 66 | 67 | 68 | --6sVZg4ihw3eq=_?: 69 | Content-Type: text/html; 70 | charset="utf-8" 71 | Content-Transfer-Encoding: 8bit 72 | 73 |

To view this email as a web page, go here.

75 | 76 | 77 | 78 | 79 | CleverBug 80 | 105 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 213 | 214 | 215 |
114 | 115 | 116 | 117 | 118 | 119 | 120 | 138 | 139 | 140 |
121 | 122 |

123 | Make 'em smile with a FREE eCard! 124 |

125 |

Simon, tomorrow is Grandparents Day!
 

126 | Don't worry if you forgot to send a printed card - you can send an eCard right now to share on Facebook or send by email.


127 |

128 | Send a FREE eCard for Grandparent's Day! 129 |

130 |

What are you waiting for? It's easy. It's fast. And it's FREE!

131 |

132 | Send Your eCard Now! 133 |

134 |

135 | 136 | 137 |
141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 156 | 157 | 158 | 159 | 160 |
150 | 151 | 152 | 153 | 154 | 155 |
161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 204 | 205 | 206 |
169 | 170 | 171 | 172 | 173 | 175 | 199 | 200 | 201 |
174 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 195 | 196 | 197 | 198 |
184 | 185 |
194 |
202 | 203 |
207 | 208 | 209 | 210 | 211 | 212 |
216 | 217 | 218 | 219 | 220 | 221 | 239 | 240 | 241 | 242 | 250 | 251 | 252 |
222 | 223 | This email was sent to: bloodearnest@gmail.com

224 | 225 | 226 | 233 | 234 |
227 | 228 | 229 | This email was sent by: Cleverbug
230 | Suite 1200,1000 N West Street Wilmington, Delaware 19801 United States 231 |
232 |

235 |
We respect your right to privacy - view our policy
236 | 237 | 238 |
243 | 244 |
245 | Manage Subscriptions | 246 | Unsubscribe 247 | 248 |
249 |
253 | 254 | 255 | 256 | --6sVZg4ihw3eq=_?:-- 257 | 258 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /tests/spam/english-html.txt: -------------------------------------------------------------------------------- 1 | Content-Type: text/html; charset=UTF-8 2 | Content-Transfer-Encoding: quoted-printable 3 | MIME-Version: 1.0 4 | From: "Confused.com" 5 | Reply-To: "Confused.com" 6 | To: bloodearnest@gmail.com 7 | Subject: =?UTF-8?B?U2ltb24sIEJSSUFOJ3MgZ290IMKjMSwwMDAsMDAwIHRvIGdpdmUgYXdheSEg?= 8 | Message-Id: <19561-175-3OOLLUU-WT99SW-62VY3S-2YX7LZ-RPNGSCG-H-M2-20140908-6ae5056a17d08@e-dialog.com> 9 | X-Mail-From: 3OOLLUU-WT99SW-62VY3S-2YX7LZ-RPNGSCG-H-M2-20140908-6ae5056a17d08@confusedcom.bounce.ed10.net 10 | X-Match: confusedcom.bounce.ed10.net 11 | X-RCPT-To: bloodearnest@gmail.com 12 | X-Mailer: EDMAIL R6.00.02 13 | List-Unsubscribe: 14 | 15 | 16 | 17 | 19 | 20 | 21 | 22 | 24 | Simon, BRIAN's got =C2=A31,000,000 to give away! 25 | 191 | 192 | =20 193 | 196 | =20 197 | 198 | 199 | 203 | 204 | 206 | 207 |
 
208 | 212 | 213 | 324 | 325 |
214 | 215 | 217 | 218 | 219 | 228 | 229 | 230 | 231 | 320 | 321 |
View this email in your web browser
232 | 233 | =20=20=20=20 234 | 236 | 237 | 247 | 248 |
3D"Confused.com"
249 | 250 | =20=20=20=20=20 251 | 252 | 254 | 255 | =20=20=20=20=20=20=20=20 318 | 319 |
256 | 258 | 259 | 262 | 272 | 282 | 292 | 302 | 306 | 316 | 317 |
Follow us:3D"Twitter=3D"Facebook=3D"Googl=3D"You= 305 |
LOG IN
322 | 323 |
326 | 327 | 328 | =20=20 329 | 330 | 331 | 332 | 333 | 334 | 338 | 339 | 446 | 447 | =20=20 448 |
340 | 341 | 343 | =20=20=20=20 344 | 345 | 365 | 385 | 405 | 424 | 443 | 444 |
348 | 349 | 357 | 361 | 362 |
Motor3D""
363 | 364 |
368 | 369 | 377 | 381 | 382 |
Home & utilities3D""
383 | 384 |
388 | 389 | 397 | 401 | 402 |
Life & family3D""
403 | 404 |
407 | 408 | 416 | 420 | 421 |
Money3D""
422 | 423 |
426 | 427 | 435 | 439 | 440 |
Travel3D""
441 | 442 |
445 |
449 | 450 | 451 | 452 | 456 | 457 | 499 | 500 |
459 | 461 | 462 | 480 | 481 | 482 | 496 | 497 |
3D"" 465 | 466 | 470 | 474 | 478 | 479 |
483 |
486 | 487 | 3D"" 493 | 494 |
495 |
498 |
501 | 502 | 505 | 506 | 755 | 756 |
508 | 510 | 511 | 752 | 753 |
512 | 513 | 514 | 515 | 522 | 523 | =20=20=20=20=20=20=20=20=20=20=20=20 524 | 525 |
Fancy winning £1,00= 518 | 0,000? Simply buy life insurance from Confused.com and enter for your chance to win!
526 | 527 | 528 | 749 | 750 |
529 | 531 | 532 | 716 | 717 |
533 | 534 | 535 | 536 | =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 537 | 538 | 539 | 634 | 635 |
540 | 541 | 542 | 569 | 579 | 580 |
543 | 544 | 545 | 562 | 566 | 567 |
546 | 547 | 548 | 552 | 553 | 554 | 559 | 560 |
3D""
3D=
561 |
3D""
568 |
At Confused.com, there's never been a better time to protect your future.= 575 | Buy life insurance now and you can enter our £Million Mega Draw for your chance to win!
581 | 582 | 583 | 611 | 631 | 632 |
584 | 585 | 586 | 604 | 608 | 609 |
587 | 588 | 589 | 593 | 594 | 595 | 600 | 601 |
3D""
3D=
602 |
603 |
3D""
610 |
614 |

With Confused.com you can compare life insurance from trusted provid= 626 | ers like Aviva, PruProtect, Legal & General and many more.

627 | If you'd prefer to speak to someone, you can call us on 0330 333 8165= 628 | , or simply request a call back and one of our friendly specialists wil= 629 | l contact you.^

630 |
633 |
636 | 637 | 638 | =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 639 | 640 | 641 | 663 | 664 |
642 | 644 | 645 | 660 | 661 |
648 | 649 | 650 | 657 | 658 |
Get a quote
659 |
662 |
665 | 666 | 667 | =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 668 | 669 | 670 | 692 | 693 |
671 | 673 | 674 | 689 | 690 |
677 | 678 | 679 | 686 | 687 |
Request a call back
688 |
691 |
694 | 695 | 696 | 697 | 698 |
700 | 701 | =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 702 | 704 | 705 | 711 | 712 |
3D""
713 | 714 |
715 |
718 | 719 | =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 720 | 722 | 723 | 730 | 731 | 732 | 746 | 747 |
3D""
733 |
735 | 736 | 3D"" 743 | 744 |
745 |
748 |
751 |
754 |
757 | 758 | 761 | 762 | 779 | 780 |
764 | 766 | 767 | 768 | 773 | 774 | =20=20=20=20=20=20=20=20 775 | 776 | 777 |
^Lines are open between 11am an= 771 | d 8.30pm Monday - Wednesday, from 10am and until 7pm on Thursday and 9am - = 772 | 4pm Friday. Calls are charged at your local rate from a mobile.
778 |
781 | 782 | 786 | 787 | 819 | 820 |
789 | 791 | 792 | 799 | 800 | 801 | 816 | 817 |
3D""
802 |
805 | 806 | 3D"" 813 | 814 |
815 |
818 |
821 | 822 | 823 | 824 | 828 | 829 | 873 | 874 | =20=20 875 |
832 | 833 | 871 | 872 |
About    &n= 841 | bsp;       Contact us  &nbs= 847 | p;         FAQs    &nb= 853 | sp;       Press    &n= 859 | bsp;       Privacy    = 865 |         Terms & conditions
876 | 880 | 881 | 893 | 894 | =20=20 895 |
882 | 883 | 887 | 888 | 890 | 891 |
 
892 |
896 | 897 | 898 | 899 | 903 | 904 | 973 | 974 |
907 | 908 | 971 | 972 |
© Copyright 2014 Confused.com. Al= 911 | l rights reserved.
912 | This email is sent for and on behalf of Inspop.com Limited trad= 913 | ing as Confused.com. Inspop.com Limited registered in England and Wales at = 914 | 3rd Floor, Greyfriars House, Greyfriars Road, Cardiff CF10 3AL (Reg. No.038= 915 | 57130). Inspop.com Limited is authorised and regulated by the Financial Con= 916 | duct Authority (Firm reference number: 310635).

Confused Life is= 917 | arranged and administered by Direct Life & Pension Services Ltd, who are a= 918 | uthorised and regulated by the Financial Conduct Authority. Registered offi= 919 | ce; Pinnacle House, A1 Barnet Way, Borehamwood, Hertfordshire WD6 2XX. Regi= 920 | stered in England, No 2467691. 921 |
922 |
923 |
If this email is not displayed correctly, please click here<= 930 | /span> | View this email in your browser
937 |
938 |
Add us to your address book
939 | To ensure our emails are delivered to your inbox please add our= 940 | address to your address book or safe sender list.
941 |
942 | Unsubscribes
943 | We are sending you this email because you registered on our web= 944 | site. If you would prefer not to receive further 945 | marketing emails from Confused.com then please 946 | =20=20=20=20=20=20=20=20=20=20=20=20 947 | =20=20=20=20=20=20=20=20=20=20=20=20 948 | click here=20 956 | =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= 957 | =20 958 | to unsubscribe.
959 | Privacy policy | Terms and conditions
975 | 976 | =20=20=20 977 | 978 | 979 | 982 | 983 | 984 | --------------------------------------------------------------------------------