I'm having huge problems with SendGrid working on my Azure subscription. He just does not send emails! I followed the textbooks, and the code is essentially copied from them, but letters are not sent to my address. The code below is used for my contact form.
My main problem is that echo $responseit gives nothing - not even space.
<?php
$url = 'https://api.sendgrid.com/';
$user = 'removed';
$pass = 'removed';
$to = 'removed@removed.com';
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$params = array(
'api_user' => $user,
'api_key' => $pass,
'to' => $to,
'subject' => $subject,
'html' => $message,
'text' => $message,
'from' => $email,
);
$request = $url.'api/mail.send.json';
$session = curl_init($request);
curl_setopt ($session, CURLOPT_POST, true);
curl_setopt ($session, CURLOPT_POSTFIELDS, $params);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
curl_close($session);
echo '<script language="javascript">';
echo 'alert("Message Sent.")';
echo '</script>';
echo 'DEBUG: Contact Form works but not fully operational.';
echo $response;
exit();
source
share