You should only follow these instructions when you've installed Mailcoach in an existing app.
First off, make sure you have created an account with Mailgun and that you have verified your domain with them. Check Mailgun's documentation on how to do this.
Go to your Domain settings in Mailgun and make sure the Click tracking and Open tracking options are enabled:
Mailgun needs to know where to send your campaigns' statistics. Go to your Mailcoach Mail config page (in the user menu on the top right), select Mailgun as your driver, and copy the webhook that is mentioned in your Mail configuration:
Then, go to the Webhooks submenu in Mailgun, and, with the webhook URL that you copied in the last step, add new webhooks for the following event types: Clicks, Opens, Permanent Failure, and Spam Complaints:
For Mailcoach to know the statistics are trustworthy, it needs to know your Mailgun HTTP webhook signing key, which you can find on the same page:
Copy it, and paste it in the Webhook signing secret field in your mail configuration:
Mailcoach still needs to know where to send its emails, so go to Overview page in your Mailgun dashboard, select the API option, then cURL and take note of the API key and API base URL that are now visible:
Go to your Mail configuration page in Mailcoach, and fill in the fields:
Mails per second: this will be different according to your Mailgun plan, you can find an appropriate value for this in your Mailgun dashboard
Domain: the same domain you did the setup for in Mailgun
Secret: the API key you copied in the last step
Endpoint: the API base URL that you copied in the last step, but without the https:// and everything after the top-level domain (.net in my case)
#Handling Mailgun feedback in an existing Laravel app
The spatie/laravel-mailcoach-mailgun-feedback package can handle bounce feedback coming from Mailgun. All e-mail address that permanently bounce will be unsubscribed from all lists.
At the webhooks settings screen, on mailgun, you must add the clicked, complained, opened and permanent_fail webhooks and point them to the route you configured. In the screenshot below we configured the webhooks using a ngrok.io domain.
At the domain settings you must enable click and open tracking
In the mailcoach config file you must add this section.
// in config/mailcoach.php'mailgun_feedback' => [
'signing_secret' => env('MAILGUN_SIGNING_SECRET'),
In your .env you must add a key MAILGUN_SIGNING_SECRET with the Mailgun signing secret you'll find at the Mailgun dashboard as its value.
Before start sending campaigns via Mailgun we highly recommend getting in touch with their support and let them know the amount of mails your email list contains. Usually they will adjust the sending limits of your account so it's not a problem to send a large volumes in a short amount of time.