curl 메서드를 사용하여 고객 프로젝트에 SendGrid를 사용하고 있습니다.SendGrid - Curl PHP 외부 파일 첨부가 깨졌습니다.
모두 잘되지만 SendGrid로 보내는 이메일에 첨부 된 (ir) 파일이 손상되었습니다. 내가 배열의 내 키 확장 파일이없는 때, 나는 관련 값을 포함하는 텍스트 파일을했습니다
$documentList = array(
"DOC1.php" => "http://www.customerdomain.com/my/path/where/my/attachment/file/is/myfile.pdf"
);
$params = array(
'api_user' => $user;
'api_key' => $pass,
'x-smtpapi' => json_encode($json_string),
'from' => $from,
'to' => $to,
'subject' => $subject,
'html' => $mailHtml,
'text' => $mailText
);
if(count($documentList)>0){
foreach($documentList as $fileName=>$documentPath){
$params['files['.$fileName.']'] = $documentPath;
}
}
$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);
:
여기 내 코드입니다.
이 문제를 해결할 생각이 있다면 혼자만의 문제는 아닙니다. 도움을 주셔서 감사합니다.
'curl_file_create'이 효과적입니다. – Shahbaz