我使用mailgun api发送电子邮件 . 我的php版本是5.3

我必须附加不是multipart / form数据的文件 . 我的意思是我有绝对的文件路径,所以如何通过Curl php发送附件?

我看到了mailgun文件 . 我找到了这个:

文件附件 . 您可以发布多个附件值 . 重要说明:发送附件时必须使用multipart / form-data编码 .

但我只有绝对的路径 multipart/form data . 那么我现在该怎么办呢?

添加 Headers 为:

curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: multipart/form-data"));

这是我通过mailgun API发送的输入数组:

数组([from] => xyz [to] => abc@gmail.com

[subject] => ryreyreyre

[text] => yreyreyreyreyre
 
此致,
xyz
[html] => yreyreyreyreyre
 
此致,
xyz
[attachment] =>数组

[0] => @ / var / www / vhosts / download / attachment / 1418034032618discover.png
[1] => @ / var / www / vhosts / download / attachment / 1418034032395master.png
[2] => @ / var / www / vhosts / download / attachment / 1418034032208visa.png

这是我的卷曲请求

$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($ch, CURLOPT_USERPWD, 'api:'.MAILGUN_APIKEY);
    if(!empty($postArr['attachments']))
    {
        curl_setopt ($ch, CURLOPT_VERBOSE, 0);
         curl_setopt ($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: multipart/form-data"));
    }
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');

    curl_setopt($ch, CURLOPT_URL, 'https://api.mailgun.net/v2/'.MAIL_VIA_DOMAIN.'/messages');
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postArr);

   $http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $result = curl_exec($ch);
    curl_close($ch);

邮件正被发送到我的邮件收件箱,但我没有收到附件 . 看着日志也说它附件空了