@@ -37,7 +37,7 @@ Example
3737
3838 import sendgrid
3939
40- sg = sendgrid.SendGridClient(' YOUR_SENDGRID_USERNAME ' , ' YOUR_SENDGRID_PASSWORD ' )
40+ sg = sendgrid.SendGridClient(' YOUR_SENDGRID_API_KEY ' )
4141
4242 message = sendgrid.Mail()
4343 message.add_to(' John Doe <john@email.com>' )
@@ -245,7 +245,7 @@ List all API Keys belonging to the authenticated user.
245245
246246.. code :: python
247247
248- client = sendgrid.SendGridAPIClient(os.environ.get( ' SENDGRID_API_KEY' ) )
248+ client = sendgrid.SendGridAPIClient(' SENDGRID_API_KEY' )
249249 status, msg = client.apikeys.get()
250250
251251 Generate a new API Key for the authenticated user
@@ -287,7 +287,7 @@ Retrieve all suppression groups associated with the user.
287287
288288.. code :: python
289289
290- client = sendgrid.SendGridAPIClient(os.environ.get( ' SENDGRID_API_KEY' ) )
290+ client = sendgrid.SendGridAPIClient(' SENDGRID_API_KEY' )
291291 status, msg = client.asm_groups.get()
292292
293293 Get a single record.
@@ -311,9 +311,9 @@ Add recipient addresses to the suppressions list for a given group.
311311
312312.. code :: python
313313
314- client = sendgrid.SendGridAPIClient(os.environ.get( ' SENDGRID_API_KEY' ) )
314+ client = sendgrid.SendGridAPIClient(' SENDGRID_API_KEY' )
315315 group_id = < group_id_number> # If no group_id_number, the emails will be added to the global suppression group
316- emails = [' elmer+test@thinkingserious .com' , ' elmer+test2@thinkingserious .com' ]
316+ emails = [' example@example .com' , ' example@example .com' ]
317317 status, msg = client.asm_suppressions.post(group_id, emails)
318318
319319 Get suppressed addresses for a given group.
@@ -337,28 +337,28 @@ Check if a given email is on the global suppression list.
337337
338338.. code :: python
339339
340- client = sendgrid.SendGridAPIClient(os.environ.get( ' SENDGRID_API_KEY' ) )
341- email = [' elmer@thinkingserious .com' ]
340+ client = sendgrid.SendGridAPIClient(' SENDGRID_API_KEY' )
341+ email = [' example@example .com' ]
342342 status, msg = client.asm_global_suppressions.get(email)
343343
344344 Get a list of all SendGrid globally unsubscribed emails.
345345
346346.. code :: python
347- client = sendgrid.SendGridAPIClient(os.environ.get( ' SENDGRID_API_KEY' ) )
347+ client = sendgrid.SendGridAPIClient(' SENDGRID_API_KEY' )
348348 status, msg = client.suppressions.get()
349349
350350 Add an email to the global suppression list.
351351
352352.. code :: python
353- client = sendgrid.SendGridAPIClient(os.environ.get( ' SENDGRID_API_KEY' ) )
354- email = [' elmer@thinkingserious .com' ]
353+ client = sendgrid.SendGridAPIClient(' SENDGRID_API_KEY' )
354+ email = [' example@example .com' ]
355355 status, msg = client.asm_global_suppressions.post(email)
356356
357357 Delete an email from the global suppression list.
358358
359359.. code :: python
360- client = sendgrid.SendGridAPIClient(os.environ.get( ' SENDGRID_API_KEY' ) )
361- email = ' elmer@thinkingserious .com'
360+ client = sendgrid.SendGridAPIClient(' SENDGRID_API_KEY' )
361+ email = ' example@example .com'
362362 status, msg = client.asm_global_suppressions.delete(email)
363363
364364 SendGrid's `X-SMTPAPI `_
@@ -369,6 +369,21 @@ If you wish to use the X-SMTPAPI on your own app, you can use the
369369
370370There are implementations for setter methods too.
371371
372+ Example
373+ ~~~~~~~
374+
375+ .. code :: python
376+
377+ sg = sendgrid.SendGridClient(' SENDGRID_API_KEY' )
378+ message = sendgrid.Mail()
379+ message.add_substitution(' :first_name' , ' John' )
380+ message.smtpapi.add_to(' John <example@example.com>' )
381+ message.set_subject(' Testing from the Python library using the SMTPAPI' )
382+ message.set_html(' <b>:first_name, this was a successful test of using the SMTPAPI library!</b>' )
383+ message.set_text(' :name, this was a successful test of using the SMTPAPI library!' )
384+ message.set_from(' Jane <example@example.com>' )
385+ sg.send(message)
386+
372387 `Recipients `_
373388~~~~~~~~~~~~~
374389
@@ -512,6 +527,7 @@ Using Templates from the Template Engine
512527
513528 message.add_filter(' templates' , ' enable' , ' 1' )
514529 message.add_filter(' templates' , ' template_id' , ' TEMPLATE-ALPHA-NUMERIC-ID' )
530+ message.add_substitution(' key' , ' value' )
515531
516532 Tests
517533~~~~~
0 commit comments