Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sendgrid
- from sendgrid.helpers.mail import Content, Email, Mail
- sg = sendgrid.SendGridAPIClient("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")
- from_email = Email("my@gmail.com")
- to_email = Email("your@gmail.com")
- subject = "A test email from Sendgrid"
- content = Content(
- "text/plain", "Here's a test email sent through Python")
- mail = Mail(from_email, subject, to_email, content)
- response = sg.client.mail.send.post(request_body=mail.get())
- # The statements below can be included for debugging purposes
- print(response.status_code)
- print(response.body)
- print(response.headers)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement