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.

    点赞 打赏 评论

相关推荐 更多相似问题