duanmianxue2687 2015-05-21 01:09
浏览 59
已采纳

PHP - 如何发送png或jpg电子邮件附件?

I am using mandrillapp for mailing using following method. But i need to send JPEG or PDF or PNG scan copy from scanner.

How can i do that please?

public static function sendBcc($from, $to, $subject, $htmlBody, 
          $bcc = '', $bcc1 = '', $utype = '') {
    $bcc = '', $bcc1 = '', $utype = '') {
    $uri = 'https://mandrillapp.com/api/1.0/messages/send.json';
    $postData = array(
        'key' => 'aaa',
        'message' => array(
            'html' => $htmlBody,
            'text' => $htmlBody,
            'subject' => $subject,
            'from_email' => $from,
            'from_name' => 'a',
            'to' => array(
                array('email'=>$to, 'name' => 'a', 'type' =>'to'),
                array('email'=>$bcc,'name' => 'Bcc 1', 'type' => 'bcc'),
                array('email'=>$bcc1,'name' => 'Bcc 2', 'type' => 'bcc')
            ),
        ),
    );
    $postString = json_encode($postData);

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $uri);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true );
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);

    $result = curl_exec($ch);  
    //curl_close($ch);
}
  • 写回答

1条回答 默认 最新

  • dongtiaobeng7901 2015-05-21 06:35
    关注

    Use the official reference from Mandrill: API reference.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 Keil uVision5创建project没反应
  • ¥15 mmseqs内存报错
  • ¥15 vika文档如何与obsidian同步
  • ¥15 华为手机相册里面的照片能够替换成自己想要的照片吗?
  • ¥15 陆空双模式无人机飞控设置
  • ¥15 sentaurus lithography
  • ¥100 求抖音ck号 或者提ck教程
  • ¥15 关于#linux#的问题:子进程1等待子进程A、B退出后退出(语言-c语言)
  • ¥20 web页面如何打开Outlook 365的全球离线通讯簿功能
  • ¥15 io.jsonwebtoken.security.Keys