jdavidbakr / mail-tracker

Package for Laravel to inject tracking code into outgoing emails.
MIT License
562 stars 129 forks source link

AWS SNS delivered, complaint, and bounce notifications not working #220

Closed Wyatt-NAT closed 1 year ago

jdavidbakr commented 1 year ago

When creating an issue please provide relevant details.

Wyatt-NAT commented 1 year ago

Hello @jdavidbakr

Hope you are doing well.

After installation of this package, I got the mail-tracker.php configuration file. I am using AWS SES and SNS to handle the email processes.

In the configuration file you have provided to add the 'sns-topic' => null, in this I have added the topic ARN which is arn:aws:sns:us-east-1:xxxxxxxxxxxx:email-notifications but I am unable to get that notification in the listeners.

Can you please provide more details about the AWS SES and SNS configuration? The sent, viewed and link clicked work well but the delivered, complaint, and bounce notifications not working.

The delivered, complaint, and bounce notifications are working when I have provided the HTTPS URL to the SNS and I am handling it in the laravel controller. In the controller.

e.g.

$data = $request->json()->all();

if ($data['Type'] == 'SubscriptionConfirmation') {
    Log::info('SubscriptionConfirmation');
    file_get_contents($data['SubscribeURL']);
} elseif ($data['Type'] == 'Notification') {
    $message = json_decode($data['Message'], true);
}

Using above code I am able to log the notifications but using the listeners I am unable to log the notifications.

Please guide me about the configuration.

Wyatt-NAT commented 1 year ago

Do I have to add the subscription URL as https://domain.com/email/sns in the AWS SNS Topic? If yes then do I also need to exclude this route from CSRF verification?

dekts commented 1 year ago

I am also facing the similar issue:

/**
 * Where should the pingback URL route be?
 */
'route' => [
    'prefix' => 'email',
    'middleware' => ['api'],
],

Do I have to change the middleware in this configuration? Is this related to the SNS callback URL?