Simple Name Substitution

This example will show you how to create a name substitution for your emails. We will be using the tag “-name-” in this example. In this example the tag -name- will get replaced with the name of the recipient.

Email Content

Text

1
Hello -name-,

HTML

1
2
3
4
5
6
7
<html>
  <head></head>
  <body>
    <p>Hello -name-,<br>
    </p>
  </body>
</html>

X-SMTPAPI Header

1
2
3
4
5
6
7
8
9
10
{
  "to": [
      "example01@domain.com",
      "example02@domain.com",
      "example03@domain.com"
  ],
  "sub": {
      "-name-": ["John", "Jane", "Matt"]
  }
}

v3 Mail Send

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{
  "personalizations": [{
      "to": [{
          "email": "example01@domain.com",
          "name": "Example 01"
      }],
      "subject": "Example 01",
      "substitutions": {
          "-name-": "John"
      }
  }, {
      "to": [{
          "email": "example02@domain.com",
          "name": "Example 02"
      }],
      "subject": "Example 02",
      "substitutions": {
          "-name-": "Jane"
      }
  }, {
      "to": [{
          "email": "example03@domain.com",
          "name": "Example 03"
      }],
      "subject": "Example 03",
      "substitutions": {
          "-name-": "Matt"
      }
  }],
  "from": {
      "email": "sender@senddomain.com",
      "name": "Sender"
  },
  "reply_to": {
      "email": "sender@senddomain.com",
      "name": "Sender"
  },
  "subject": "Example",
  "content": [{
      "type": "text/plain",
      "value": "Hello -name-,"
  }, {
      "type": "text/html",
      "value": "Hello -name-,"
  }]

}

Example Outcome:

example01@domain.com

Text
1
Hello John,
HTML
1
2
3
4
5
6
7
<html>
  <head></head>
  <body>
    <p>Hello John,<br>
    </p>
  </body>
</html>

example02@domain.com

Text
1
Hello Jane,
HTML
1
2
3
4
5
6
7
<html>
  <head></head>
  <body>
    <p>Hello Jane,<br>
    </p>
  </body>
</html>

example03@domain.com

Text
1
Hello Matt,
HTML
1
2
3
4
5
6
7
<html>
  <head></head>
  <body>
    <p>Hello Matt,<br>
    </p>
  </body>
</html>

First Name and Last Name Substitutions

This example will show you how to create a first name and last name substitution for your emails. We will be using the tags “-first_name-” and “-last_name-” in this example. In this example the tag -first_name- will get replaced with the first name of the recipient and the tag -last_name- will get replaced with the last name of the recipient.

Email Content

Text

1
Hello -first_name- -last_name-,

HTML

1
2
3
4
5
6
7
<html>
  <head></head>
  <body>
    <p>Hello -first_name- -last_name-,<br>
    </p>
  </body>
</html>

X-SMTPAPI Header

1
2
3
4
5
6
7
8
9
10
11
{
  "to": [
      "example01@domain.com",
      "example02@domain.com",
      "example03@domain.com"
  ],
  "sub": {
      "-first_name-": ["John", "Jane", "Matt"],
      "-last_name-": ["Smith", "Williams", "Johnson"]
  }
}

v3 Mail Send

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{
  "personalizations": [{
      "to": [{
          "email": "example01@domain.com",
          "name": "Example 01"
      }],
      "subject": "Example 01",
      "substitutions": {
          "-first_name-": "John",
          "-last_name-": "Smith"
      }
  }, {
      "to": [{
          "email": "example02@domain.com",
          "name": "Example 02"
      }],
      "subject": "Example 02",
      "substitutions": {
          "-first_name-": "Jane",
          "-last_name-": "Williams"
      }
  }, {
      "to": [{
          "email": "example03@domain.com",
          "name": "Example 03"
      }],
      "subject": "Example 03",
      "substitutions": {
          "-first_name-": "Matt",
          "-last_name-": "Johnson"
      }
  }],
  "from": {
      "email": "sender@senddomain.com",
      "name": "Sender"
  },
  "reply_to": {
      "email": "sender@senddomain.com",
      "name": "Sender"
  },
  "subject": "Example",
  "content": [{
      "type": "text/plain",
      "value": "Hello -first_name- -last_name-,"
  }, {
      "type": "text/html",
      "value": "Hello -first_name- -last_name-,"
  }]

}

Example Outcome:

example01@domain.com

Text
1
Hello John Smith,
HTML
1
2
3
4
5
6
7
<html>
  <head></head>
  <body>
    <p>Hello John Smith,<br>
    </p>
  </body>
</html>

example02@domain.com

Text
1
Hello Jane Williams,
HTML
1
2
3
4
5
6
7
<html>
  <head></head>
  <body>
    <p>Hello Jane Williams,<br>
    </p>
  </body>
</html>

example03@domain.com

Text
1
Hello Matt Johnson,
HTML
1
2
3
4
5
6
7
<html>
  <head></head>
  <body>
    <p>Hello Matt Johnson,<br>
    </p>
  </body>
</html>

Simple Greeting Section with Name Substitution

This example will show you how to create a section as a greeting with a name substitution. We will be using the tags “-warm_welcome-“, “-greeting-” and “-name-” in this example. In this example we have created a greeting using the section tag -warm_welcome-. The -warm_welcome- tag is replaced with the -greeting- substitution which calls the section “Hello -name-,”. The -name- tag in “Hello -name-,” is then replaced with the recipients name.

Email Content

Text

1
-warm_welcome-

HTML

1
2
3
4
5
6
7
<html>
  <head></head>
  <body>
    <p>-warm_welcome-<br>
    </p>
  </body>
</html>

X-SMTPAPI Header

1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
  "to": [
      "example01@domain.com",
      "example02@domain.com",
      "example03@domain.com"
  ],
  "sub": {
      "-name-": ["John", "Jane", "Matt"],
      "-warm_welcome-": ["-greeting-", "-greeting-", "-greeting-"]
  },
  "section": {
      "-greeting-": "Hello -name-,"
  }
}

v3 Mail Send

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{
  "personalizations": [{
      "to": [{
          "email": "example01@domain.com",
          "name": "Example 01"
      }],
      "subject": "Example 01",
      "substitutions": {
          "-name-": "John",
          "-warm_welcome-": "-greeting-"
      }
  }, {
      "to": [{
          "email": "example02@domain.com",
          "name": "Example 02"
      }],
      "subject": "Example 02",
      "substitutions": {
          "-name-": "Jane",
          "-warm_welcome-": "-greeting-"
      }
  }, {
      "to": [{
          "email": "example03@domain.com",
          "name": "Example 03"
      }],
      "subject": "Example 03",
      "substitutions": {
          "-name-": "Matt",
          "-warm_welcome-": "-greeting-"
      }
  }],
  "from": {
      "email": "sender@senddomain.com",
      "name": "Sender"
  },
  "reply_to": {
      "email": "sender@senddomain.com",
      "name": "Sender"
  },
  "subject": "Example",
  "content": [{
      "type": "text/plain",
      "value": "-warm_welcome-"
  }, {
      "type": "text/html",
      "value": "-warm_welcome-"
  }],
  "sections": {
      "-greeting-": "Welcome -name-,"
  }
}

Example Outcome:

example01@domain.com

Text
1
Hello John,
HTML
1
2
3
4
5
6
7
<html>
  <head></head>
  <body>
    <p>Hello John,<br>
    </p>
  </body>
</html>

example02@domain.com

Text
1
Hello Jane,
HTML
1
2
3
4
5
6
7
<html>
  <head></head>
  <body>
    <p>Hello Jane,<br>
    </p>
  </body>
</html>

example03@domain.com

Text
1
Hello Matt,
HTML
1
2
3
4
5
6
7
<html>
  <head></head>
  <body>
    <p>Hello Matt,<br>
    </p>
  </body>
</html>

Greeting Section with First & Last Name Substitutions

This example will show you how to create a section with first name and last name substitution for your emails. We will be using the tags “-warm_welcome-“, “-greeting-“, “-first_name-” and “-last_name-” in this example. In this example we have created a greeting using the section tag -warm_welcome-. The -warm_welcome- tag is replaced with the -greeting- substitution which calls the section “Hello -first_name- -last_name-,”. The -first_name- and -last_name- tags in “Hello -first_name- -last_name-,” is then replaced with the recipients first and last names.

Email Content

Text

1
-warm_welcome-

HTML

1
2
3
4
5
6
7
<html>
  <head></head>
  <body>
    <p>-warm_welcome-<br>
    </p>
  </body>
</html>

X-SMTPAPI Header

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
  "to": [
      "example01@domain.com",
      "example02@domain.com",
      "example03@domain.com"
  ],
  "sub": {
      "-first_name-": ["John", "Jane", "Matt"],
      "-last_name-": ["Smith", "Williams", "Johnson"],
      "-warm_welcome-": ["-greeting-", "-greeting-", "-greeting-"]
  },
  "section": {
      "-greeting-": "Hello -first_name- -last_name-,"
  }
}

v3 Mail Send

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{
  "personalizations": [{
      "to": [{
          "email": "example01@domain.com",
          "name": "Example 01"
      }],
      "subject": "Example 01",
      "substitutions": {
          "-first_name-": "John",
          "-last_name-": "Smith",
          "-warm_welcome-": "-greeting-"
      }
  }, {
      "to": [{
          "email": "example02@domain.com",
          "name": "Example 02"
      }],
      "subject": "Example 02",
      "substitutions": {
          "-first_name-": "Jane",
          "-last_name-": "Williams",
          "-warm_welcome-": "-greeting-"
      }
  }, {
      "to": [{
          "email": "example03@domain.com",
          "name": "Example 03"
      }],
      "subject": "Example 03",
      "substitutions": {
          "-first_name-": "Matt",
          "-last_name-": "Johnson",
          "-warm_welcome-": "-greeting-"
      }
  }],
  "from": {
      "email": "sender@senddomain.com",
      "name": "Sender"
  },
  "reply_to": {
      "email": "sender@senddomain.com",
      "name": "Sender"
  },
  "subject": "Example",
  "content": [{
      "type": "text/plain",
      "value": "-warm_welcome-"
  }, {
      "type": "text/html",
      "value": "-warm_welcome-"
  }],
  "sections": {
      "-greeting-": "Welcome -first_name- -last_name-,"
  }
}

Example Outcome:

example01@domain.com

Text
1
Hello John Smith,
HTML
1
2
3
4
5
6
7
<html>
  <head></head>
  <body>
    <p>Hello John Smith,<br>
    </p>
  </body>
</html>

example02@domain.com

Text
1
Hello Jane Williams,
HTML
1
2
3
4
5
6
7
<html>
  <head></head>
  <body>
    <p>Hello Jane Williams,<br>
    </p>
  </body>
</html>

example03@domain.com

Text
1
Hello Matt Johnson,
HTML
1
2
3
4
5
6
7
<html>
  <head></head>
  <body>
    <p>Hello Matt Johnson,<br>
    </p>
  </body>
</html>

Three Different Greeting Sections with First & Last Name Substitutions

This example will show you how to create three different sections, each with first name and last name substitution for your emails. We will be using the tags “-warm_welcome-“, “-greeting01-“, “-greeting02-“, “-greeting03-“, “-first_name-” and “-last_name-” in this example. In this example we have created three different greetings using the section tag -warm_welcome-. The -warm_welcome- tag is replaced with either -greeting01-, -greeting02- or -greeting03- substitution. This will call one of the three sections. In each of these sections there is the -first_name- and -last_name- tags which will get replaced with the recipients first and last names.

Email Content

Text

1
-warm_welcome-

HTML

1
2
3
4
5
6
7
<html>
  <head></head>
  <body>
    <p>-warm_welcome-<br>
    </p>
  </body>
</html>

X-SMTPAPI Header

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
  "to": [
      "example01@domain.com",
      "example02@domain.com",
      "example03@domain.com"
  ],
  "sub": {
      "-first_name-": ["John", "Jane", "Matt"],
      "-last_name-": ["Smith", "Williams", "Johnson"],
      "-warm_welcome-": ["-greeting01-", "-greeting02-", "-greeting03-"]
  },
  "section": {
      "-greeting01-": "Welcome -first_name- -last_name-,",
      "-greeting02-": "Hello -first_name- -last_name-,",
      "-greeting03-": "Dear -first_name- -last_name-,"
  }
}

v3 Mail Send

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{
  "personalizations": [{
      "to": [{
          "email": "example01@domain.com",
          "name": "Example 01"
      }],
      "subject": "Example 01",
      "substitutions": {
          "-first_name-": "John",
          "-last_name-": "Smith",
          "-warm_welcome-": "-greeting01-"
      }
  }, {
      "to": [{
          "email": "example02@domain.com",
          "name": "Example 02"
      }],
      "subject": "Example 02",
      "substitutions": {
          "-first_name-": "Jane",
          "-last_name-": "Williams",
          "-warm_welcome-": "-greeting02-"
      }
  }, {
      "to": [{
          "email": "example03@domain.com",
          "name": "Example 03"
      }],
      "subject": "Example 03",
      "substitutions": {
          "-first_name-": "Matt",
          "-last_name-": "Johnson",
          "-warm_welcome-": "-greeting03-"
      }
  }],
  "from": {
      "email": "sender@senddomain.com",
      "name": "Sender"
  },
  "reply_to": {
      "email": "sender@senddomain.com",
      "name": "Sender"
  },
  "subject": "Example",
  "content": [{
      "type": "text/plain",
      "value": "-warm_welcome-"
  }, {
      "type": "text/html",
      "value": "-warm_welcome-"
  }],
  "sections": {
      "-greeting01-": "Welcome -first_name- -last_name-,",
      "-greeting02-": "Hello -first_name- -last_name-,",
      "-greeting03-": "Dear -first_name- -last_name-,"
  }
}

Example Outcome:

example01@domain.com

Text
1
Welcome John Smith,
HTML
1
2
3
4
5
6
7
<html>
  <head></head>
  <body>
    <p>Welcome John Smith,<br>
    </p>
  </body>
</html>

example02@domain.com

Text
1
Hello Jane Williams,
HTML
1
2
3
4
5
6
7
<html>
  <head></head>
  <body>
    <p>Hello Jane Williams,<br>
    </p>
  </body>
</html>

example03@domain.com

Text
1
Dear Matt Johnson,
HTML
1
2
3
4
5
6
7
<html>
  <head></head>
  <body>
    <p>Dear Matt Johnson,<br>
    </p>
  </body>
</html>

Three Confirmation Sections and Substitutions

This example will show you how to create three different sections for confirmation emails. We will be using the tags “-name-“, “-confirmations-“, “-confirmation_001-“, “-confirmation_002-“, “-confirmation_003-” and “-order_id-” in this example. In this example we have created three different confirmations using the section tag -confirmations-. The -confirmations- tag is replaced with either -confirmation_001-, -confirmation_002- or -confirmation_003- substitution. This will call one of the three sections. In each of these sections there is the -order_id- tag which will get replaced with the recipients order id.

Email Content

Text

1
2
Hello -name-,
-confirmations-

HTML

1
2
3
4
5
6
7
8
<html>
  <head></head>
  <body>
    <p>Hello -name-,<br>
      -confirmations-
    </p>
  </body>
</html>

X-SMTPAPI Header

1
2
3
4
5
6
7
8
9
10
11
12
13
{
  "to": ["example01@domain.com", "example02@domain.com", "example03@domain.com"],
  "sub": {
      "-name-": ["John", "Jane", "Matt"],
      "-confirmations-": ["-confirmation_001-", "-confirmation_002-", "-confirmation_003-"],
      "-order_id-": ["12345", "23456", "34567"]
  },
  "section": {
      "-confirmation_001-": "Thanks for choosing SendGrid. This email is to confirm that we have processed your order -order_id-.",
      "-confirmation_002-": "Thanks for choosing SendGrid. This email is to confirm that we have processed your order -order_id-. This invoice is to be paid by bank transfer within 7 days from the date of your monthly statement.",
      "-confirmation_003-": "Thanks for choosing SendGrid. This email is to confirm that we have processed your order -order_id-. You can download your invoice as a PDF for your records."
  }
}

v3 Mail Send

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{
  "personalizations": [{
      "to": [{
          "email": "example01@domain.com",
          "name": "Example 01"
      }],
      "subject": "Example 01",
      "substitutions": {
          "-name-": "John",
          "-order_id-": "12345",
          "-confirmations-": "-confirmation_001-"
      }
  }, {
      "to": [{
          "email": "example02@domain.com",
          "name": "Example 02"
      }],
      "subject": "Example 02",
      "substitutions": {
          "-name-": "Jane",
          "-order_id-": "23456",
          "-confirmations-": "-confirmation_002-"
      }
  }, {
      "to": [{
          "email": "example03@domain.com",
          "name": "Example 03"
      }],
      "subject": "Example 03",
      "substitutions": {
          "-name-": "Matt",
          "-order_id-": "34567",
          "-confirmations-": "-confirmation_003-"
      }
  }],
  "from": {
      "email": "sender@senddomain.com",
      "name": "Sender"
  },
  "reply_to": {
      "email": "sender@senddomain.com",
      "name": "Sender"
  },
  "subject": "Example",
  "content": [{
      "type": "text/plain",
      "value": "Hello -name-,\r\n-confirmations-"
  }, {
      "type": "text/html",
      "value": "<p>Hello -name-,<br>-confirmations-"
  }],
  "sections": {
      "-confirmation_001-": "Thanks for choosing SendGrid. This email is to confirm that we have processed your order -order_id-.",
      "-confirmation_002-": "Thanks for choosing SendGrid. This email is to confirm that we have processed your order -order_id-. This invoice is to be paid by bank transfer within 7 days from the date of your monthly statement.",
      "-confirmation_003-": "Thanks for choosing SendGrid. This email is to confirm that we have processed your order -order_id-. You can download your invoice as a PDF for your records."
  }
}

Example Outcome:

example01@domain.com

Text
1
2
Welcome John,
Thanks for choosing SendGrid. This email is to confirm that we have processed your order 12345.
HTML
1
2
3
4
5
6
7
8
<html>
  <head></head>
  <body>
    <p>Welcome John,<br>
      Thanks for choosing SendGrid. This email is to confirm that we have processed your order 12345.
    </p>
  </body>
</html>

example02@domain.com

Text
1
2
Hello Jane,
Thanks for choosing SendGrid. This email is to confirm that we have processed your order 23456. This invoice is to be paid by bank transfer within 7 days from the date of your monthly statement.
HTML
1
2
3
4
5
6
7
8
<html>
  <head></head>
  <body>
    <p>Hello Jane,<br>
      Thanks for choosing SendGrid. This email is to confirm that we have processed your order 23456. This invoice is to be paid by bank transfer within 7 days from the date of your monthly statement.
    </p>
  </body>
</html>

example03@domain.com

Text
1
2
Dear Matt,
Thanks for choosing SendGrid. This email is to confirm that we have processed your order 34567. You can download your invoice as a PDF for your records.
HTML
1
2
3
4
5
6
7
8
<html>
  <head></head>
  <body>
    <p>Dear Matt,<br>
      Thanks for choosing SendGrid. This email is to confirm that we have processed your order 34567. You can download your invoice as a PDF for your records.
    </p>
  </body>
</html>