addTo($to); $content = new SendGrid\Content("text/plain", "some text here"); $mail = new SendGrid\Mail(); $mail->setFrom($from); $mail->setSubject($subject); $mail->addPersonalization($personalization); $mail->addContent($content); $to = new SendGrid\Email(null, "test2@example.com"); $mail->personalization[0]->addTo($to); //echo json_encode($mail, JSON_PRETTY_PRINT), "\n"; return $mail; } function sendHelloEmail() { $apiKey = getenv('SENDGRID_API_KEY'); $sg = new \SendGrid($apiKey); $request_body = helloEmail(); $response = $sg->client->mail()->send()->post($request_body); echo $response->statusCode(); echo $response->body(); echo $response->headers(); } ?>