mailgun을 사용하여 첨부 파일이있는 메일을 보내려고합니다. 메일 자체는 문제가 없지만 첨부 파일이 누락되었습니다. 또한 mailgun 로그에서 정상적으로 표시되지만 첨부 파일 배열이 비어 있습니다.Mailgun이 첨부 파일과 함께 메일을 보냅니다.
나는 내 자격 증명을 example.com으로 바꿨습니다. 파일은 하위 디렉토리에 있으며 읽을 수 있습니다. 나는이 발견 모든 문서에 따르면
"message": {
"headers": {
"to": "[email protected]",
"message-id": "[email protected]",
"from": "Example <[email protected]>",
"subject": "Subject"
},
"attachments": [],
"size": 349
},
: 첨부 파일이 나열되어 mailgun 로그 내에서
string(103) "{
"id": "<[email protected]>",
"message": "Queued. Thank you."
}"
:
는$filename = 'directory/example.pdf';
$parameters = array('from' => 'Example <[email protected]>',
'to' => '[email protected]',
'subject' => 'Subject',
'text' => 'This is just a test.',
'attachment[1]' => '@' . $filename);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.mailgun.net/v3/mail.example.com/messages');
curl_setopt($ch, CURLOPT_USERPWD, 'api:key-ThisIsJustARandomString');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: multipart/form-data'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
는 이는
$response
내가 오류가 발생하지 않는 것입니다
올바른 해결책이지만 작동하지 않습니다.
미리 답변 해 주셔서 감사합니다.
감사합니다. 덕분에 도움이되었습니다. – Vestalis