Construct a Nested Multipart mail

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I used pear api to make this mail but I can t add multipart.My mail
structure is like that.

part 1: a file
part 2: multipart
            part 1: a file
            part 2: a file

Content-Type: multipart/related; boundary="----
=_Part_1130_31345073.1112689804895"; type="text/xml";
Content-Length: 2062
SOAPAction: "urn:mm7DeliverReq"


I searched and test pear api(mimepart.php) but I cant make this.
function mmsCombiner( $env) {
        global $requestAttachments;
        $params['content_type'] = 'multipart/related';
        $mimeMessage =& new Mail_mimePart('', $params);

        $params['content_type'] = 'text/xml';
        $params['encoding']     = '8bit';
        $params['charset']      = 'utf-8';
        $mimeMessage->addSubpart($env, $params);

        $paramsInner['content_type'] = 'multipart/related';
        $mimeInnerMessage =& new Mail_mimePart('', $paramsInner);
        foreach ($requestAttachments as $att) {
            $paramsInner['content_type'] = $att['contenttype'];
            // TODO it must be changed
            $paramsInner['encoding']     = '7bit';
            //$params['disposition']  = 'attachment';
            $paramsInner['dfilename']    = $att['filename'];
            $paramsInner['cid']          = $att['cid'];
            if ($att['data'] == '' && $att['filename'] <> '') {
                if ($fd = fopen($att['filename'], 'rb')) {
                    $data = fread($fd, filesize($att['filename']));
                } else {
                    $data = '';
                $mimeInnerMessage->addSubpart($data, $paramsInner);
            } else {
                $mimeInnerMessage->addSubpart($att['data'], $paramsInner);

        $outputInner = $mimeInnerMessage->encode();
        $mimeInnerHeaders = $outputInner['headers'];
        $headInner ="";
        foreach ($mimeInnerHeaders as $k => $v) {
            $headInner.="$k: $v \n";
            //echo $headInner;

        $attachment =  $headInner."\n".$outputInner['body'];

        $paramsInner['content_type'] = 'multipart/related';
        $mimeMessage->addSubpart($attachment, array());
        $output = $mimeMessage->encode();
        $mimeHeaders = $output['headers'];
        $head ="";
        foreach ($mimeHeaders as $k => $v) {
            $head.="$k: $v \n";
        //return $attachment;
        echo $head."\n".$output['body'];
        //return $head."\n".$output['body'];

How can I achieve to construct nested multipart?


Re: Construct a Nested Multipart mail


on 04/21/2007 07:14 AM gezerpunta said the following:
Quoted text here. Click to load it

I don't know if it is possible to achieve that with PEAR Mail, but you
certainly can with this popular MIME message composing and sending class.


Manuel Lemos

Metastorage - Data object relational mapping layer generator

PHP Classes - Free ready to use OOP components written in PHP

Re: Construct a Nested Multipart mail

Kimmo Laine wrote:
Quoted text here. Click to load it

Unless next_page.php generates PHP, the script with this include will
only get HTML.

Quoted text here. Click to load it


    if (isset($_GET['foo'])) {
      echo '<?php echo $_GET[\'foo\']; ?>';
    } else {
      echo '<?php echo \'Not available\'; ?>';

File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot

Site Timeline