Re: attach file problem.

From: Date: Wed, 01 Aug 2001 16:10:21 +0000
Subject: Re: attach file problem.
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-8618@lists.php.net to get a copy of this message
"Arthur" <arthur@ici.curitiba.pr.gov.br> wrote in message news:048001c11a9d$387eb460$f91c10ac@curitiba.pr.gov.br... > $Headers .= "MIME-version: 1.0\n"; > $Headers .= "Content-type: multipart/mixed; "; > $Headers .= "\nContent-Type:text/html"; > $Headers .= "boundary=\"Message-Boundary\"\n"; > $Headers .= "Content-transfer-encoding: 7BIT\n"; > $Headers .= "X-attachments: $attach_name"; > > $Headers .= "Content-type: $attach_type; name=\"$attach_name\"\n"; > $Headers .= "Content-Transfer-Encoding:base64_encode\n"; > $Headers .= "Content-disposition: attachment; filename=\"$attach_name\"\n\n"; > $Headers .= "$encoded_attach\n"; 1. You never start a block boundary 2. You give your message two global content-types 2. You never include a closing block boundary 3. You don't close your X-Attachments line, so Content-type will be run-on 4. You leave no spacing or separator between 'text/html' and 'boundary' 5. Your lines should end in \r\n (Windows systems may automatically expand \n, though). 6. If you are using mail(), you are mixing up what should be in the header vs. what should be in the body. 7. In theory it's possible to send several MIME messages and let them refer to sections of each other. Just to be correct, you should not use the same boundary in multiple messages - it should have a large randomized chunk. Try something like define("CRLF", "\r\n"); // may have to be "\n" only on Windows systems $bounds = makeRandBoundary(); // generate a randomized boundary text $headers = "MIME-Version: 1.0".CRLF ."Content-Type: multipart/mixed; boundary=\"$bounds\"".CRLF ; $msg = "This is a MIME-encoded message.".CRLF .CRLF ."--$bounds".CRLF ."Content-Type: text/html".CRLF ."Content-Transfer-Encoding: 7bit".CRLF .CRLF .$htmlMessage.CRLF ."".CRLF ."--$bounds".CRLF ."Content-Type: $attach_type; name=\"attach_name\"".CRLF ."Content-Transfer-Encoding: base64_encode".CRLF ."Content-Disposition: attachment; filename=\"$attach_name\"".CRLF .CRLF ."$encoded_attach".CRLF ."".CRLF ."--$bounds--".CRLF ; mail($to, $from, $msg, $headers); I don't guarantee any of this, it's just off the top of my head; if you want something to refer to, check your email client; it should have an option to let you read the raw text of a message. Send yourself an email with a small attachment, and see how it does it.

« previous php.windows (#8618) next »