

@app.route('/send/email', methods=['POST'])
def send_email():
    to = request.form.get('to')
    if (not to):
        return 'Please provide an email address in the "to" query string parameter.'
    sg = sendgrid.SendGridClient(SENDGRID_API_KEY)
    message = sendgrid.Mail(to=to, subject='This is a test email', html='<p>Example HTML body.</p>', text='Example text body.', from_email=SENDGRID_SENDER)
    (status, response) = sg.send(message)
    if (status != 200):
        return 'An error occurred: {}'.format(response)
    return 'Email sent.'

dataset/ETHPy150Open GoogleCloudPlatform/python-docs-samples/managed_vms/sendgrid/main.py send_email/original