The mail service
Every Waddle project with mail enabled exposes a Docker service called
mail. All services in the project (PHP, Node etc.) forward outbound mail to
this endpoint, regardless of environment. The endpoint address and port never change, only where mails is relayed.
- Locally, the
mailservice is MailCatcher, a fake SMTP server that catches all outgoing mail and displays it in a web interface. No mail actually leaves the machine. - On remotes, the
mailservice is a dedicated SMTP relay container that accepts mail from the project’s internal network and forwards it to a real external SMTP provider (e.g. Gmail, Mailgun, SendGrid).
How PHP, Node, etc. send mail
PHP’s built-in mail() function doesn’t speak SMTP directly, it execs a sendmail-compatible
binary configured via sendmail_path in php.ini. Waddle installs
msmtp inside the PHP container and sets it as that binary.
msmtp is configured to connect to host mail on the project’s internal SMTP port (default 1025)
with no authentication; it just drops the message on the internal network. The mail container
takes it from there.
Node and other services that send mail follow the same pattern: point at host mail on the
configured port, no credentials needed.
Why use a separate relay container?
Three reasons for keeping the relay as its own container rather than pointing msmtp straight at the external SMTP provider:
-
Credential isolation. The SMTP password is injected only into the relay container’s environment at deploy time. The PHP (and Node) containers never see it. A compromised application container can still send mail through the relay, but it cannot read the password or reconfigure where mail goes.
-
Single exit point. Any service in the project, PHP, Node, a background worker, sends mail through the same relay. There is one place to audit, rotate credentials, or disable outbound mail entirely.
-
Environment symmetry. The msmtp config inside PHP is identical in every environment (
host mail, no auth). No per-environment branching is needed inside the application containers.