Skip to content

Mailgun

Justin Rhodes edited this page Aug 20, 2025 · 2 revisions

Mailgun Mail Driver

This application supports sending emails via the Mailgun driver.

Setup

  1. Add the following to your .env file:
    MAIL_MAILER=mailgun
    MAILGUN_DOMAIN=your-mailgun-domain
    MAILGUN_SECRET=your-mailgun-api-key
    MAIL_FROM_ADDRESS=your@email.com
    MAIL_FROM_NAME="Your Name"
    
  2. Get the API Key from 1Password Bison vault.
  3. Ensure the mailgun/mailgun-php package is installed (Bison includes this by default).
  4. Configuration is managed in config/mail.php and config/services.php.

All application emails will use Mailgun when these settings are active.


Testing the Mail Driver

The app:test-mail-driver console command allows you to verify your mail driver (including Mailgun) is configured correctly.

Usage:

php artisan app:test-mail-driver recipient@example.com
  • Replace recipient@example.com with the email address to send a test email to.
  • The command is disabled in the production environment.
  • The command validates the email address and sends a test email using the current mail driver.
  • If successful, you’ll see: Test email sent.

Prompt for Missing Argument: If you omit the email address, the command will prompt you to enter it interactively.


For more details, see the implementation in app/Console/Commands/TestMailDriver.php.

Clone this wiki locally