SendGrid

GRATIS CON POSSIBILITÀ DI UPGRADE
Verified
Official
Da sendgrid | Aggiornamento 2 mesi fa | Email
Popolarità

9.8 / 10

Latenza

298ms

Livello di servizio

100%

Torna a tutte le discussioni

My emails are successfully sending but the response is always an empty string variable.

avatar
mikhaelangelo
2 anni fa

i’m using PHP and CURL to send an email via rapidpro-sendgrid API and everything is done well but the response getted by the curl_exec() are a just blank and empty string (with double quotes).

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://rapidprod-sendgrid-v1.p.rapidapi.com/mail/send");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_ENCODING, "UTF-8");
curl_setopt($curl, CURLOPT_MAXREDIRS, 10);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POSTFIELDS, $messageField);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("accept: application/json","content-type: application/json","x-rapidapi-host: rapidprod-sendgrid-v1.p.rapidapi.com","x-rapidapi-key: *******"));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
     echo "cURL Error #:" . $err;
} else {
     echo $response;
}
avatar
alexwalling commented 2 anni fa

That’s to be expected! Any time an email is successfully send the request will simply respond with an empty 202 response.

avatar
mikhaelangelo commented 2 anni fa

lol, really? so i was all this time thinking that was something wrong… oh fuck hahahaha. So, in this case, we can say: if th response get anything than an empty string, thats mean there something got wrong? I mean… i can validate the send by doing something like:

if($response === "") {
echo "Success";
} else {
echo "Email not sent";
}

Is it safe to trust it? I really didn’t found anything in the docs that explain such a thing.

Partecipa alla discussione - aggiungi un commento di seguito:

Accedi/Iscriviti per pubblicare nuovi commenti
Valutazione: 4.8 - Voti: 5