加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 邮件邮件附件

发布时间:2020-12-13 17:27:38 所属栏目:PHP教程 来源:网络整理
导读:当使用邮件发送附件的邮件时,我正面临问题. 如果有人做了这件事,请回覆. 这是我的代码… $mg_api = 'key-3ax6xnjp29jd6fds4gc373sgvjxteol0';$mg_version = 'api.mailgun.net/v2/';$mg_domain = "samples.mailgun.org";$mg_from_email = "info@samples.com";
当使用邮件发送附件的邮件时,我正面临问题.
如果有人做了这件事,请回覆.
这是我的代码…
$mg_api = 'key-3ax6xnjp29jd6fds4gc373sgvjxteol0';
$mg_version = 'api.mailgun.net/v2/';
$mg_domain = "samples.mailgun.org";
$mg_from_email = "info@samples.com";
$mg_reply_to_email = "info@samples.org";

$mg_message_url = "https://".$mg_version.$mg_domain."/messages";


$ch = curl_init();
curl_setopt($ch,CURLOPT_HTTPAUTH,CURLAUTH_BASIC);

curl_setopt ($ch,CURLOPT_MAXREDIRS,3);
curl_setopt ($ch,CURLOPT_FOLLOWLOCATION,false);
curl_setopt ($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt ($ch,CURLOPT_VERBOSE,0);
curl_setopt ($ch,CURLOPT_HEADER,CURLOPT_CONNECTTIMEOUT,10);
curl_setopt ($ch,CURLOPT_SSL_VERIFYPEER,CURLOPT_SSL_VERIFYHOST,0);

curl_setopt($ch,CURLOPT_USERPWD,'api:' . $mg_api);
curl_setopt($ch,1);

curl_setopt($ch,CURLOPT_POST,true); 
//curl_setopt($curl,CURLOPT_POSTFIELDS,$params); 
curl_setopt($ch,false); 

//curl_setopt($ch,CURLOPT_CUSTOMREQUEST,'POST');
curl_setopt($ch,CURLOPT_URL,$mg_message_url);
curl_setopt($ch,array(  'from'      => 'aaaa <' . 'aaa@aaa.com' . '>','to'        => 'test.client91@gmail.com','h:Reply-To'=>  ' <' . $mg_reply_to_email . '>','subject'   => 'aaaaa'.time(),'html'      => 'aaaaaa','attachment'[1] => 'aaa.rar'
            ));
$result = curl_exec($ch);
curl_close($ch);
$res = json_decode($result,TRUE);
print_r($res);

(我用过我的邮件设置)

我收到的电子邮件没有附件.如果我使用URL路径,它会显示URL而不是附件.

您需要以下列方式更改最后一个参数:
附件[1]’=> ‘@aaa.rar

我们在我们的文档中有一些示例用于此用例.只需点击顶部栏中的PHP即可切换语言.
http://documentation.mailgun.net/user_manual.html#examples-sending-messages-via-http

请随时向我们发送电子邮件至support@mailgunhq.com.我们总是乐意帮助.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读