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=?=
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.
ReturnPath
parameter didn't fix it for me. Must be something else. –
Crone 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,
)
Reply-To:"[email protected]"
, which should be Reply-To:[email protected]
. –
Bluing I was getting this error when using the SES SendRawEmail
API because my entire "To" header was being encoded in MIME encoded-words syntax as a unit.
It's not completely clear from the documentation, but it hints that the sender name should be encoded separately.
The sender name (also known as the friendly name) may contain non-ASCII characters. These characters must be encoded using MIME encoded-word syntax, as described in RFC 2047. MIME encoded-word syntax uses the following form: =?charset?encoding?encoded-text?=.
Python's email.message.Message
class automatically encodes headers containing non-ascii characters as a single chunk:
from email.message import Message
message1 = Message()
message1["To"] = "Recipiént <[email protected]>"
print(message1.as_string())
# To: =?utf-8?b?UmVjaXBpw6ludCA8Zm9vQGJhci5jb20+?=
I worked around this by formatting the address in advance using the formataddr
utility function, which does the encoding for the sender name separately:
from email.utils import formataddr
message2 = Message()
message2["To"] = formataddr(("Recipiént", "[email protected]"))
print(message2.as_string())
# To: =?utf-8?q?Recipi=C3=A9nt?= <[email protected]>
I just got this error because I was storing email addresses in a .cfg file (which uses the same structure as a Windows .ini file) and I put quotes around the email address like programmers are in the habit of doing with strings but that you shouldn't do in a cfg file:
[email_settings]
email_to="[email protected]"
When I removed the quotes, it worked. I'm sure there are multiple issues that can cause this error.
I think this error might have occurred for different reasons. So it might be possible that there may be case-specific reasons, and one solution might not work every time.
I'm using the @aws-sdk/client-ses
JS SDK. In my case, I was facing it while providing an address as an empty string, null, or undefined.
© 2022 - 2024 — McMap. All rights reserved.