3

I'd like to dynamically set unsubscribe links using Sendgrid in my PHP/Laravel similar to how its been demonstrated with Ruby on Rails.

I see that I need to set a header with JSON. Can someone help figure out how this header gets integrated with a simple signup confirm code? See below:

Mail::send('emails.confirmation', ['user' => $user, 'resend_text' => $resend_text], function ($m) use ($user, $resend_text) {
    $m->to($user->email)->subject('Confirm your email address'.$resend_text);
});
Community
  • 1
  • 1
tim peterson
  • 23,653
  • 59
  • 177
  • 299

1 Answers1

6

I ended up setting the substitution text via sendgrid.com and setting the link in my HTML like this <a href="UNSUBSCRIBE_LINK">Unsubscribe</a>. Specifically, on the subscription tracking section on sendgrid.com, I set REPLACEMENT TAG to UNSUBSCRIBE_LINK. So Sendgrid parses your email's HTML and substitutes the hrefs. Pretty cool.

tim peterson
  • 23,653
  • 59
  • 177
  • 299