2016-05-11 10 views
0

上で実行されていないグリッドのメールAPIを送信します。カール関数または私は電子メールを送信するために、以前にこのコードを使用していた私のサーバー

<?php 

    $tos='[email protected]'; 
    $subject09='hello madam223'; 
    $messageto90='this is a test'; 
    $myName_emailis='Sonam '; 
$emaillist_act=array('[email protected]','[email protected]'); 
$json_string = array('to' =>$emaillist_act,'category' => 'activity'); 

$url = 'https://api.sendgrid.com/'; 
$user = 'username'; 
$pass = 'password'; 
$params = array(
'api_user' => $user, 
'api_key' => $pass, 
'x-smtpapi' => json_encode($json_string), 
'to'  => "$tos", 
'subject' => "$subject09", 
'html'  => "$messageto90", 
'fromname' => $myName_emailis, 
'from'  => "domain.com <[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); 
// 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_r($response); 
?> 

しかし今、同じコードが何もしません。応答を印刷したり、電子メールを送信したりすることはありません。

私は私がカール機能でそれを確認して自分のサーバーにインストールし、

function _is_curl_installed() { 
if (in_array ('curl', get_loaded_extensions())) { 
    return true; 
} 
else { 
    return false; 
} 
} 

そして、それは本当の私を示していないことが、カールかもしれないと思った。..

考えられる理由何ができますか?私を助けてください。 それはまだ問題があるかもしれない私のサーバーではなく、他のサーバー上で成功メッセージを印刷していますか?

+0

私は同じコードが多くのドメインに存在しているとして、私は、コードを変更するカントのparamater https://sendgrid.com/docs/Integrate/Code_Examples/php.html – JiteshNK

答えて

0

api url自体にapi userid、apiキーを送信してみます。そしてカールは別の定義を必要としません。私は働いているjsonデータを取得するために次のコードを使いました。

$json_url = "https://httpapi.com/api/products/reseller-price.json?auth-userid"; 

$ch = curl_init(); 

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); 

curl_setopt($ch, CURLOPT_URL, $json_url); 

$str = curl_exec($ch); 

$ar = json_decode($str,true); 

    echo $ar['domcno'][0]['pricing']['addnewdomain'][1]; 
+0

といくつかの変更があると思い、このリンクをチェックしてくださいすべての私のdomaisは同じサーバー上でホストされています。だから私はサーバー側から問題を解決する必要があります –

+0

最初に動作していたコードは?そして今は問題に直面していますか? 「mail」フィールドから「name」だけに変更してメールを送信しようとしましたか?gmailがdomain.comを含むフィールドからメールを拒否している可能性があります。昨日同様の問題に直面しました。 。私はちょうど初心者ですが、まだウェブ開発の深い勉強をしていません。しかし、私はあなたがここで探している必要な助けを得ることを願っています。 – GBnewbie

+0

同じコードが他のサーバーでも動作します.. –

関連する問題