Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/loopingz/aws-smtp-relay

Local SMTP server that convert SMTP message to AWS SES API Call to allow you to use role instance
https://github.com/loopingz/aws-smtp-relay

Last synced: 3 months ago
JSON representation

Local SMTP server that convert SMTP message to AWS SES API Call to allow you to use role instance

Awesome Lists containing this project

README

        

# aws-smtp-relay

[DEPRECATED] I moved to this project instead: https://github.com/loopingz/smtp-relay
It should have similar features with more flexibility, please create issue on the new project

![logo](https://raw.githubusercontent.com/loopingz/aws-smtp-relay/master/docs/aws-smtp-relay-logo.png)

Current main:

[![CodeQL](https://github.com/loopingz/aws-smtp-relay/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/loopingz/aws-smtp-relay/actions/workflows/codeql-analysis.yml)
[![CI](https://github.com/loopingz/aws-smtp-relay/actions/workflows/ci.yml/badge.svg)](https://github.com/loopingz/aws-smtp-relay/actions/workflows/ci.yml)

Local SMTP server that convert SMTP message to AWS SES API Call to allow you to use **AWS Role Instance**.

If you follow the AWS SES postfix relay : http://docs.aws.amazon.com/ses/latest/DeveloperGuide/postfix.html

You can have a simple relay for your email, this issue with it is you have to create SMTP credentials.

To follow AWS Best practices you need to rotate those keys at least every 90 days, so the AWS Role are easier to use.

Sending an email with Postfix relay looks like this :

![Postfix Schema](https://raw.githubusercontent.com/loopingz/aws-smtp-relay/master/docs/postfix.png)

Sending an email with aws-smtp-relay looks like this :
![aws-smtp-relay Schema](https://raw.githubusercontent.com/loopingz/aws-smtp-relay/master/docs/aws-smtp-relay.png)

## Compile

Just run the maven project

```
git clone https://github.com/loopingz/aws-smtp-relay.git
cd aws-smtp-relay
mvn clean compile assembly:single
```

## Run

Take the result of your compilation or download the static jar here

```
java -jar aws-smtp-relay.jar
```

**By default the SMTP run on port 10025**

### Arguments

```
usage: aws-smtp-relay
-a,--sourceArn AWS Source ARN of the sending authorization policy
-b,--bindAddress Address to listen to
-c,--configuration AWS SES configuration to use
-f,--fromArn AWS From ARN of the sending authorization policy
-p,--port Port number to listen to
-r,--region AWS region to use
-al --authLambda Name of AWS Lambda to invoke for authentication
-smtpH,--smtpHost SMTP variable Host
-smtpO,--smtpOverride Not use SES but set SMTP variables t/f true/false
-smtpP,--smtpPort SMTP variable Port
-smtpU,--smtpUsername SMTP variable Username
-smtpW,--smtpPassword SMTP variable password
-ssm,--ssmEnable Use SSM Parameter Store to get configuration
-ssmP,--ssmPrefix SSM prefix to find variables default is /smtpRelay
-ssmR,--ssmRefresh SSM refresh rate to reload parameter
-t,--returnPathArn AWS Return Path ARN of the sending authorization policy
-h,--help Display this help
```
"/smtpRelay" can be changed with -ssmP

smtpOverride allows you to point it to a mail catcher such as [MailHog](https://github.com/mailhog/MailHog/) to disable outbound email

If ssm (Simple Systems Manager) Parameter store is used please add to your region
https://ap-southeast-2.console.aws.amazon.com/systems-manager/parameters
once setup, you can change the configuration by restarting the service or rebooting the ec2 instance

```
/smtpRelay/region
/smtpRelay/configuration
/smtpRelay/sourceArn
/smtpRelay/fromArn
/smtpRelay/smtpOverride
/smtpRelay/smtpHost
/smtpRelay/smtpPort
/smtpRelay/smtpUsername
/smtpRelay/smtpPassword
```

"/smtpRelay" can be changed with -ssmP/--ssmPrefix

smtpOverride allows you to point it to a mail catcher such as [MailHog](https://github.com/mailhog/MailHog/) to disable outbound email

# Docker hub

You have a Docker image available

```
docker run -p 10025:10025 loopingz/aws-smtp-relay
```

# IAM Policy

Use this IAM Policy JSON to allow sending emails.

```
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "ses:SendRawEmail",
"Resource": "*"
}
]
}
```

## IAM Policy for SSM Paramater store access

Use this IAM Policy JSON to allow SSM Paramater variables to be used instead of the command line
Replace ```$SSMKEY``` with KMS key arn for the alias aws/ssm i.e. ```arn:aws:kms:ap-southeast-2:111222333444:key/111111111-2222-3333-4444-555555555555```

```
{
"Statement": [
{
"Effect": "Allow",
"Action": [
"ssm:DescribeParameters"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"ssm:GetParameters",
"ssm:GetParameter",
"ssm:GetParametersByPath"
],
"Resource": [
"arn:aws:ssm:*:*:parameter/smtpRelay",
"arn:aws:ssm:*:*:parameter/smtpRelay/*"
]
},
{
"Effect": "Allow",
"Action": [
"kms:Decrypt"
],
"Resource": [
"$SSMKEY"
]
}
]
}
```

# Changelog

* argument `````--smtpPW````` is now ```--smtpW```
* SSM refresh rate to reload parameter added (```-ssmR,--ssmRefresh ```)
* AWS From ARN of the sending authorization policy added (```-f,--fromArn ```)