0
私は基本的に、重複したメールアドレスにメールを送信しても奇妙な結果を得るためにSendgridの例を見ています。毎回重複したメール(4件)が届きます。私はいくつかのスレッドを見てきましたが、ほとんどすべてが重複要求によって解決されています。しかし、私が見ることができるものから、何もありません(そして、これは基本的にSendgridのスクリプト例です)。すべてのヘルプは大...いただければ幸いSendgridの例PHPが重複したメールを送信する
コード:
$url = 'https://api.sendgrid.com/';
$user = 'My Username';
$pass = 'My Password';
$json_string = array(
'to' => array(
'[email protected]', '[email protected]'
),
'category' => 'test_category'
);
$params = array(
'api_user' => $user,
'api_key' => $pass,
'x-smtpapi' => json_encode($json_string),
'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);
// 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 everything out
print_r($response);
プリントアウトが言う成功(一回のみ)。電子メールは正常に配信されます。唯一の問題は、4つの電子メールがすべての電子メールボックスに表示されることです。