GithubHelp home page GithubHelp logo

markushinz / aws-ses-pop3-server Goto Github PK

View Code? Open in Web Editor NEW
36.0 2.0 12.0 886 KB

The missing POP3 ๐Ÿ’Œ server for Amazon Simple Email Service - written in golang.

License: Apache License 2.0

Go 98.69% Dockerfile 1.31%
mail email pop3 pop3-server aws aws-ses aws-s3 go golang ses

aws-ses-pop3-server's Introduction

aws-ses-pop3-server ๐Ÿ’Œ

CI Quality Gate Status

The missing POP3 server for Amazon Simple Email Service - written in golang. Tested with Apple Mail 16.0 on macOS 12.5.1, Apple Mail on iOS 15.6.1 and Microsoft Outlook for Mac 16.64.

AWS SES is powerful when it comes to sending emails but has only limited functionality to receive them. Officially, only storing them in Amazon S3 and triggering Amazon Lambda functions is supported (in certain regions such as eu-west-1).

This implementation serves a fully compliant RFC1939 POP3 server backed with an S3 bucket for SES.

Docker ๐Ÿณ / docker-compose / Kubernetes

markushinz/aws-ses-pop3-server

Hint: If you want to deploy aws-ses-pop3-server to Kubernetes check this tutorial on how to configure your NGINX Ingress Controller.

Linux / macOS

sudo curl -L "https://github.com/markushinz/aws-ses-pop3-server/releases/latest/download/aws-ses-pop3-server-$(uname -m)-$(uname -s)" -o /usr/local/bin/aws-ses-pop3-server
sudo chmod +x /usr/local/bin/aws-ses-pop3-server
aws-ses-pop3-server

Usage

First, follow the official tutorial Receiving Email with Amazon SES to store emails in a S3 bucket.

Next, create an IAM user that has read and write permissions to the desired S3 bucket.

Create a config file using one of the supported authentication/authorization ways (listed below) and start the server.

Restrict access to your local machine or use TLS!

Finally, configure your favorite email client ๐Ÿฅณ. Follow the official tutorial Using the Amazon SES SMTP Interface to Send Email to obtain SMTP credentials for sending emails.

1) JSON Web Tokens (JWTs)

Provide all required information the server needs to access an S3 bucket via a JWT. To ensure that a malicious user cannot trick the server into authenticating against AWS with arbitrary credentials, the server checks the signature and the exp property of JWTs. If exp is not specified tokens do not expire.

To use JWTs, provide a JWT secret via the config and provide jwt as user and the a signed JWT with the following content as password:

{
    "awsAccessKeyID": "AKIAIOSFODNN7EXAMPLE",
    "awsSecretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
    "awsSessionToken": "...",
    "region": "eu-central-1",
    "bucket": "aws-ses-pop3-server",
    "prefix": ""
}

awsSessionToken is only used for STS (short-term) credentials.

This does not work with Gmail! Gmail enforces a maximum character length for POP3 credentials that is smaller than the expected length of JWTs.

2) HTTP(S) basic auth

Perform a GET request to retrieve all required information the server needs to access an S3 bucket. The GET request transmits user and password via basic auth and expects the response to have status code 200 and a JSON body that follows the same format as the JWT content (see above).

3) Static credentials

Just accept one hardcoded pair or user and password. You have to provide all information required to access one (!) S3 bucket via the config. If no additional information is provided the server will behave like there are no emails.

Change the default values for user and password!

Config

aws-ses-pop3-server can be configured using environment variables and / or a config file. aws-ses-pop3-server looks for config files at the following locations and in the depicted order:

  • /etc/aws-ses-pop3-server/config.yaml
  • $HOME/.aws-ses-pop3-server/config.yaml (~/.aws-ses-pop3-server/config.yaml)
  • $(pwd)/config.yaml (present working directory)

Environment variables use the prefix POP3_ followed by the config key where - have to be replaced with _. Environment variables take precedence.

Check the following example config.yaml for possible keys:

# GENERAL SETTINGS
host: "localhost" # optional, defaults to "" (or 0.0.0.0; [::];  listening on all NICs)
port: 2110 # optional, defaults to 2110 (or 2995 if you specified tls-cert / tls-key or tls-cert-path / tls-key-path)
tls-cert: |- # optional, only valid in combination with tls-key, takes precedence over tls-cert-path / tls-key-path
  -----BEGIN CERTIFICATE-----
  [ ... ]
  -----END CERTIFICATE-----
tls-key: |- # optional, only valid in combination with tls-cert, takes precedence over tls-cert-path / tls-key-path
  -----BEGIN PRIVATE KEY-----
  [ ... ]
  -----END PRIVATE KEY-----
tls-cert-path: "etc/aws-ses-pop3-server/tls.crt"  # optional, only valid in combination with tls-key-path
tls-key-path: "etc/aws-ses-pop3-server/tls"  # optional, only valid in combination with tls-cert-path
verbose: false # optional, defaults to false



# JWT PROVIDER SETTINGS
jwt-secret: "k2ya2iTNRdlsixVuTi00" # optional



# HTTP BASIC AUTH SETTINGS (only effictive if jwt-secret is not set)
http-basic-auth-url: "http://localhost" # optional
http-basic-auth-url-insecure: false # optional, defaults to false. If set to true non-localhost URLs using the insecure http protocol will not be rejected



# STATIC CREDENTIALS SETTINGS (only effictive if neither jwt-secret nor http-basic-auth-url are set)
user: "[email protected]" # optional, defaults to "user"
password: "6xRkiWA4mZBSaNmv" # optional, defaults to "changeit". DO CHANGE IT!

# The following aws-* keys are optional but required if you want to load emails
# These values have to be set here and are not inferred from other envrionment variables or ~/.aws/credentials
# aws-session-token is only used for STS-based keys
# You need read and write permissions to the desired S3 bucket
aws-access-key-id: "AKIAIOSFODNN7EXAMPLE"
aws-secret-access-key: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
aws-session-token: "..."

# The following aws-s3-* keys are required iff you set aws-access-key-id and aws-secret-access-key
aws-s3-region: "eu-central-1"
aws-s3-bucket: "aws-ses-pop3-server"
aws-s3-prefix: "" # optional, defaults to "" (set this if the emails are not stored in the root directory of the S3 bucket)

aws-ses-pop3-server's People

Contributors

dependabot[bot] avatar jarrod-lowe avatar markushinz avatar renovate[bot] avatar

Stargazers

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

Watchers

 avatar  avatar

aws-ses-pop3-server's Issues

Multiple e-mail accounts on Mozilla Thunderbird

When using the same POP3 server domain name e.g. email.example.com and one more account with a jwt username Mozilla Thunderbird (maybe, on other clients too) shows the error:

An account with that user name and server name already exists. Please enter a different user name and/or server name.

Currently, the POP3 server is checking if the username matches the string jwt. Maybe we can change the validation logic a bit and look just for substring jwt in a username, for example, user@jwt. Or even check if the password matches a valid JWT token (it's better I guess) and ignore the username field and as a consequence allow any name to make sure of account uniqueness.

Does it make sense, what do you think?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

dockerfile
Dockerfile
  • golang 1.22.2@sha256:450e3822c7a135e1463cd83e51c8e2eb03b86a02113c89424e6f0f8344bb4168
  • alpine 3.19.1@sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761f8e1ad6b
github-actions
.github/workflows/ci.yaml
  • actions/checkout v4@b4ffde65f46336ab88eb53be808477a3936bae11
  • markushinz/actions v1.1.10
  • actions/setup-go v5
  • docker/setup-buildx-action v3
  • docker/login-action v3
  • markushinz/actions v1.1.10
  • docker/build-push-action v5
.github/workflows/merge.yaml
gomod
go.mod
  • go 1.21
  • github.com/aws/aws-sdk-go v1.51.21
  • github.com/golang-jwt/jwt v3.2.2+incompatible
  • github.com/spf13/viper v1.18.2
  • github.com/stretchr/testify v1.9.0
pre-commit
.pre-commit-config.yaml
  • pre-commit/pre-commit-hooks v4.6.0

  • Check this box to trigger a request for Renovate to run again on this repository

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.