Sending an email with attachment by using Amazon SES Services

Amazon Simple Email Service (Amazon SES)

“” script can send an email with an attachment by using Amazon SES services (Amazon Simple E-mail Services). It needs the AWS Cli tool.


You have to just install the AWS CLI tool. There are many ways to install the Amazon Web Service Command Line Client (aka AWS Cli) including using pip package manager, homebrew package manager or just downloading the raw executables.( As a Mac user, I prefer to use Homebrew ( )


After installing AWS Cli, you must configure the credential file. You can use this command:

This command asks your aws access key and secret key and region.

AWS Secret Access Key [None]: je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY
Default region name [None]: us-east-1

Normally you can use just aws command to send a simple email without any attachment.

But if you want to send an email with an attachment, you must use a raw message. AWS uses a JSON file format to prepare a raw message.

I used some variables like {FROM}, {SUBJECT}, etc.. Because I am planning to change these variables with script arguments and create dynamic a raw message file.

Here it is…

You should use base64 encoding to send an email smoothly. After adding some checks and parsing command-line arguments and assigning values, our script is ready.

Here it is a simple and easy use script. How can use it? The help is included :)

Example Usings


If you are lazy or have more important jobs, you can find this code on my Github repo. :)

DevOps & Software & Architect & Linux Geek —

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store