I'm using a dynamic template created in the visual editor for a transactional email. I used the standard Footer module, which includes placeholders for [Sender_Name], [Sender_Address], etc. I can't figure out how to fill those placeholders with my information.
I'm using the following to send the email:
data = {
"personalizations": [
{
"to": [
{
"email": email
}
],
"dynamic_template_data": {
"subscribe-link" : subscribeLink
}
}
],
"from": {
"email": "[email protected]",
"name": "Bridger"
},
"template_id": template_id,
"asm": {
"group_id": subcription_management_group_id
},
"substitutions": {
"[Sender_Name]": "Scribble LLC",
"Sender_City": "New York, New York" # Also tried it without the brackets
}
}
response = sg.client.mail.send.post(request_body=data)
I've also tried using "Sender_Name" in the dynamic_template_data object, but no luck.
There is a section that sort of addresses this issue at https://sendgrid.com/docs/ui/sending-email/how-to-send-an-email-with-dynamic-transactional-templates/, but I don't understand how to copy the dynamic unsubscribe link into a text module. The image it references as an example is missing.
Hello @bridger,
Thanks for submitting a GitHub issue! We are very sorry that you are running into this problem. In order to better serve you, as this does not present itself as a library specific issue, we would like to ask that you reach out to our support team at https://support.sendgrid.com.
Thank you!
SendGrid DX Team
For future people who might have the same issue I was able to workaround it.
[Sender_Name] with {{Sender_Name}}, etc.Now you can use the templates but they use the correct replacement tags. You can fill in the Sender_Name field with the dynamic_template_data parameters for sending mail.
It seems like this should be reopened. This seems like a major bug in SendGrid templates - the "Unsubscribe Module" is mandatory, and yet, it doesn't work. It just keeps sending out unprofessional [Sender_Name] [Sender_Address], [Sender_City], [Sender_State] [Sender_Zip] Unsubscribe - Unsubscribe Preferences" as-is with nothing filled in and nothing linked.
The Unsubscribe Module is broken and needs to be fixed.
It seems like this should be reopened. This seems like a major bug in SendGrid templates - the "Unsubscribe Module" is mandatory, and yet, it doesn't work. It just keeps sending out unprofessional [Sender_Name] [Sender_Address], [Sender_City], [Sender_State] [Sender_Zip] Unsubscribe - Unsubscribe Preferences" as-is with nothing filled in and nothing linked.
The Unsubscribe Module is broken and needs to be fixed.
Second!
This needs to be fixed. Exporting/Importing to workaround is not an acceptable solution.
Hello @bridger,
Thanks for submitting a GitHub issue! We are very sorry that you are running into this problem. In order to better serve you, as this does not present itself as a library specific issue, we would like to ask that you reach out to our support team at https://support.sendgrid.com.
Thank you!
SendGrid DX Team
I don't particularly care for this response.
Regardless of whether the python helper classes are coded correctly or not this is an engineering issue at Sendgrid and as such we should not be tasked with passing this along to support to inform them API is not functioning correctly.
That is in fact the job of the Sendgrid employees maintaining this lib or those moderating these support issues.
Please pass this thread along to your colleagues as it's not the responsibility of paying customers to communicate issues between departments.
This thread alone probably documents the issue well enough to inform the Sendgrid engineers working on this where the problems exist in the codebase.
Also, this functionality is still broken at the time of writing this comment.
Also having this issue which I believe it is based on a lack of documentation and possible bug. So the transactional template has the [Sender_Name] tags which are for the Marketing campaigns as seen here: https://sendgrid.com/docs/ui/sending-email/senders/#before-you-begin
I have tried using the same Sender email as the from in the transactional email in the API and still those are not replaced.
So either a new module is needed for the transactional emails or a new prop like senderId is needed in the object so we can choose the sender. I rather have the latter.
Yeah. Total mess, and only made worse by a spaghetti bowl of confusing docs.
That {{ }} instead of [] solved the issue. You guys should change this in the documentation and also in the default template creation. It is pain in the a$$
+1 I don't think is so hard to change [] for {{}} for the sendGrid team. Having to export html, modify and import is not a good solution!
Hi, as mentioned in #809 I vote for this issue to be progressed, including the definition of a footer 'Mail Helper Class' The current footer management steps are not clear. I'd also support for a better documentation of current workaround.
I'm new to SendGrid and this was completely throwing me off so I'm glad I found this ticket. I was kind of expecting the [Sender_%] values within the unsubscribe widget to be pulled from the "Sender Management" section of the SendGrid interface, although from a programming perspective I'm guessing each sender listed in that section would need to have a "sender ID" generated much like the template IDs have so that we can reference the appropriate sender data within the JSON object. For now I'll be using the import/export hack but would much prefer a prettier solution; one that uses the actual sender information within SendGrid.
edit: having the [Sender_%] data default to a "default" sender if we don't specify a sender ID would be nice, too
Thanks for taking the time to detail your thoughts and suggestions @dustinfl! Your comment adds to the priority of this issue, so thanks again!
The issue is compounded if you are using Design template instead of Code template. Since the workaround requires you to use the Code template editor (export/import).
I'm deeply impressed by how any developer can think it's ok any feature to be that confusing and messed. Sometimes I just wonder, what the actual fuck. lol
I am able to use the workaround to render the proper sender name into my emails. However, in order to use the unsubscribe module, I need to keep the version with the [] placeholder in, which looks ugly.
Is there a way to either fix it properly or just remove the [sender_name] entirely from the unsubscribe block and just keep the links there?
Ran into this problem myself, and the way it's currently addressed in the Unsubscribe Plugin is via "Sender Management". As I have not seen this information on this thread but Google led me here, I will post the help document links here:
https://sendgrid.com/docs/ui/sending-email/senders/#adding-a-sender
Their idea is that you will add senders to the list here:
https://mc.sendgrid.com/senders/new
@twocs Great ! and how do you configure this sender info in dynamic templates unsubscribe modules ? This is so confusing.
@twocs Great ! and how do you configure this sender info in dynamic templates unsubscribe modules ? This is so confusing.
The way that is shown at https://github.com/sendgrid/sendgrid-python/issues/735#issuecomment-443089317 is to use the template
{{Sender_Name}}
Dynamic field data is passed as a parameter. If sending as json it is in a section such as:
"dynamic_template_data": {
"Sender_Name" : "konfronpi"
}
So basically, some anti-spam laws say that we must provide certain details with marketing emails. SendGrid intends that sender info is set for the account as [Sender_Name] via the Sender's list https://mc.sendgrid.com/senders/new.
We can also achieve this via dynamic templates by using {{Sender_Name}} if programmatically specifying this data at send time.
@twocs thanks that's interesting ! Can you configure unsubscribe groups links as well ?
On Wed, Jul 17, 2019 at 9:47 AM Tom Anderson notifications@github.com
wrote:
@twocs https://github.com/twocs Great ! and how do you configure this
sender info in dynamic templates unsubscribe modules ? This is so confusing.The way that is shown at #735 (comment)
https://github.com/sendgrid/sendgrid-python/issues/735#issuecomment-443089317
is to use the template{{Sender_Name}}
Dynamic field data is passed as a parameter. If sending as json it is in a
section such as:"dynamic_template_data": { "Sender_Name" : "konfronpi" }
So basically, some anti-spam laws say that we must provide certain details
with marketing emails. SendGrid intends that sender info is set for the
account as [Sender_Name] but we can also achieve this via dynamic templates
by using {{Sender_Name}} if we are programmatically specifying this data
This is a little misleading. What does not work, is this template, or any
template, as it was intended to work.
What also does not work is use of:
[Sender_Name]
In Dynamic Templates that's ignored, and emitted literally ("[Sender_Name]"
goes out in every email, to actual customers).
What does work is this complicated workaround:
1) Switch each of those to anything you like - {{Sender_Name}} if you want,
but you could also use {{Unsubscribe.senderName}} or even {{Jello}} if you
wanted, it doesn't matter because the framework has no actual support for
this section.
2) Emit the Unsubscribe field info in each of your JSON packets you send to
these Dynamic Templates. This is why I proposed {{Unsubscribe.senderName}}
above - you could include a .Unsubscribe property in each JSON you emit to
SendGrid.
Of course, if the JSON you're sending is used elsewhere in the system - for
example, info about an event that needs to be emitted over email - you've
now got a problem on your hands. Any other use in the system doesn't need
Unsubscribe info. So you'll have to put a SendGridWrapper of some sort
around the data, add that Unsubscribe property to it, and take it from
there.
In the end, this is all a lot of unnecessary complexity. This template
system is simply broken. The default Unsubscribe module should simply work,
taking its info from the central settings in SendGrid. There is no way to
get that info from those central settings today, and the default templates
new users start with lead them down this rabbit hole, probably to this
thread.
@b9chris Well said. Worse, I just learnt from the sendgrid support (which are actually good compared to the documentation) that putting unsubscribe links through the API is done with yet another substitution tag system (asm), not handlebars.
I gotta stick with @b9chris. Those workarounds are cringing. Let's stop this and wait for a real f* fix.
The workflow for the naive user is as follows. They create a dynamic template. They see [Sender_Name] at the bottom and assume that it's valid. At least stick a "?" on the Unsubscribe module to the Design module. That links you to the page where you enter the details, or at least to the documentation! The law does not say anyone can send a marketing email with [Sender_Name] instead of their real name, but SendGrid facilitates this occurrence.
Also, why can't we save the dynamic template with a minor error like a inside the handlebars, but we can save it without details set for [Sender_Name]? Fix!
@twocs thanks that's interesting ! Can you configure unsubscribe groups links as well ?
This is an issue report for the SendGrid Python API. I think that Stackexchange or the SendGrid guide on how to find answers will be more suitable for these questions,
Maybe this will be useful: Sendgrid guide on Creating and Managing Unsubscribe Groups.
I came here looking for how to fill these fields in as well, but not for Python - just in general. It seems as though they are variables and I have to send the same data with each email. I'm not sure why SendGrid would want this data sent with each email? Why would my company change? Shouldn't this come from my account, or possibly form fields in the module itself I could just edit?
I believe this is also responsible for sending our email to Spam.
This has been open for almost a year now? Is import/export still the best way to handle this?
How can I populate Address Line ([Sender_Name], [Sender_Address], [Sender_City], [Sender_State] [Sender_Zip]) in transactional template?
How can I populate Address Line ([Sender_Name], [Sender_Address], [Sender_City], [Sender_State] [Sender_Zip]) in transactional template?
The best way is still what @bridger proposed. exporting/importing the html and changing from [Sender_Name] to {{Sender_Name}}. Then you can treat the values like any other dynamic parameters.
How to populate data in "Unsubscribe Module" in "Design Editor"? Sender_Name, Sender_Address, Sender_City, Sender_State, Sender_Zip and Unsubscribe link.
Not working, the templates use different tags it should be set to {{ }} why is it [], and how can I fix it? I know transactional templates don't require unsubscribe but why is this box there?
How can I populate Address Line ([Sender_Name], [Sender_Address], [Sender_City], [Sender_State] [Sender_Zip]) in transactional template?
Since you mentioned it's a transactional template, I would just avoid the problem by making a new footer. It won't have the special Unsubscribe link, but those are only desirable in marketing emails. Transactional emails should not have the ability to unsubscribe.
@thinkingserious it would be really nice if the documentation here: https://sendgrid.com/docs/for-developers/sending-email/getting-started-with-transactional-emails/ contained the information in this thread so sendgrid users didn't waste time trying to set senders for transactional emails.
A solution that worked for me:
While you can't change the dynamic text or pass through standard fields, you can minimize the display to just be the 'Unsubscribe' and 'Unsubscribe Preferences' only.

using these settings for the field:

Then create a new Text field and hardcode the company name and address above with zero padding.
I'm running into the same issue as many others. Very surprising that such simple but critical issue was posted over 18 months ago and there's still no practical solution without extensive workarounds? I contacted SendGrid's support yesterday but am still waiting for their answer. Did anyone get a response from SendGrid that included a real solution to this issue?
Took a look into this just now.
Creating dynamic templates using the design editor just shows the unsubscribe links by default; no sender information. 馃憤
Creating a design in the design library using the design editor shows the unsubscribe links and the sender placeholders properly handledbar'ed. 馃憤
{{Sender_Name}}
{{Sender_Address}}, {{Sender_City}}, {{Sender_State}} {{Sender_Zip}}
Unsubscribe - Unsubscribe Preferences
I don't know _when_ this was fixed, but seeing as it's fixed now and is not directly related to this repo I'm closing this issue.
Let me know if I'm missing something. And please open a separate issue for anything else. Note that we're (slowly) working through old issues with a priority on new issues and issues with +1s on the _issue summary_ (not on comments).
Most helpful comment
It seems like this should be reopened. This seems like a major bug in SendGrid templates - the "Unsubscribe Module" is mandatory, and yet, it doesn't work. It just keeps sending out unprofessional [Sender_Name] [Sender_Address], [Sender_City], [Sender_State] [Sender_Zip] Unsubscribe - Unsubscribe Preferences" as-is with nothing filled in and nothing linked.
The Unsubscribe Module is broken and needs to be fixed.