How do I submit an application using mailgun?

I am trying to send an attachment using curl

via mailgun

, but its sending an email without the attachment. (I only receive email with part of the html, but no attachments). Here is my code

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($ch, CURLOPT_USERPWD, 'api:'.$api_key);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
    curl_setopt($ch, CURLOPT_URL, 'https://api.mailgun.net/v3/'.$domain.'/messages');
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;

      

$postFields

is an array with the following value.

Array
(
    [from] => ***
    [to] => *** 
    [subject] => ***
    [html] => ***
    [attachment] => Array
        (
            [0] => /home/***/n.jpg
            [1] => /home/***/n2.jpg
        )

)

      

+3
api php curl mailgun


source to share


No one has answered this question yet

See similar questions:

44
how to download file using curl from php

or similar:

2480
How do I send JSON data using Curl from terminal / command line to Test Spring REST?
2263
How to get YouTube video thumbnail using YouTube API?
895
How do I send a header using an HTTP request through curl?
five
cURL doesn't work sometimes and gives an empty result
4
How to implement caching system in php for json api
3
Post php Curl for PHPBB
2
ABBYY OCR SDK: I am trying to use a sample script to recognize business cards, but I am not getting any output
2
extract url from xml response and redirect
0
shell_exec escapes quotes in php for Twitter API & # 8594; Getting CURL to work with obscure twitter-api method
0
How can I check if RESTAPI is not working using curl php



All Articles
Loading...
X
Show
Funny
Dev
Pics