spatie / mailcoach-support

Questions and support for Mailcoach
https://mailcoach.app
31 stars 2 forks source link

Sendgrid feedback generate error when doesn't contain send_uuid #172

Closed electronick86 closed 4 years ago

electronick86 commented 4 years ago

Hello,

I use the sendgrid mail provider and I see that sometimes feedback do not contain eny send_uuid. This generate an Error

[2020-04-29 12:31:04] local.ERROR: Argument 1 passed to Spatie\Mailcoach\Models\Send::findByUuid() must be of the type string, null given, called in /var/www/html/vendor/spatie/laravel-mailcoach-sendgrid-feedback/src/ProcessSendgridWebhookJob.php on line 46 {"exception":"[object] (TypeError(code: 0): Argument 1 passed to Spatie\\Mailcoach\\Models\\Send::findByUuid() must be of the type string, null given, called in /var/www/html/vendor/spatie/laravel-mailcoach-sendgrid-feedback/src/ProcessSendgridWebhookJob.php on line 46 at /var/www/html/vendor/spatie/laravel-mailcoach/src/Models/Concerns/HasUuid.php:19)
[stacktrace]
#0 /var/www/html/vendor/spatie/laravel-mailcoach-sendgrid-feedback/src/ProcessSendgridWebhookJob.php(46): Spatie\\Mailcoach\\Models\\Send::findByUuid()
#1 /var/www/html/vendor/spatie/laravel-mailcoach-sendgrid-feedback/src/ProcessSendgridWebhookJob.php(33): Spatie\\MailcoachSendgridFeedback\\ProcessSendgridWebhookJob->getSend()
#2 /var/www/html/vendor/spatie/laravel-mailcoach-sendgrid-feedback/src/ProcessSendgridWebhookJob.php(27): Spatie\\MailcoachSendgridFeedback\\ProcessSendgridWebhookJob->handleRawEvent()
#3 [internal function]: Spatie\\MailcoachSendgridFeedback\\ProcessSendgridWebhookJob->handle()
#4 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(33): call_user_func_array()
#5 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php(36): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()

This exception happens when the feedback payload doesn't contains any send_uuid key.

_MySQL_5_7_28__GocarDinghyLocal_gocarmail_webhook_calls

Do I select too much feedback type on the sendgrid configuration side? SendGrid

Thanks for your help.

riasvdv commented 4 years ago

I can see there's an sg_message_id parameter in the payload, can you compare those in the payloads where send_uuid is present and see if they are the same?

Could you paste one of each payload anonimyzed? One that contains the send_uuid and one that doesn't? I might be able to find something to connect the feedback, otherwise it's a Sendgrid issue

electronick86 commented 4 years ago

Hello Rias.

I don't find any matching IDS betweens payload with uuid and without.

id  name    payload exception   created_at  updated_at
433 sendgrid-feedback   [{"email":"mail@xx","event":"open","ip":"IP_ADRESS","sg_content_type":"html","sg_event_id":"71o3k3rGQO2nRT7pQAL_kg","sg_message_id":"  .filterdrecv-p3mdw1-6dbfd75bfd-8wk2j-19-5EAABE63-E.0","timestamp":1588248245,"useragent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit\/605.1.15 (KHTML, like Gecko)"}]  NULL    2020-04-30 14:09:14 2020-04-30 14:09:14

432 sendgrid-feedback   [{"email":"mail@xx","event":"open","ip":"IP_ADRESS","sg_content_type":"html","sg_event_id":"f1nsQqENR9S_clTAum6TwQ","sg_message_id":"ayYRECIsSYqYvugQKhE_EQ.filter0073p3las1-3640-5EAABCC8-A1.0","timestamp":1588248252,"useragent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit\/605.1.15 (KHTML, like Gecko)"}]  NULL    2020-04-30 14:08:55 2020-04-30 14:08:55

I can maybe ask sendgrid a bit more but theses message without send_uuid should maybe be ignored?

I just sent some more campaign test emails (from the campaign > delivery tab) and I received that kind of feedback when I opened/clicked the content of the test email.

Just to be sure that this is the way to configure sendgrid : my env file is

MAIL_MAILER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=25
MAIL_USERNAME=apikey
MAIL_PASSWORD=the_key

and I don't set specific mailer into config/mailcoach.php at the moment

riasvdv commented 4 years ago

Hi @electronick86, did you contact Sendgrid about this already? I can't seem to find a reason why it would be empty for some webhook calls

I'm closing this issue for now, as this doesn't seem something we have control over, but if you receive some feedback from Sendgrid, do let me know here :)

electronick86 commented 4 years ago

Hello Rias, I contact them again about this topic.

electronick86 commented 4 years ago

Hello @riasvdv ,

Sorry for this issue. I realized that I use the same API key for my app email (the app don't send other emails than the campaigns, except the campaigns reports and that kind of emails).

So the feedback witout send_uuid is just feedback from others emails send from the same sendgrid subaccount.

Thanks for help!