Mark Amery
Mark Amery

Reputation: 155115

Unknown parameter in Destination: "ReplyToAddresses", must be one of: ToAddresses, CcAddresses, BccAddresses

If I try to use Boto 3 to send an email with SES with a Reply-To header that doesn't match some other header in the email, using a script like this...

import boto3
client = boto3.client('ses')
client.send_email(
    Destination={
        'ToAddresses': [
            "someone@example.com"
        ],
        'ReplyToAddresses': [
            "someoneelse@example.com"
        ]
    },
    Message={
        'Body': {
            'Text': {
                'Charset': "UTF-8",
                'Data': 'Bla bla bla',
            },
        },
        'Subject': {
            'Charset': "UTF-8",
            'Data': 'Bla bla bla',
        },
    },
    Source="My Company <noreply@example.com>",
)

... then I receive an error like this:

Traceback (most recent call last):
  File "/Users/markamery/test.py", line 24, in <module>
    Source="My Company <noreply@shielddx.com>",
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/client.py", line 320, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/client.py", line 596, in _make_api_call
    api_params, operation_model, context=request_context)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/client.py", line 632, in _convert_to_request_dict
    api_params, operation_model)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/validate.py", line 291, in serialize_to_request
    raise ParamValidationError(report=report.generate_report())
botocore.exceptions.ParamValidationError: Parameter validation failed:
Unknown parameter in Destination: "ReplyToAddresses", must be one of: ToAddresses, CcAddresses, BccAddresses

This doesn't make much sense to me. What I'm trying to do here seems to be a best practice (see https://stackoverflow.com/a/14555043/1709587) and according to https://forums.aws.amazon.com/thread.jspa?threadID=60093&tstart=0, as of 2011, you can use "any email address" in the "Reply-To" header.

What causes this error? Have SES's rules been changed again since that forum post from 2011? Is the error I see above an undocumented restriction for accounts that are in the sandbox, like mine? Or is this a bug - is Boto 3, on the client side, applying stricter validation of ReplyToAddresses than the AWS API itself does?

Upvotes: 1

Views: 760

Answers (1)

Taek
Taek

Reputation: 1024

According to the boto3 docs you need to put the list of reply-to adresses in an argument outside of the Destinations argument. It seems strange to me too.

send_mail(
    ...,
    Destination={...},
    ReplyToAddresses=[
        'someoneelse@example.com',
])

Upvotes: 1

Related Questions