請告訴我,我使用 curl php 電子郵件(gmail api)發送。內容型別是訊息/rfc822。發送時如何在電子郵件的主題中使用西里爾字母。在字母的正文中,西里爾字母正常顯示,在字母的主題中顯示為符號。D??€D?D2Dμ?。
$access_token = "***";
$message = "To: ".addslashes($_POST['to'])."\r\nSubject: ".addslashes($_POST['subject'])."\r\n\r\n".addslashes($_POST['message']);
$ch = curl_init('https://www.googleapis.com/upload/gmail/v1/users/me/messages/send');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer ".$access_token, 'Accept: application/json', 'Content-Type: message/rfc822; charset=utf-8'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $message);
$data = curl_exec($ch);
uj5u.com熱心網友回復:
您需要使用標準的 php 函式:
mb_encode_mimeheader($_POST['subject'], "UTF-8");
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/484806.html
