I am using AWS Lambda, Python 3.7 and SendGrid API and want to send an email but getting the error:
"Unable to import module 'lambda_function': No module named 'sendgrid'"
Is there a way to resolve this? I can see that in some similar issues that the module would be imported from somewhere but can't work out from where.
My lambda code is just the sample code from the SendGrid website which values updated with the ones I want to use:
import json
import sendgrid
import os
from sendgrid.helpers.mail import *
def lambda_handler(event, context):
sg = sendgrid.SendGridAPIClient(apikey=os.environ.get('SENDGRID_API_KEY'))
from_email = Email("test@example.com")
to_email = Email("****")
subject = "Sending with SendGrid is Fun"
content = Content("text/plain", "and easy to do anywhere, even with Python")
mail = Mail(from_email, subject, to_email, content)
response = sg.client.mail.send.post(request_body=mail.get())
print(response.status_code)
print(response.body)
print(response.headers)
Thanks