Sendgrid Azure PHP
Я новичок в php, azure и sendgrid.
Вот код, который я нашел, что я пытаюсь использовать для формы 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-->
Вот PHP, который я пытаюсь использовать
Я обновил код следующим образом, меняя свои учетные данные и адрес электронной почты. Нет ошибок, но все еще не работает для меня. Есть ли что-то еще, что я могу проверить?
<?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);
?>
И вот ошибки, которые я получаю. bool (true) Примечание: неопределенная переменная: curl в D: \ home \ site \ wwwroot \ a_test_mailer_processor.php в строке 36 Предупреждение: curl_setopt () ожидает, что параметр 1 является ресурсом, ноль указывается в D: \ home \ site \ wwwroot \ a_test_mailer_processor.php в строке 36
Я попытался просто удалить строку 36, curl_setopt ($ curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2); и ошибки прекратились, но форма все еще не была отправлена / получена. Дайте мне знать, что я делаю не так.