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

时间:2015-05-21 01:09:15

标签: php zend-framework

我使用mandrillapp使用以下方法进行邮寄。但我需要从扫描仪发送JPEG或PDF或PNG扫描副本。

我该怎么办呢?

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 个答案:

答案 0 :(得分:0)

使用Mandrill的官方参考:API reference