Skip to content

How to add unsubscribe header? #1045

Open
@addsimm

Description

@addsimm

Issue Summary

I'm trying to add an unsubscribe header and the docs are not very clear, then tech support told me to ask here ...

Here is my code from Django 3.9, which is working fine:

    from sendgrid import SendGridAPIClient
    from sendgrid.helpers.mail import Mail, To

    for lead_page in lead_paginator.page_range:
        sents = sents + '----------------lead_page: ' + str(lead_page)
        to_emails = []
        for lead in lead_paginator.page(lead_page).object_list:
            pixel_url = 'e=' + lead.lead_email + '&s=' + e_archive.subject_slug

            one_to_email = To(email=lead.lead_email,
                    name=lead.first_name,
                    substitutions={
                            '<< first_name >>': first,
                            '<< pixel_url >>': pixel_url
                    },
                    subject=e_archive.subject)

            to_emails.append(one_to_email)

        message = Mail(
                from_email=('[email protected]', 'xxxxx'),
                to_emails=to_emails,
                subject=e_archive.subject,
                html_content=e_html,
                is_multiple=True)

So where do I add an unsubscribe header based off of the pixel_url, so its personalized; something like:

  "headers": {
    "List-Unsubscribe": "<https://xxxxx.com/download/?<< pixel_url >>&p=unsubscribe>"
  }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions