Merge pull request #2820 from bblommers/bug/2264

SES - Parse email address on verification
This commit is contained in:
Steve Pulec 2020-03-19 19:39:45 -05:00 committed by GitHub
commit 0903f6a4a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -91,9 +91,11 @@ class SESBackend(BaseBackend):
return host in self.domains
def verify_email_identity(self, address):
_, address = parseaddr(address)
self.addresses.append(address)
def verify_email_address(self, address):
_, address = parseaddr(address)
self.email_addresses.append(address)
def verify_domain(self, domain):

View File

@ -214,3 +214,16 @@ def test_send_raw_email_without_source_or_from():
kwargs = dict(RawMessage={"Data": message.as_string()})
conn.send_raw_email.when.called_with(**kwargs).should.throw(ClientError)
@mock_ses
def test_send_email_notification_with_encoded_sender():
sender = "Foo <foo@bar.baz>"
conn = boto3.client("ses", region_name="us-east-1")
conn.verify_email_identity(EmailAddress=sender)
response = conn.send_email(
Source=sender,
Destination={"ToAddresses": ["your.friend@hotmail.com"]},
Message={"Subject": {"Data": "hi",}, "Body": {"Text": {"Data": "there",}}},
)
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)