Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS javascript SDK SES SendMail Illegal Address

I'm attempting to send mail using AWS SES.

Here's the error I'm seeing:

{
    "message": "Illegal address",
    "code": "InvalidParameterValue",
    "time": "2017-06-02T03:12:37.110Z",
    "requestId": "544c6aee-4741-11e7-9cf5-a709f069aa99",
    "statusCode": 400,
    "retryable": false,
    "retryDelay": 73.04001529701054
}

Here's the request object being passed in to SendMail method of AWS.SES for javascript SDK.

{
    "Destination": {
        "BccAddresses": [],
        "CcAddresses": [],
        "ToAddresses": [
            "[email protected]"
        ]
    },
    "Message": {
        "Body": {
            "Html": {
                "Charset": "UTF-8",
                "Data": "You have been removed from Kudo mailing list for account: [email protected]"
            },
            "Text": {
                "Charset": "UTF-8",
                "Data": "You have been removed from Kudo mailing list for account: [email protected]"
            }
        },
        "Subject": {
            "Charset": "UTF-8",
            "Data": "Kudo email removal"
        }
    },
    "ReplyToAddresses": [],
    "ReturnPath": "",
    "ReturnPathArn": "",
    "Source": "[email protected]",
    "SourceArn": "arn:aws:ses:us-west-2:1xxxxxxxxxx2:identity/[email protected]"
}

[email protected] is verified on my account (which is still in sandbox mode). [email protected] is also verified on my account.

Edit: I just tested it by using the test email option in SES and it worked... still can't get it to send using the SDK though.

like image 663
CamHart Avatar asked Jun 02 '17 03:06

CamHart


1 Answers

Okay, the key is to remove the empty strings for ReturnPath and ReturnPathArn and SourceArn if you aren't using it. Once I did that it worked.

Source: https://forums.aws.amazon.com/thread.jspa?messageID=787424&#787424

{
    "Destination": {
        "BccAddresses": [],
        "CcAddresses": [],
        "ToAddresses": [
            "[email protected]"
        ]
    },
    "Message": {
        "Body": {
            "Html": {
                "Charset": "UTF-8",
                "Data": "You have been removed from Kudo mailing list for account: [email protected]"
            },
            "Text": {
                "Charset": "UTF-8",
                "Data": "You have been removed from Kudo mailing list for account: [email protected]"
            }
        },
        "Subject": {
            "Charset": "UTF-8",
            "Data": "Kudo email removal"
        }
    },
    "ReplyToAddresses": [],
    "Source": "[email protected]"
}
like image 56
CamHart Avatar answered Oct 16 '22 08:10

CamHart