diff --git a/moto/core/exceptions.py b/moto/core/exceptions.py index 14d0a394d..b177c63da 100644 --- a/moto/core/exceptions.py +++ b/moto/core/exceptions.py @@ -31,7 +31,7 @@ ERROR_RESPONSE = """ {{error_type}} - {{message}} + {% block extra %}{% endblock %} diff --git a/tests/test_ses/test_ses_boto3.py b/tests/test_ses/test_ses_boto3.py index fcf218cb7..8a43eaf5d 100644 --- a/tests/test_ses/test_ses_boto3.py +++ b/tests/test_ses/test_ses_boto3.py @@ -114,6 +114,32 @@ def test_send_email_when_verify_source(): sent_count.should.equal(2) +@mock_ses +def test_send_unverified_email_with_chevrons(): + conn = boto3.client("ses", region_name="us-east-1") + + # Sending an email to an unverified source should fail + with pytest.raises(ClientError) as ex: + conn.send_email( + Source=f"John Smith ", # << Unverified source address + Destination={ + "ToAddresses": ["blah@example.com"], + "CcAddresses": [], + "BccAddresses": [], + }, + Message={ + "Subject": {"Data": "Hello!"}, + "Body": {"Html": {"Data": "Hi"}}, + }, + ) + err = ex.value.response["Error"] + err["Code"].should.equal("MessageRejected") + # The source should be returned exactly as provided - without XML encoding issues + err["Message"].should.equal( + "Email address not verified John Smith " + ) + + @mock_ses def test_send_templated_email(): conn = boto3.client("ses", region_name="us-east-1")