Help get this topic noticed by sharing it on Twitter Twitter, Facebook Facebook, or email.
artur.jewula

Unable to change parts defined in "section"

Hello I want to use section in my emails but somehow I cannot make it work. I pass the values but they are not changed in the incoming email. I send header like this:
"to": ["email1", "email2" ...],
"sub": ["%username%": ["text1", "text2"], ...],
"section": {"%posttitle%": "text", ...}

In email template i use
Dear %username%,

There is a new %posttitle% in the ....

But in the email I receive all sub parts are changed but all section parts remain unchanged. If instead of section I create sub then all variables are substituted correctly.

I create headers in php zend application and I use swift as a mailer to send requests like in the documentation.
1 person has
this question
+1
Reply

  • artur.jewula
    I found the solution. section is used after substitution and perform on what sub does. So if I wanted to use %username% in all emails first I must make sure that sub will place %username% somewhere in the content of the email.

    I must say it is strange that it isn't working without sub first.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited sad, anxious, confused, frustrated indifferent, undecided, unconcerned kidding, amused, unsure, silly

  • Hello,

    The sections are a little confusing, so I figured I'd elaborate here on why they exist and how they are used.

    Sections are used for the replacement of large sections of text inside recipient specific code. The idea here is if you are trying to create dynamic content for some section of users, rather than having to figure out how to separate them at the point of mail generation you could just say "user X gets body Y, user Z gets body A".

    So sections are only replaced inside subs, not the main body of the email. They don't really make a lot of sense otherwise, since you'd just include the text in the email rather than trying to include it into a header.

    Please let me know if you have any other questions or feedback.

    Regards,
    Tim
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited sad, anxious, confused, frustrated indifferent, undecided, unconcerned kidding, amused, unsure, silly

  • artur.jewula
    I need to prepare notification emails for certain actions in my application. I create template body with things like link to the event or the description of the event which will be identical in all emails but dynamic between different events. I thought I could use section to insert this text into the body of an email.

    With this logic I have two options:
    1. Use section and create sub for each email which still will shorten the header.
    2. Change part of the body before sending email. This however breaks creating dynamic content into two separate places.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited sad, anxious, confused, frustrated indifferent, undecided, unconcerned kidding, amused, unsure, silly

  • Avtar Singh Kohli
    sad I’m sad
    I need to the same - dynamic text body based on event, but only using http posts with request parameters as values for tokens within the template... such a simple concept - but does not exist in SendGrid.... not happy and still waiting to hear back from SG team. I reckon this feature would add immense value to SendGrid Services...
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited sad, anxious, confused, frustrated indifferent, undecided, unconcerned kidding, amused, unsure, silly