SendGrid не может доставить почту в Yahoo, Hotmail, Outlook - PullRequest
0 голосов
/ 28 мая 2020

Я пытаюсь отправлять электронные письма через API SendGrid https://api.sendgrid.com/ с использованием PHP, CURL.

Пока я могу доставлять электронные письма в Gmail (как для домена моего офиса, так и для личные аккаунты), используя тот же код, электронные письма не доставляются в Yahoo / OutLook / HotMail. Для всех этих доменов API возвращает ответ как

{message:success}

, но электронные письма не доставляются. Я проверил Корзину / Спам, но мне не повезло.

Код CURL, который я использую:

function sendEmailResponse($to,$from,$subject,$response, $messageId)
{
    $subject = (!empty($subject)?$subject:'Email Campaign');
    header("Content-type: text/html");
    $url = 'https://api.sendgrid.com/';
    $user = constants::$sendGridUser;
    $pass = constants::$sendGridPwd;

    $json_string = array(

      'to' => array(
        $to
      ),
      'category' => $subject
    );


    $headers = array("In-Reply-To" => "{$messageId}");
    $plainText = $response;
    $plainText = strip_tags($plainText);

    $params = array(
        'api_user'  => $user,
        'api_key'   => $pass,
        'x-smtpapi' => json_encode($json_string),
        'to'        => $to,
        'replyto'   => $from,
        'subject'   => $subject,
        'text'      => $plainText,
        'html'      => $response,
        'from'      => $from,
        'headers' => json_encode($headers)
      );

    $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_HTTPHEADER, 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);
    return $response;
}

Нужно ли мне передавать какие-либо дополнительные заголовки / параметры для Yahoo / OutLook?

...