0
我正在開發一個PHP腳本,用於從Azure上承載的站點向用戶發送電子郵件。我正在使用SendGrid,使用以下代碼:在Microsoft Azure上使用sendgrid PHP
$url = 'https://api.sendgrid.com/';
$user = 'username';
$pass = 'password';
$params = array(
'api_user' => $user,
'api_key' => $pass,
'to' => $email,
'subject' => "Bid Submission",
'html' => "",
'text' => "y",
'from' => $emailFrom,
);
$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);
但是,上述代碼不會運行,也不會發送電子郵件。我已經設置了SendGrid帳戶,並且正在使用提供的用戶名和我自己的密碼。任何人都可以告訴我,我做錯了什麼?
嗨,任何更新? –