Difference between revisions of "Postfix docker relay"
Jump to navigation
Jump to search
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
# Run docker container for relay using uvoo/email-relay | # Run docker container for relay using uvoo/email-relay | ||
+ | - https://github.com/uvoo/containers/tree/main/uvoo/email-relay | ||
+ | - You usually want to remove -e SMTP_TLS_SECURITY_LEVEL="none" line so it requires encrypted communictions | ||
``` | ``` | ||
docker rm postfix -f || true | docker rm postfix -f || true |
Latest revision as of 00:35, 12 June 2024
Run docker container for relay using uvoo/email-relay
- https://github.com/uvoo/containers/tree/main/uvoo/email-relay
- You usually want to remove -e SMTP_TLS_SECURITY_LEVEL="none" line so it requires encrypted communictions
docker rm postfix -f || true mkdir -p data cd data mkdir -p keys logs spool_postfix sudo chmod 0755 keys logs spool_postfix cd ../ docker run -p 8587:25 \ -e SMTP_USERNAME=tester@localhost \ -e SMTP_USERPASS=PleaseChangeMe \ -e SMTP_USERS="tester@localhost:PleaseChangeMe tester1@localhost:PleaseChangeMe" \ -e MYNETWORKS="127.0.0.0/8 172.16.0.0/12 10.210.77.1/32" \ -e DKIM_DOMAINS="example.com" \ -e DKIM_SELECTORS="default mail" \ -e MYHOSTNAME="localrelay.example.com" \ -e RELAYHOST="relay.example.com:587" \ -e SMTP_TLS_SECURITY_LEVEL="none" \ -v ${PWD}/data/keys:/etc/opendkim/keys \ -v ${PWD}/data/logs:/var/log/mail\ -v ${PWD}/data/spool_postfix:/var/spool/postfix \ --hostname localrelay.example.com \ --name postfix -d uvoo/email-relay
Test email
#!/usr/bin/python3 import smtplib from email.mime.text import MIMEText # Email details from_addr = f"noreply@example.com" to_addr = f"jeremy.busk@example.com" subject = "Hello" body = "This is a test email." # Create the email msg = MIMEText(body) msg["Subject"] = subject msg["From"] = from_addr msg["To"] = to_addr # Send the email server = smtplib.SMTP("localhost", 8587) server.send_message(msg) server.quit() print("Email sent.")