Sendgrid Azure PHP
Ich bin ein Neuling in PHP, Azure und Sendgrid.
Es gibt einen Code, den ich für das HTML-Formular verwenden möchte.
<!-- 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-->
Hier ist das PHP, das ich versuche zu verwenden
Ich habe den Code wie folgt aktualisiert und meine Anmeldeinformationen und E-Mail-Adresse ausgetauscht. Keine Fehler, aber immer noch nicht bei mir. Kann ich noch etwas testen?
<?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);
?>
Und hier sind die Fehler, die ich erhalte. bool (true) Hinweis: Nicht definierte Variable: curl in D: \ home \ site \ wwwroot \ a_test_mailer_processor.php in Zeile 36 Warnung: curl_setopt () erwartet, dass Parameter 1 eine Ressource ist, null in D: \ home \ site \ wwwroot \ a_test_mailer_processor.php in Zeile 36
Ich habe versucht, Zeile 36 zu entfernen, curl_setopt ($ curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2); und die Fehler hörten auf, aber das Formular wurde immer noch nicht gesendet / empfangen. Lass mich wissen, was ich falsch mache.