-
Notifications
You must be signed in to change notification settings - Fork 778
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subject not changing in Template mail.send() #713
Comments
The workaround that I am using is to add a subject in SendGrid's web interface like {{subject}} and then to pass in a subject variable to |
Hello @falconmick, @wbw20 workaround works, please try that as we investigate the root cause. Thanks for helping out! I edited out your image because it did not add to the solution. Not sure what your intention was. With Best Regards, Elmer |
FWIW, I see similar behavior with the Ruby lib. Setting the subject on the email object doesn't carry through to override anything defined on the template on the web tooling. Have to make it a handlebar and add to each personalization. |
I too am encountering this issue. I am struggling to pin point exactly why it's failing. |
The workaround seems viable, but is unfortunate as it goes against the set up we have for all other SendGrid e-mails. |
It should be like: go to https://sendgrid.com/dynamic_templates It work for me 👍 |
@atarabbi's solution should be what you need. Please continue to comment on this thread if you still run into issues. Thanks! |
But doesn't that still leave things ultimately not working according to how the library API is documented for us to consume? Setting the subject as things allow would still seem broken no? |
Yeah, the method the docs suggest for changing the subject don't seem to work. I don't know if this is only a problem for dynamic_template_data, but I'm experiencing this as well. I'll try using a dynamic template for the subject line, but the documentation is surprisingly inconsistent |
From what I'm seeing in the docs here, it's documented to update the template subject with the handlebars variable (granted, this could be a more expansive explanation). @baugarten Just to make sure, are you saying that is not working for you? Can you point out where we're pointing you in the wrong direction? I'm seeing that we're not documenting dynamic_template_data in the client package. Also, are you using the latest library version v6.3.1? Definitely want to fix this, and apologize for the confusion! |
FWIW I am also seeing this issue in the Golang library, I'm unable to override the template subject from the API call. If I can't find a suitable workaround I'll make an issue there as well. |
Ugh, the docs specifically say that the base subject will be overwritten by a personalization subject, which is not at all the same as being able to template the subject. EDIT: Especially when your own libraries don't work. They add subject in a personalization, where it cannot be used to template. If you expect this to be the documented behavior, then the libraries need to add it to the dynamic_template_data sub-object. |
Also ran into this, subject doesn't seem to be overwritten, but work around is usable. |
Leaving the subject in the 'dynamic_template_data' and referring to it in the template with {{{subject}}} does indeed seem to work. Also what I noticed is that custom_args no longer exists. It is merged along with substitutions into 'dynamic_template_data'. Unfortunately the docs don't tell this. If you want to pass a language parameter for example, also do this in your 'dynamic_template_data'. |
The "dynamic_template_data" field works but seems undocumented: https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/index.html |
This is still an issue. Why was this closed? The workaround does not work reliably. If I send ~30 emails in a loop using the same exact Subject I get some with the subject I sent in and some with (no subject). Is there currently a way to reliably send in custom subject through the API? |
@deepai-org Best to use the latest docs here: https://sendgrid.com/docs/API_Reference/api_v3.html @vladkosarev Are you saying that you're using the same dynamic template with subject templatized with handlebars (see #713 (comment)) and your request payload contains the proper dynamic template data for the subject and it's not reliably using the subject? If this is the case, best to contact support as this is not something that can/should be addressed by a client-side library. |
@childish-sambino After a while the subject was actually correct in all emails. It seems like there's something async going on for a while and some emails will get old email template and some new. Is this https://sendgrid.com/docs/API_Reference/api_v3.html correct documentation? I'm pretty sure sending subject as described in that doc does not work. The only way so far that it did work was the workaround described in this ticket. |
@vladkosarev Those are the correct docs. If you're using dynamic templates, the subject must be templatized and passed as dynamic template data in order to modify it per-email, as outlined in this issue. If you're not using templates, then the subject provided in the mail-send payload will be used. As to why some sync was needed in order for the subject to be correct for all emails, best to contact support. |
@childish-sambino Can you please point me where in the docs it explains how to use subject in dynamic template? I still can't find that anywhere in that new link. Thanks! |
if I recall correctly @vladkosarev, you want to set the handlebars value in the template itself for the subject -- this is done using the template GUI. Then just reference that value in your code. |
@aroach thanks but I'm interested in seeing that in the doc, not in a comment on github. By the way {{}} did not work for me when I tried, only triple brackets {{{}}} worked (could be same async issue as before). |
@vladkosarev It appears to be mentioned here: https://sendgrid.com/docs/ui/sending-email/how-to-send-an-email-with-dynamic-transactional-templates/
|
@aroach thank you. I just did more tests and subject takes a while to actually 'apply' to a template so it looks like it's not working if you are testing (edit template/send). If you wait 10 min then it actually does get applied and works as intended. I might reach out to SG to document that template updates are not real time (at least for subject) and that you have to wait a bit to do a test. Thank you. |
@Whatthefoxsays should be able to chase this down and/or make the appropriate edits. 👋 |
@aroach one thing I should probably mention is that we do have two IPs for sending out email. I don't know the inner working of SG but that could be why there's an issue (takes time to propagate to second node?). |
@thinkingserious @Whatthefoxsays @aroach Amazing that 2+ years later the most basic function in email API does not work.... you add subject in JSON and it does nothing. using the dynamic template as a workaround works fine, but there is obvious bug vs expected behaviour and Senggrid is just sitting on it? |
Issue Summary
subject not changing in email
Steps to Reproduce
call sgMail.send(seeBellow)
which results in the following post
I have also tried sending 2 emails via an array of messages instead of using personalizations however this also doesn't work.
Finally I have also attempted to place subject beside the from field, still didn't work
Technical details:
The text was updated successfully, but these errors were encountered: