• You need to work on this!

Question related to mission Welcome Email by SendGrid


Over 5000 people have attempted to complete this task and less than 1300 have completed it. Users attempted: 5030 Users succeeded: 1264 (congrats to these people not sure how they did it though)

To start with you should allow html_content which is the default in the example you sent everyone to.

Additionally I had to import Content in order to be able to set the text/plain attribute in the message that one of the unit tests are testing. This is not in the examples either; this took substantial digging to figure out.

Next there should be a few more ways to run the asserts at the bottom to know if you are doing it right. For example why not have the send function return a tuple of the status codes from Send grid, you could pre set the return values in the tuple in the template.

CheckIO people you should be checking on high failure rates of tasks and get author to correct the issues or fix them. I am assuming that Send Grid is using this to promote there systems which is why it is an early unlock for new users.

I use SendGrid at work so its not like this is overly hard but not seeing the tests that he is running makes it near impossible. I see some assert error for a function "Fail: sumtwo("admin@checkio.org","Alex")" that is not even in the description that it needs to be ran for. What the hell is sumtwo and how is it related to this send grid task.

import sendgrid
from sendgrid.helpers.mail import Mail,Content

API_KEY = 'SGxxxxxx'
SUBJECT = 'Welcome'
BODY = 'Hi {name}'

sg = sendgrid.SendGridAPIClient(API_KEY)

def send_email(email, name):
    global API_KEY
    global SUBJECT
    global BODY

    message = Mail(
    message.content = Content('text/plain', BODY)
        sg = sendgrid.SendGridAPIClient(API_KEY)
        response = sg.send(message)
    except Exception as e:

if __name__ == '__main__':
    #These "asserts" using only for self-checking and not necessary for auto-testing
    send_email('paul@example.com', 'paul')