Hi,
Can you help me to find the problem in this code?
import sendgrid
from sendgrid.helpers.mail import Email, Mail, Content
API_KEY = "xxxxxxxxxx"
SUBJECT = "Welcome"
BODY = "Hi {name}"
sg = sendgrid.SendGridAPIClient(API_KEY)
def send_email(email, name):
global API_KEY
global SUBJECT
global BODY
BODY="Hi {}".format(name)
message = Mail(
from_email='xxx@gmail.com',
to_emails=email,
subject=SUBJECT,
html_content=BODY
)
message.content = Content('text/plain', BODY)
try:
sg = sendgrid.SendGridAPIClient(API_KEY)
response = sg.send(message)
print(response.status_code)
print(response.body)
print(response.headers)
except Exception as e:
print(e)
Created at: 2020/03/06 19:47; Updated at: 2020/04/10 19:46