dmcbrn / laravel-email-database-log

A simple database logger for all outgoing emails sent by Laravel website.
MIT License
15 stars 12 forks source link

Configurable toggle for filtering unknown emails when handling MailGun events. #10

Closed kentdahl closed 2 years ago

kentdahl commented 3 years ago

Adds toggle whether MailGun events for (currently) unknown emails should be discarded or not.

This is useful when introducing this package in a system that is already using MailGun with a bit of volume.

With the aggressive attempts at MailGun for getting mails out, you could see up to a few weeks of events being retried as emails are retried again and again by the system.

It is also useful if you often purge / clean out the log table and MailGun still has events related to those mails now deleted from the log table. Similarly when you jump between testing servers and move the MailGun webhooks, the avalanche of unknowns gets cumbersome.

P.S.: The env('MAILGUN_SECRET', null), was also changed into a config due to recommendations regarding Laravel configuration caching. (TL;DR: Never use env outside of config\ folder.)

dmcbrn commented 2 years ago

Hey, sorry for the very late reply. Can you add the changes to the readme file as well?

I'd only state something on the lines:


This is a breaking change. Please update the config file by adding

    'mailgun' => [
        'secret' => env('MAILGUN_SECRET', null),
        'filter_unknown_emails' => env('EMAIL_LOG_MAILGUN_FILTER_UNKNOWN_EMAILS', true),
    ],

at the end of the array.

I'll merge it afterwards.

dmcbrn commented 2 years ago

Hey, please look at the 5.2.2. release

This fix will not work.

FIX option 1:

FIX option 2 (seems like better approach):