query($sql_insert) === true) { //Invio mail creatore $email = new \SendGrid\Mail\Mail(); $email->setFrom("info@n-hub.com", "NH-HR"); $email->addTo("$user_email", "$user_email"); $email->SetTemplateId("d-4cc102622d9e45f780395130e8e44196"); //Here is the Place holder values you need to replace. $email->addDynamicTemplateData("NHHR_verification_code", "$code"); $email->addDynamicTemplateData("NHHR_code_expiration", "" . date('d/m/Y H:i', strtotime($formatDate)) . ""); $sendgrid = new \SendGrid(SENDGRID_API_KEY); try { $response = $sendgrid->send($email); echo "ok"; } catch (Exception $e) { echo 'Caught exception: ' . $e->getMessage() . "\n"; } } else { echo "error"; }