Skip to content

Instantly share code, notes, and snippets.

@unicoder88
Created April 12, 2020 08:44
Show Gist options
  • Save unicoder88/c244486f99c9d9822e89125d74a3338a to your computer and use it in GitHub Desktop.
Save unicoder88/c244486f99c9d9822e89125d74a3338a to your computer and use it in GitHub Desktop.

Using containerized Mailcatcher with default php mail()

docker network create mailcatcher-net
docker run -d -p 1080:1080 -p 1025:1025 --name mailcatcher --rm --network mailcatcher-net schickling/mailcatcher
sudo usermod -aG docker www-data
# php.ini
sendmail_path = /usr/bin/docker run --rm --network mailcatcher-net -i schickling/mailcatcher catchmail --smtp-ip mailcatcher --smtp-port 1025 -f some@from.address

# test in bash
echo "Subject: sendmail test" | docker run --rm --network mailcatcher-net schickling/mailcatcher catchmail --smtp-ip mailcatcher --smtp-port 1025 -f some@from.address some@to.address

# test in PHP CLI `php -a`
print_r(mail('some@to.address', 'Testing CLI mail', time()));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment