-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge develop branch for 4.0.2 release.
- Loading branch information
Showing
14 changed files
with
199 additions
and
73 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
from collections import namedtuple | ||
|
||
|
||
version_info = namedtuple('version_info', ('major', 'minor', 'micro', 'releaselevel', 'serial'))(4, 0, 1, 'final', 0) | ||
version_info = namedtuple('version_info', ('major', 'minor', 'micro', 'releaselevel', 'serial'))(4, 0, 2, 'final', 0) | ||
version = ".".join([str(i) for i in version_info[:3]]) + ((version_info.releaselevel[0] + str(version_info.serial)) if version_info.releaselevel != 'final' else '') | ||
|
||
author = namedtuple('Author', ['name', 'email'])("Alice Bevan-McGregor", '[email protected]') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# encoding: utf-8 | ||
|
||
try: | ||
import requests | ||
|
||
except ImportError: | ||
raise ImportError("You must install the requests package to deliver mail mailgun.") | ||
|
||
|
||
__all__ = ['MailgunTransport'] | ||
|
||
log = __import__('logging').getLogger(__name__) | ||
|
||
|
||
|
||
class MailgunTransport(object): # pragma: no cover | ||
__slots__ = ('ephemeral', 'keys', 'session') | ||
|
||
API_URL_TMPL = "https://api.mailgun.net/v3/{domain}/messages.mime" | ||
|
||
def __init__(self, config): | ||
if 'domain' in config and 'key' in config: | ||
self.keys = {config['domain']: config['key']} | ||
else: | ||
self.keys = config.get('keys', {}) | ||
|
||
if not self.keys: | ||
raise ValueError("Must either define a `domain` and `key` configuration, or `keys` mapping.") | ||
|
||
self.session = None | ||
|
||
def startup(self): | ||
self.session = requests.Session() | ||
|
||
def deliver(self, message): | ||
domain = message.author.address.rpartition('@')[2] | ||
if domain not in self.keys: | ||
raise Exception("No API key registered for: " + domain) | ||
|
||
uri = self.API_URL_TMPL.format(domain=domain) | ||
|
||
result = self.session.post(uri, auth=('api', self.keys[domain]), | ||
data = {'from': message.author, 'to': list(str(i) for i in message.recipients), | ||
'subject': message.subject}, | ||
files = {"message": ('message.mime', message.mime.as_bytes())}) | ||
|
||
result.raise_for_status() | ||
|
||
def shutdown(self): | ||
if self.session: | ||
self.session.close() | ||
|
||
self.session = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,38 @@ | ||
[pytest] | ||
addopts = --flakes --spec --cov-report term-missing --cov-report html --cov-report xml --no-cov-on-fail --cov marrow.mailer -l --durations=5 -r fEsxw --color=yes test/ | ||
[aliases] | ||
test = pytest | ||
|
||
[check] | ||
metadata = 1 | ||
restructuredtext = 1 | ||
|
||
[clean] | ||
build-base = .packaging/build | ||
bdist-base = .packaging/dist | ||
|
||
[build] | ||
build-base = .packaging/build | ||
|
||
[install] | ||
optimize = 1 | ||
|
||
[bdist] | ||
bdist-base = .packaging/dist | ||
dist-dir = .packaging/release | ||
|
||
[bdist_wheel] | ||
bdist-dir = .packaging/dist | ||
dist-dir = .packaging/release | ||
|
||
[register] | ||
strict = 1 | ||
|
||
[tool:pytest] | ||
addopts = --flakes --cov-report term-missing --cov-report xml --no-cov-on-fail --cov marrow.mailer -l --durations=5 -r fEsxw --color=auto test | ||
|
||
flakes-ignore = | ||
test/*.py UnusedImport | ||
test/*/*.py UnusedImport | ||
|
||
[wheel] | ||
universal=1 | ||
universal = 1 | ||
|
Oops, something went wrong.