我一直在搜索,因此请使用 mailgun api 和标准 php php curl - 不使用Mailgun SDK ,没有运气,所以我求助于发布问题。
到目前为止,这是我的代码:
$url = 'https://api:**my-key**@api.eu.mailgun.net/v3/**my-domain.com**/messages';
$from = 'Admin < admin@my-domain.com >';
$to = 'Excite User < user@somewhere.com >';
$subject= 'Excite Stuff In Here';
$body = '<html>
<img src="cid:logo_sml.png">
<p>Testing Mailgun API with inline images</p>
</html>';
$text = strip_tags( nl2br($body) );
$tag = 'Test';
$inline = ['inline' => realpath('../includes/images/logo_sml.png')];
// parameters of message
$params = [
'from' => $from,
'to' => $to,
'subject' => $subject,
'text' => $text,
'html' => $body,
'inline' => json_encode($inline),
'o:tag' => $tag
];
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_FAILONERROR, TRUE);
curl_setopt($curl, CURLOPT_POSTFIELDS, $params );
$data_results = curl_exec($curl);
$response = json_decode($data_results);
curl_close($curl);
电子邮件是在没有任何错误消息的情况下发送的,但没有图像,无论是内联还是附件。我要去哪里?
我提出了一张带有邮件支持的票,而马可(Marco
$inline = curl_file_create(realpath('../includes/images/logo_sml.png'));
...
'inline' => $inline,
curl_file_create - 创建一个卷曲文件对象以连接图像。代码的其余部分不变。