0

I'm using the SendGrid sample code to make sure my Token is ready, but every time I try to run it I get an error with RFC822 My Sample Code:

import os
import sendgrid
from sendgrid.helpers.mail import Mail

message = Mail(
    from_email='someone@gmail.com',
    to_emails='someone@gmail.com',
    subject='Sending with Twilio SendGrid is Fun',
    html_content='<strong>and easy to do anywhere, even with Python</strong>')
try:
    sg = sendgrid.SendGridAPIClient('some token')
    response = sg.send(message)
    print(response.status_code)
    print(response.body)
    print(response.headers)
except Exception as e:
    print(e.message)

I always get this error:

ModuleNotFoundError: No module named 'rfc822'

During handling of the above exception, another exception occurred:
ImportError: cannot import name 'Mail' from partially initialized module 'sendgrid.helpers.mail' (most likely due to a circular import) (/home/userrrr/.local/lib/python3.8/site-packages/sendgrid/helpers/mail/__init__.py)

I'm using python3 and pip3, also tried older versions of sendgrid with no hope, also tried it on Windows and Ubuntu

Any ideas? Thank You !

Joseph Khella
  • 695
  • 1
  • 9
  • 26

0 Answers0