私はSendGridのPHP APIを使用してWebページの電子メールを設定しようとしています。私はAzureのウェブサイトからコードを試しただけでなく、Googleに試している間に見つけたさまざまな例を試してきました。応答として何も返さず、電子メールが設定されていないときはいつも。ここで私が話しているコードです:それはまた、私はそれに付属のコードを伴うsendgrid-PHPを使用して試したことは注目に値するSendGridを使用して電子メールを送信する方法
<?php
$url = 'https://api.sendgrid.com/';
$user = 'USERNAME';
$pass = 'PASSWORD';
$params = array(
'api_user' => $user,
'api_key' => $pass,
'to' => '[email protected]',
'subject' => 'testing from curl',
'html' => 'testing body',
'text' => 'testing body',
'from' => '[email protected]',
);
$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);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
// obtain response
$response = curl_exec($session);
curl_close($session);
// print everything out
print_r($response);
?>
は、それは単純にロードしないようにページを引き起こします。私は今、本当に困っています。どんな助けも大歓迎です。
コードをそのまま(ダミーのユーザー/パスを含む)実行すると、私は応答を得ます。 –
これは役に立つかもしれません:http://stackoverflow.com/questions/4477535/curl-init-function-not-working – Katie
私はphpinfo()を使用してチェックし、カールサポートが有効であると言います。 –