SendGrid

FREEMIUM
Verified
Official
Official
Durch Sendgrid | Aktualisiert 4 days ago | Email
Popularität

9.5 / 10

Latenz

388ms

Service Level

100%

Health Check

N/A

Zurück zu allen Diskussionen

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

Rapid account: Mikhaelangelo
mikhaelangelo
4 years ago

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;
}
Rapid account: Mikhaelangelo
mikhaelangelo Commented 4 years ago

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.

Rapid account: Alexwalling
alexwalling Commented 4 years ago

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

Nehmen Sie an der Diskussion teil - fügen Sie unten einen Kommentar hinzu:

Anmelden / Registrieren, um neue Kommentare zu veröffentlichen