Search code examples
bashamazon-ses

AWS CLI: for amazon ses: An error occurred (InvalidParameterValue) when calling the SendRawEmail operation: Missing required header 'To'


Since I've been wrestling with Chat GPT over this for a bit I figure someone else is going to have this problem in the future. Here's the skinny:

I've written a script that I want to send emails from an internal build process. It works fine on my mac but we have trouble on our ci and Linux servers.

What we get on Linux is An error occurred (InvalidParameterValue) when calling the SendRawEmail operation: Missing required header 'To'.


Solution

  • I worked fixing this for an embarrassingly long period of time rewriting this several times and then boiling it down to a single command line that I could run it on macos and Linux. This command was complete with the encoded base64 to remove as many variables as possible. It worked like a champ on the mac but not on Linux as predicted. I tried using the 'destinations' flag rather than the message headers... re-encoding and decoding on Linux but nothing worked.

    Finally, on a whim, I looked AWS permissions. Sure enough - there were no perms granted for SES. I updated my IAM permissions to grant full SES permissions (AmazonSESFullAccess) to CI and our Linux server roles. This fixed the issue!