Sendgrid Azure PHP
Soy un novato en php, azure y sendgrid.
Aquí hay un código que encontré que estoy tratando de usar para el formulario html.
<!-- BEGINNING OF CONTACT FORM -->
<div class="section-page-landing" id="contact">
<div class="inner-section">
<div class="contain">
<center><h2>Contact Me</h2>
<form class="contact" action="a_test_mailer_processor.php" method="post">
<p>Name:</p> <!-- Can choose to customize form.html inputs starting here as needed, but be sure to reference any changes in mailer.php post fields-->
<input type="text" name="name" />
<p>E-mail:</p>
<input type="text" name="email" />
<p>Subject:</p>
<input type="text" name="subject" />
<p>Message:</p>
<textarea name="message" syle="width: 45%; text-align: center;">Please leave a short message here</textarea></p>
<input class="send" type="submit" value="Send"> <!-- Send button-->
</form></center>
</div>
</div>
</div>
<!--end contact form-->
Aquí está el PHP que estoy tratando de usar
Actualicé el código de la siguiente manera, cambiando mis credenciales y mi dirección de correo electrónico. Sin errores, pero aún no funciona para mí. ¿Hay algo más que pueda probar?
<?php
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
var_dump(function_exists('curl_version'));
$url = 'https://api.sendgrid.com/';
$user = 'MYSENDGRIDUSERNAME';
$pass = 'MYSENDGRIDPASSWORD';
$params = array(
'api_user' => $user,
'api_key' => $pass,
'to' => 'MYEMAILADDRESS',
'subject' => 'testing from curl',
'html' => 'testing body',
'text' => 'testing body',
'from' => 'MYEMAILADDRESS',
);
$request = $url.'api/mail.send.json';
// Generate curl request
$session = curl_init($request);
// Tell curl to use HTTP POST
curl_setopt ($session, CURLOPT_POST, true);
// Tell curl that this is the body of the POST
curl_setopt ($session, CURLOPT_POSTFIELDS, $params);
// Tell curl not to return headers, but do return the response
curl_setopt($session, CURLOPT_HEADER, false);
// Tell PHP not to use SSLv3 (instead opting for TLS)
curl_setopt($session, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
// obtain response
$response = curl_exec($session);
curl_close($session);
// print everything out
print_r($response);
?>
Y aquí están los errores que estoy recibiendo. bool (true) Aviso: Variable indefinida: curl en D: \ home \ site \ wwwroot \ a_test_mailer_processor.php en la línea 36 Advertencia: curl_setopt () espera que el parámetro 1 sea recurso, nulo en D: \ home \ site \ wwwroot \ a_test_mailer_processor.php en la línea 36
Intenté simplemente eliminar la línea 36, curl_setopt ($ curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2); y los errores se detuvieron pero el formulario aún no se envió / recibió. Déjame saber lo que estoy haciendo mal.