Skip to content

Latest commit

 

History

History
24 lines (23 loc) · 703 Bytes

send_a_single_email_to_multiple_recipients.md

File metadata and controls

24 lines (23 loc) · 703 Bytes
import os
import json
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import Mail

to_emails = [
    ('[email protected]', 'Example Name 0'),
    ('[email protected]', 'Example Name 1')
]
message = Mail(
    from_email=('[email protected]', 'Example From Name'),
    to_emails=to_emails,
    subject='Sending with Twilio SendGrid is Fun',
    html_content='<strong>and easy to do anywhere, even with Python</strong>')
try:
    sendgrid_client = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
    response = sendgrid_client.send(message)
    print(response.status_code)
    print(response.body)
    print(response.headers)
except Exception as e:
    print(e.message)