When sending emails with SendGrid, the code does not work. For example, in the file sendgrid_email_adapter.py, the code self.sg = SendGridAPIClient(apikey=sendgrid_api_key) is invalid with the sendgrid library.
I was able to successfully send email by replacing the function with the following code:
def send_email_message(self, recipient, subject, html_message, text_message, sender_email, sender_name):
if not current_app.testing: # pragma: no cover
try:
# Prepare Sendgrid helper objects
from sendgrid.helpers.mail import Mail
msg = Mail(
from_email=sender_email,
to_emails=recipient,
subject=subject,
html_content=html_message)
response = self.sg.send(msg)
print(response.status_code)
print(response.body)
print(response.headers)
except ImportError:
raise ConfigError(SENDGRID_IMPORT_ERROR_MESSAGE)
except Exception as e:
print(e)
#print(e.body)
raise
When sending emails with SendGrid, the code does not work. For example, in the file
sendgrid_email_adapter.py
, the codeself.sg = SendGridAPIClient(apikey=sendgrid_api_key)
is invalid with the sendgrid library.I was able to successfully send email by replacing the function with the following code: