Code Monkey home page Code Monkey logo

postfix-relay-kubernetes's Introduction

Postfix relay running in Kubernetes

This repository has an example of a postfix relay running in Kubernetes using a helm chart.

Build Docker image

You can build the Docker image locally

docker build -t eldada-docker-examples.bintray.io/postfix-relay:0.6 Docker/

Run locally with Docker

Run the postfix relay locally for testing

# Need to set SMTP connection details
export SMTP="[smtp.mailgun.org]:587"
export USERNAME=<your smtp username>
export PASSWORD=<your smtp password>

# Optional custom configuration to add/override in /etc/postfix/main.cf (delimited by a ";")
export POSTFIX_CUSTOM_CONFIG="key1 = value1;key2 = value2;key3 = value3"

# Set list of allowed networks
export TX_SMTP_RELAY_NETWORKS='10.0.0.0/8,127.0.0.0/8,172.17.0.0/16,192.0.0.0/8'

docker run --rm -d --name postfix-relay -p 2525:25 \
	-e TX_SMTP_RELAY_HOST="${SMTP}" \
	-e TX_SMTP_RELAY_MYHOSTNAME=my.local \
	-e TX_SMTP_RELAY_USERNAME=${USERNAME} \
	-e TX_SMTP_RELAY_PASSWORD=${PASSWORD} \
	-e TX_SMTP_RELAY_NETWORKS=${TX_SMTP_RELAY_NETWORKS} \
	-e POSTFIX_CUSTOM_CONFIG="${POSTFIX_CUSTOM_CONFIG}" \
	eldada-docker-examples.bintray.io/postfix-relay:0.6

Test sending mail

  1. Connect to running container on port 2525
telnet localhost 2525
  1. Edit the following with your details and paste in your terminal
helo localhost
mail from: [email protected]
rcpt to: [email protected]
data
Subject: Subject here...
The true story of swans singing Pink Floyd. 
.
quit
  1. You should see the following
220 tx-smtp-relay.yourhost.com ESMTP Postfix
helo localhost
250 tx-smtp-relay.yourhost.com
mail from: [email protected]
250 2.1.0 Ok
rcpt to: [email protected]
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
Subject: Subject here...
The true story of swans singing Pink Floyd. 
.
250 2.0.0 Ok: queued as 982FF53C
quit
221 2.0.0 Bye
Connection closed by foreign host
  1. Check the inbox of [email protected] and see you got the email.

Deploy Helm Chart

The Helm Chart in helm/postfix directory can be used to deploy the postfix-relay into your Kubernetes cluster.

The Chart will deploy 2 pods (for high availability), load balanced with a service, exposing port 25.

# Need to set SMTP connection details
export SMTP="[smtp.mailgun.org]:587"
export USERNAME=<your smtp username>
export PASSWORD=<your smtp password>

helm upgrade --install postfix-relay \
        --set smtp.relayHost=${SMTP} \
        --set smtp.relayMyhostname=my.local \
        --set smtp.relayUsername=${USERNAME} \
        --set smtp.relayPassword=${PASSWORD} \ 
        helm/postfix

Thanks

This work is based on examples from https://github.com/applariat/kubernetes-postfix-relay-host

postfix-relay-kubernetes's People

Contributors

eldada avatar colmm99 avatar slavoo avatar

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.