I have Traefik as a reverse proxy. Behind Traefik are sitting containers with nginx+php+mysql (domain1-com, domian2-com, domain3-com).
I want to send emails (from PHP scripts) from addresses such as peter@domain1-com, betty@domain2-com. If somebody responds to any of my emails I want to just redirect incoming email to something@gmail-com.
Which image should I use or how to solve it? (easiest way) I’ll be using SSL, DKIM, SPF … .
Do you want to run a local E-mail server? Because this is something that an e-mail server should do. I tan my email server locally years ago and I also configured SPF and DKIM. Later I realized I didn’t need the local server. I could use Email Hosting | Secure Business Email for your organization - Zoho Mail for free and create rules to forward emails to anywhere. I could change my domain’s MX record on the DNS server (you can also ask your domain provider) so it pointed to zoho. This way you could even have multiple aliases to one email account if you don’t want to forward emails to gmail.
You do the same with GMail but when I last checked that, it was not free.
Your scripts should use SMTP to send emails so you don’t really need to install anything inside the container, at least I don’t remember anything. You can find SMTP mailer frameworks for any programming language.
To send emails from PHP scripts in your containers and redirect incoming email to a Gmail address, you can use an email relay service that supports SMTP. Here is a high-level overview of the steps you can take to set this up:
Choose an email relay service: There are many email relay services available, such as SendGrid, Mailgun, and Amazon SES. Another option would be to extract email addresses from LinkedIn. Choose a service that supports SMTP and has a good reputation for deliverability.
Configure your email relay service: Follow the instructions provided by your email relay service to configure your account, set up SMTP credentials, and configure any necessary authentication methods (such as DKIM and SPF).
Configure your PHP application: Update your PHP application to use the SMTP credentials provided by your email relay service. You can use a PHP library such as PHPMailer or SwiftMailer to handle sending emails via SMTP.
Configure your email forwarding: Set up email forwarding for the email addresses you want to redirect to your Gmail address. You can do this by configuring the MX records for your domain(s) to point to a third-party email forwarding service, or by setting up a forwarding rule in your Gmail account.
Test and monitor: Test your email sending and forwarding to ensure everything is working as expected. Monitor your email deliverability and adjust your configuration as needed to improve it.