2015-04-16 18:45:56 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# docker-postfix
  
						 
					
						
							
								
									
										
										
										
											2015-04-19 17:50:39 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Simple Postfix SMTP TLS relay [docker ](http://www.docker.com ) image with no local authentication enabled (to be run in a secure LAN). 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 17:28:21 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### Build instructions
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Clone this repo and then:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cd docker-Postfix
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    sudo docker build -t postfix .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-06 01:24:32 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Or you can use the provided [docker-compose ](https://github.com/juanluisbaptiste/docker-postfix/blob/master/docker-compose.yml ) files:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    sudo docker-compose -f docker-compose.yml -f docker-compose.dev.yml build
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								For more information on using multiple compose files [see here ](https://docs.docker.com/compose/production/ ). You can also find a prebuilt docker image from [Docker Hub ](https://registry.hub.docker.com/u/juanluisbaptiste/postfix/ ), which can be pulled with this command:
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 17:28:21 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    sudo docker pull juanluisbaptiste/postfix:latest
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### How to run it
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								The following env variables need to be passed to the container:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  `SMTP_SERVER`  Server address of the SMTP server to use. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  `SMTP_USERNAME`  Username to authenticate with. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*  `SMTP_PASSWORD`  Password of the SMTP user. 
						 
					
						
							
								
									
										
										
										
											2015-05-13 01:07:20 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								*  `SERVER_HOSTNAME`  Server hostname for the Postfix container. Emails will appear to come from the hostname's domain. 
						 
					
						
							
								
									
										
										
										
											2015-04-19 17:28:21 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-20 01:28:21 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								To use this container from anywhere, the 25 port needs to be exposed to the docker host server:
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 17:28:21 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-20 01:28:21 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    docker run -d --name postfix -p "25:25"  \ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								           -e SMTP_SERVER=smtp.bar.com \
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								           -e SMTP_USERNAME=foo@bar .com \
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								           -e SMTP_PASSWORD=XXXXXXXX \
							 
						 
					
						
							
								
									
										
										
										
											2015-05-13 01:08:58 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								           -e SERVER_HOSTNAME=helpdesk.mycompany.com \
							 
						 
					
						
							
								
									
										
										
										
											2015-05-03 00:32:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								           juanluisbaptiste/postfix
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 17:28:21 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								If you are going to use this container from other docker containers then it's better to just publish the port:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-20 01:28:21 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    docker run -d --name postfix -P \
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								           -e SMTP_SERVER=smtp.bar.com \
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								           -e SMTP_USERNAME=foo@bar .com \
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								           -e SMTP_PASSWORD=XXXXXXXX \
							 
						 
					
						
							
								
									
										
										
										
											2015-05-13 01:09:26 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								           -e SERVER_HOSTNAME=helpdesk.mycompany.com \           
							 
						 
					
						
							
								
									
										
										
										
											2015-05-03 00:32:50 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								           juanluisbaptiste/postfix
							 
						 
					
						
							
								
									
										
										
										
											2018-03-06 01:24:32 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Or if you can start the service using the provided [docker-compose ](https://github.com/juanluisbaptiste/docker-postfix/blob/master/docker-compose.yml ) file for production use:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    sudo docker-compose up -d
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 17:36:32 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### A note about using gmail as a relay
  
						 
					
						
							
								
									
										
										
										
											2015-04-19 17:28:21 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 17:39:10 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Since last year, Gmail by default [does not allow email clients that don't use OAUTH 2 ](http://googleonlinesecurity.blogspot.co.uk/2014/04/new-security-measures-will-affect-older.html ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 17:28:21 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								for authentication (like Thunderbird or Outlook). First you need to enable access to "Less secure apps" on your 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[google settings ](https://www.google.com/settings/security/lesssecureapps ). 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Also take into account that email `From:`  header will contain the email address of the account being used to 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-20 01:28:21 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								authenticate against the Gmail SMTP server(SMTP_USERNAME), the one on the email will be ignored by Gmail.