Skip to content

Commit 700ca04

Browse files
Preparing for merge into master
2 parents a943d7d + 298aeab commit 700ca04

6 files changed

Lines changed: 46 additions & 9 deletions

File tree

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ install:
77
- python setup.py install
88
script:
99
- if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then unit2 discover; else python -m unittest discover; fi
10-
1110
notifications:
1211
hipchat:
1312
rooms:

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## [1.4.3] - 2015-10-22
5+
### Fixed
6+
- Reply To header now supports friendly name [#110](https://github.com/sendgrid/sendgrid-python/issues/110)
7+
8+
## [1.4.2] - 2015-09-15
9+
### Added
10+
- Upgrade Mail to new-style class, on Python 2.x.
11+
412
## [1.4.1] - 2015-09-09
513
### Added
614
- Classifiers for compatible python versions

README.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ Warning
1212

1313
If you upgrade to version ``1.2.x``, the ``add_to`` method behaves differently. In the past this method defaulted to using the ``SMTPAPI`` header. Now you must explicitly call the ``smtpapi.add_to`` method. More on the ``SMTPAPI`` section.
1414

15+
Announcements
16+
-------------
17+
18+
For users of our `Web API v3 endpoints`_, we have begun integrating v3 endpoints into this library. As part of this process we have implemented a test automation tool, TOX_. We are also updating and enhancing the core library code.
19+
20+
In no particular order, we have implemented a few of the v3 endpoints already and would appreciate your feedback. Please feel free to submit issues and pull requests on the `v3_beta branch`_.
21+
22+
Thank you for your continued support!
23+
1524
Install
1625
-------
1726

@@ -504,3 +513,6 @@ MIT License
504513
.. _Category: http://sendgrid.com/docs/Delivery_Metrics/categories.html
505514
.. _Unique Arguments: http://sendgrid.com/docs/API_Reference/SMTP_API/unique_arguments.html
506515
.. _Filter: http://sendgrid.com/docs/API_Reference/SMTP_API/apps.html
516+
.. _`Web API v3 endpoints`: https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html
517+
.. _TOX: https://testrun.org/tox/latest/
518+
.. _`v3_beta branch`: https://github.com/sendgrid/sendgrid-python/tree/v3_beta

sendgrid/message.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ def __init__(self, **opts):
4343
self.html = opts.get('html', '')
4444
self.bcc = []
4545
self.add_bcc(opts.get('bcc', []))
46-
self.reply_to = opts.get('reply_to', '')
46+
self.reply_to = ''
47+
self.set_replyto(opts.get('reply_to', ''))
4748
self.files = opts.get('files', {})
48-
self.set_headers(opts.get('headers', ''))
49+
self.headers = {}
50+
self.set_headers(opts.get('headers', {}))
4951
self.date = opts.get('date', rfc822.formatdate())
5052
self.content = opts.get('content', {})
5153
self.smtpapi = opts.get('smtpapi', SMTPAPIHeader())
@@ -123,7 +125,18 @@ def add_bcc(self, bcc):
123125
self.add_bcc(email)
124126

125127
def set_replyto(self, replyto):
126-
self.reply_to = replyto
128+
name, email = rfc822.parseaddr(replyto.replace(',', ''))
129+
if name and email:
130+
self.set_reply_to_name(replyto)
131+
elif email:
132+
self.reply_to = email
133+
134+
def set_reply_to_name(self, replyto):
135+
headers = {
136+
"Reply-To": replyto
137+
}
138+
self.reply_to = ''
139+
self.set_headers(headers)
127140

128141
def add_attachment(self, name, file_):
129142
if sys.version_info < (3, 0) and isinstance(name, unicode):
@@ -146,10 +159,14 @@ def add_content_id(self, cid, value):
146159
self.content[cid] = value
147160

148161
def set_headers(self, headers):
162+
if sys.version_info < (3, 0) and isinstance(headers, unicode):
163+
headers = headers.encode('utf-8')
164+
if isinstance(self.headers, str):
165+
self.headers = json.loads(self.headers)
149166
if isinstance(headers, str):
150-
self.headers = headers
151-
else:
152-
self.headers = json.dumps(headers)
167+
headers = json.loads(headers)
168+
for key, value in headers.items():
169+
self.headers[key] = value
153170

154171
def set_date(self, date):
155172
self.date = date

sendgrid/sendgrid.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
import json
23
from socket import timeout
34
from .version import __version__
45
try:
@@ -71,7 +72,7 @@ def _build_body(self, message):
7172
'text': message.text,
7273
'html': message.html,
7374
'replyto': message.reply_to,
74-
'headers': message.headers,
75+
'headers': json.dumps(message.headers) if message.headers else '',
7576
'date': message.date,
7677
'x-smtpapi': message.json_string()
7778
}

sendgrid/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version_info = (1, 4, 1)
1+
version_info = (1, 5, 3)
22
__version__ = '.'.join(str(v) for v in version_info)

0 commit comments

Comments
 (0)