s-ichikawa / laravel-sendgrid-driver

This library can add sendgrid driver into the laravel's mail configure.
MIT License
391 stars 91 forks source link

Message id #100

Closed basvandertogt closed 5 years ago

basvandertogt commented 5 years ago

How can i retrieve the message id from Sendgrid after the mail is sent?

s-ichikawa commented 5 years ago

The send function does not generally return the result value and you can not receive the message id. But you can do it by the little hack. as following:

  1. Create a class extends Swift_Events_SendListener, and implement the sendPerformed function to get the message id. https://github.com/s-ichikawa/laravel58/blob/master/app/Console/Commands/Mail/ApiSimple.php#L76-L95
  2. Get SwiftMailer from Mailer and register the class created above and re-set SwiftMailer to Mailer. https://github.com/s-ichikawa/laravel58/blob/master/app/Console/Commands/Mail/ApiSimple.php#L49-L51
s-ichikawa commented 5 years ago

Mailable pattern: https://github.com/s-ichikawa/laravel58/blob/master/app/Console/Commands/Mail/ApiSimpleMailable.php#L40-L42

s-ichikawa commented 5 years ago

Sorry, it could be more simple: https://github.com/s-ichikawa/laravel58/commit/fdc0dbb3db847db4bbf4477ca4f9249aa8d2ed57

s-ichikawa commented 5 years ago

@basvandertogt Did you resolve the issue?

s-ichikawa commented 5 years ago

Please re-open the issue if you have a problem yet.