Giter Club home page Giter Club logo

aws-ses-sender's Introduction

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

Install

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.(http://docs.aws.amazon.com/cli/latest/userguide/installing.html) As a Mac user, I prefer to use Homebrew ( https://brew.sh/ )

brew install awscli

or

pip3 install --upgrade --user awscli

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

aws configure

Usage

You can get help with -h or --help argument.

$ sh sender.sh -h

Usage: sender.sh [-h|--help ]
        [-s|--subject <string> subject/title for email ]
        [-f|--from <email> ]
        [-r|--receiver|--receivers <emails> coma seperated emails ]
        [-b|--body <string> ]
        [-a|--attachment <filename> filepath ]
        [--aws-region <string> Change Default AWS Region ]
        [--aws_access_key_id <string> Change AWS Access Key ID ]
        [--aws_secret_access_key <string> Change AWS Secret Access Key ]

######Examples

sh sender.sh -s test -f [email protected] -r [email protected] -b "mail content" -a ~/Documents/Projects/batur/test.html 
sh sender.sh -s test -f [email protected] -r [email protected] -b "mail content" -a ~/Documents/Projects/batur/test.html --aws-region us-east-1

aws-ses-sender's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

aws-ses-sender's Issues

Missing required header 'From'

I tested your script on both OSX and on AWS EC2 node (AWS Linux image)

I get Missing From in both cases.

/usr/local/opt/coreutils/libexec/gnubin/base64

An error occurred (InvalidParameterValue) when calling the SendRawEmail operation: Missing required header 'From'.```

A few issues to fix

I was unable to get the script to work as-is and needed to make the following changes on macOS Big Sur:

Line 50: ATTACHMENT=base64 -i $ATTACHMENT needs to change to: ATTACHMENT=base64 -e $ATTACHMENT (note the replacement of the -i with -e ... it also works if you omit -e completely)

Line 65: add another line: sed -i -e "s/$(printf '\r')//g" $TMPFILE (the script as written adds extra CR characters which make the JSON illegal). This removes those extra CRs.

Line 66: aws ses send-raw-email --raw-message file://$TMPFILE needs to change to: aws ses send-raw-email --cli-binary-format raw-in-base64-out --raw-message file://$TMPFILE

Even after fixing these issues, this script still won't work with large attachments because sed simply can't deal with them. Refer: https://unix.stackexchange.com/questions/546906/sed-command-giving-argument-list-too-long-error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.