Mailgun Sent mail With attachment

后端 未结 8 1642
眼角桃花
眼角桃花 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:34

    Thsi worked for me:

     'Excited User ',
        'to'      => 'test@gmail.com',
        'subject' => 'Hello',
        'text'    => 'test',
    'attachment[1]' => $filePath
    );
    
    $service_url = 'https://api.mailgun.net/v3/test.com/messages';
    $curl = curl_init($service_url);
    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($curl, CURLOPT_USERPWD, "api:key-test"); 
    
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_POST, true);
    
    curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 
    
    
    $curl_response = curl_exec($curl);  
    $response = json_decode($curl_response);
    curl_close($curl);
    
    var_dump($response);
    
    
    
     ?>
    

提交回复
热议问题