Answer the question
In order to leave comments, you need to log in
How to convert curl request to php?
There is an example request:
curl -s --user 'api:key-123456789 \
https://api.mailgun.net/v3/domain.com/messages \
-F from='Excited User ' \
--F to='[email protected] com' \
-F cc='[email protected]' \
-F bcc='[email protected]' \
-F subject='Hello' \
-F text='Testing some Mailgun awesomness!' \
--form-string html='HTML version of the body' \
-F [email protected]/cartman.jpg \
-F [email protected]/cartman.png
$post=array(
'to' => $to,
'from' => $from,
'subject' => $subject,
'text' => $plain,
'html' => $html
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_URL,
sprintf(' https://api.mailgun.net/v3/%s/%s ', $this->domain, $url));
curl_setopt($ch, CURLOPT_MAXREDIRS, 3);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_USERPWD, "api:{$this->apiKey}");
$result = curl_exec($ch);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question