Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SPF and DKIM Authentication for Outgoing Emails in Docker Compose #327

Open
dennysubke opened this issue Mar 6, 2025 · 0 comments
Open

Comments

@dennysubke
Copy link

Add SPF and DKIM Authentication for Outgoing Emails in Docker Compose

Description

Currently, the outgoing emails sent from the anonaddy Docker container are being blocked by Gmail due to unauthenticated sending. Gmail's error message indicates that the email is not passing SPF and DKIM checks. In order to ensure successful email delivery, it's essential to implement proper email authentication mechanisms like SPF and DKIM.

Proposed Changes

  1. SPF Configuration:
  • Add an SPF record for the domain used by anonaddy to the DNS settings. This will help Gmail and other mail providers authenticate the sending server.

  • The SPF record should allow the IP address of the server to send emails on behalf of the domain.

    Example SPF record:

v=spf1 ip4:<YOUR_SERVER_IP> -all

  1. DKIM Configuration:
  • Integrate OpenDKIM (or another DKIM signing tool) into the Docker container to sign outgoing emails with a DKIM key.
  • Generate DKIM keys (public and private) and configure the container to sign emails using the private key.
  • Add the public DKIM key as a TXT record to the DNS settings for the domain.

Steps for DKIM:

  • Generate DKIM keys:
    opendkim-genkey -s mail -d example.com
  • Configure OpenDKIM to sign emails and store the private key in the container.
  • Add the public DKIM key to the DNS as a TXT record:
    mail._domainkey.example.com. IN TXT "v=DKIM1; k=rsa; p=<YOUR_PUBLIC_DKIM_KEY>"
    
  1. Mail Server Configuration:
  • Ensure that the mail server (e.g., Postfix) inside the Docker container is configured to use the DKIM signing tool to sign outgoing messages.
  • Update Docker Compose configuration to expose necessary ports (e.g., SMTP ports 25 and 587) and provide the required environment variables for DKIM signing.

Benefits

  • Prevent emails from being marked as spam or bounced by mail providers like Gmail.
  • Improve email deliverability and ensure proper email authentication.

Additional Information

  • This issue is critical for users who wish to send authenticated emails from the anonaddy service, especially those using it with custom domains.
  • Please refer to the official guides for configuring SPF and DKIM for more details.

Thank you for considering this enhancement!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant