mailGun Web API を使用していますが、インライン ファイルの追加の問題に遭遇しました。私たちのソフトウェアは画像を作成し、それを文字列として渡します。その画像をインライン化したい 私が抱えている問題は、php curl が実際のファイルではなく、ファイル ポインターを取り込むことです。サーバー上で動作する多くのプロセスがあり、悪いメールを送信したくないため、可能であれば tmp ファイルの書き込みを避けたい
前もって感謝します
MailGun インライン サンプル: http://documentation.mailgun.net/user_manual.html#inline-image 私が使用しているコード サンプル:
function send_inline_image($image) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, 'api:key-3ax6xnjp29jd6fds4gc373sgvjxteol0');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_URL, 'https://api.mailgun.net/v2/samples.mailgun.org/messages');
curl_setopt($ch,
CURLOPT_POSTFIELDS,
array('from' => 'Excited User <me@samples.mailgun.org>',
'to' => 'sergeyo@profista.com',
'subject' => 'Hello',
'text' => 'Testing some Mailgun awesomness!',
'html' => '<html>Inline image: <img src="cid:test.jpg"></html>',
'inline' => $image))
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
$image = 'Some image string that we have generated'
send_inline_image($image)