Sendgrid change text and style for group unsubscribe links

1.1k Views Asked by At

I'm facing one problem while sending emails with SendGrid. I'm sending normal email with assigning unsubscribe ground id. And when sending email then getting two links Unsubscribe From This List and Manage Email Preferences. Now my requirement is that I want to change these link texts from

  1. Unsubscribe From This List => Unsubscribe
  2. Manage Email Preferences => Update Preferences

And also links are not coming in the bottom of email. I want these after footer texts.

I'm not using marketing emails. Below is the one email screen-shot which I got:- enter image description here

And below is the code for sending email. I'm using Laravel for sending emails:-

public function sendMail()
{
    $status = \Mail::send('emails.demo', ['name' => "testdata"], function($message)
    {
        $args = [
            'asm_group_id' => 3169

        ];
        $message->getHeaders()->addTextHeader('X-SMTPAPI', json_encode($args));
       $message->to('[email protected]', 'Test User')->subject('This is a demo!');
    });
}

Please suggest me if anyone have idea how can I achieve this.

1

There are 1 best solutions below

0
On

Check this package. https://github.com/s-ichikawa/laravel-sendgrid-driver .

This is the correct format for the above package:

$send = \Mail::send('emails.tests.tests', compact([]),
        function (Message $message) use (
            $subject, $from_email, $from_name, $to_emails, $to_name ) {
            $message->subject($subject)
                //->attach($pathToFile)
                //->to($to_emails)
                ->to($to_emails, $to_name)
                //->cc($cc_email)
                ->from($from_email, $from_name)
                ->embedData([
                    'asm' => ['group_id' => 123],
                ],
                    'sendgrid/x-smtpapi');
        });

if you are not using this package then

        $status = Mail::send('emails.test', compact('data_var'), function($message)
    {
        $args = [
            'asm_group_id' => 123

        ];

        $message->from('[email protected]','from name');
        $message->getHeaders()->addTextHeader('X-SMTPAPI', json_encode($args));
        $message->to('[email protected]', 'Test User')
            ->subject('This is a demo!');
    });