Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting "InvalidParameterValue - Missing final '@domain'" from Amazon SES while sending an email with unicode characters in destination address

Amazon SES returns the error mentioned above when i try to send an email that contains unicode characters in the To: field. Amazon SES Documentation says that such email addresses should be sent in MIME encoded-word syntax, which the mail gem (used by ActionMailer) is doing correctly, it is sent as: =?UTF-8?B?dmluYXl2aW5heeKAmXNAbWFpbGluYXRvci5jb20=?=

like image 579
vinayvinay Avatar asked Jan 23 '14 10:01

vinayvinay


2 Answers

I was seeing this same error, and found it was due to an incorrect ReturnPath parameter. The error indicates your ReturnPath parameter does not have a domain name. The ReturnPath parameter should be an email address, and it's the address to which bounce notifications are forwarded.

like image 99
James Bowler Avatar answered Oct 23 '22 10:10

James Bowler


The question is pretty old, but I'll add my case for it seems to be the first result searching for problems with "Missing finale @domain" on AWS SES.

(the only other SO question I found is AWS SES Missing final '@domain' PHP SDK )

As in the other question's answer, InvalidParameterValue is returned every time a parameter don't pass validation.

In my case I was using boto3 on python, composing the Destination parameter with some keys that could be empty, like so:

to = []
bcc = []
# Some code to populate one or both lists..
response = client.send_email(
        Destination={
            'ToAddresses': to,
            'BccAddresses': bcc
        },
        Message={
            'Body': {
                'Html': {
                    'Charset': MAIL_CHARSET,
                    'Data': message,
                },
                'Text': {
                    'Charset': MAIL_CHARSET,
                    'Data': message,
                },
            },
            'Subject': {
                'Charset': MAIL_CHARSET,
                'Data': subject,
            },
        },
        Source=MAIL_SENDER,
    )

If one of the two keys in the dict assigned to the Destination parameter was an empty list the InvalidParameterValue was returned. Solution is to simply remove empty, useless, key:

to = []
bcc = []
# Some code to populate one or both lists..
destinations = {
            'ToAddresses': to,
            'BccAddresses': bcc
        }
response = client.send_email(
        Destination={typ: addresses
                     for typ, addresses in destinations.iteritems()
                     if addresses},
        Message={
            'Body': {
                'Html': {
                    'Charset': MAIL_CHARSET,
                    'Data': message,
                },
                'Text': {
                    'Charset': MAIL_CHARSET,
                    'Data': message,
                },
            },
            'Subject': {
                'Charset': MAIL_CHARSET,
                'Data': subject,
            },
        },
        Source=MAIL_SENDER,
    )
like image 35
Hrabal Avatar answered Oct 23 '22 10:10

Hrabal