Mailgun Sent mail With attachment

后端 未结 8 1652
眼角桃花
眼角桃花 2020-12-01 15:03

I am facing issue when mail having attachment sent using mailgun. If anyone has done this thing please reply. This is my code...

$mg_api = \'key-3ax6xnjp29jd         


        
8条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-01 15:28

    I realise this is old but I've just run into this problem and this page is pretty much the only info I can find on the net. So I hope this will assist someone else. After talking to MailGun support I've found the following works with the current API.

    Cycles through an array of zero to n attachment files:

        $attachmentsArray = array('file1.txt', 'file2.txt');
        $x = 1;
        foreach( $attachmentsArray as $att )
        {
            $msgArray["attachment[$x]"] = curl_file_create( $att );
            $x ++;
        }
    
        // relevant cURL parameter, $msgArray also contains to, from, subject  parameters etc.
        curl_setopt($ch, CURLOPT_POSTFIELDS,$msgArray);
    

提交回复
热议问题