Skip to content

setSubscriptionTracking 4th parameter $substitution_tag #1126

@milanIntermaps

Description

@milanIntermaps

Can someone exmplain me how that substitution_tag works?

$email = new Mail();
        
        $email->setClickTracking(true, true);
        $email->setOpenTracking(true, "--sub--");
        $email->setSubscriptionTracking(
            true,
            "subscribe",
            "<bold>subscribe</bold>",
            "%%sub%%"
        );

        $email->setSubject("Sending with Twilio SendGrid is Fun 2");

        $email->addTo("[email protected]", "Example User");

        $email->setFrom("[email protected]", "Twilio SendGrid");

        $email->setGlobalSubject("Sending with Twilio SendGrid is Fun and Global 2");

        $email->addContent(
            "text/plain",
            "and easy to do anywhere %%sub%% , even with PHP"
        );
        $email->addContent(
            "text/html",
            "<strong>and easy to do anywhere %%sub%% , even with PHP</strong>"
        );

        $email->setAsm(629);
        $email->setFooter(true, "Footer %%sub%% YEY", "<strong>Footer %%sub%% YEY</strong>");

        $sendgrid = new \SendGrid('...');
        try {
            $response = $sendgrid->send($email);
            print $response->statusCode() . "\n";
            print_r($response->headers());
            print $response->body() . "\n";
        } catch (Exception $e) {
            echo 'Caught exception: '.  $e->getMessage(). "\n";
        }

I would expect that to do something with %%sub%% at any of the places, but nothing happend.

It gives me PLAIN like this

and easy to do anywhere %%sub%% , even with PHP
Unsubscribe From This List http://.../asm/unsubscribe/?user_id=...&data=... | Manage Email Preferences http://.../asm/?user_id=...&data=...
Footer %%sub%% YEY

It gives me HTML like this

<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
><strong>and easy to do anywhere %%sub%% , even with PHP</strong><a href=3D=
"http://.../asm/unsubscribe/?user_id=...&amp;data=...">Unsubscribe From This List</a> | <a href=3D"http://.../asm/?user_id=...&amp;data=...">Manage Email Preferences</a>
<strong>Footer %%sub%% YEY</strong><img src=3D"http://...=
/wf/open?upn=..." alt=3D=
"" width=3D"1" height=3D"1" border=3D"0" style=3D"height:1px !important;wid=
th:1px !important;border-width:0 !important;margin-top:0 !important;margin-=
bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padd=
ing-top:0 !important;padding-bottom:0 !important;padding-right:0 !important=
;padding-left:0 !important;">=

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions