[英]How to add attachment to mailgun API using PHP
我一直在使用 mailgun API 在我的 PHP 應用程序中發送電子郵件,當我按照文檔添加附件參數時,出現錯誤:資源類型無效:array in /var/www/html/vendor/guzzlehttp/psr7/ src/functions.php
有人可以幫忙嗎?
$mgClient = new Mailgun('xxx');
$domain = "xxx";
$parameters = array(
'from' => 'xxx',
'to' => $to,
'subject' => $subject,
'text' => $text,
'attachment' = [
[
'filePath' => $attachment,
'filename' => $file_name,
]
];
);
$result = @$mgClient->sendMessage("$domain", $parameters);
我通過將附件數組添加為 sendMessage() 的第三個參數找到了解決方案
$mgClient->sendMessage("$domain", $parameters, ['attachment' => ['filePath' => $file_path]]);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.