Anonymous | Login | Signup for a new account | 11-21-2024 16:21 PST |
Main | My View | View Issues | Change Log | Docs |
Viewing Issue Simple Details [ Jump to Notes ] | [ View Advanced ] [ Issue History ] [ Print ] | |||||||||||
ID | Category | Severity | Reproducibility | Date Submitted | Last Update | |||||||
0003923 | [Quercus] | minor | always | 03-03-10 12:42 | 02-10-11 10:53 | |||||||
Reporter | emil | View Status | public | |||||||||
Assigned To | ||||||||||||
Priority | normal | Resolution | open | |||||||||
Status | new | Product Version | 4.0.5 | |||||||||
Summary | 0003923: Multipart messages get stuffed into a single mime part by Javamail | |||||||||||
Description |
(rep by michitopf) In PHP one can easily send Multipart MIME messages. I use the code below to accomplish this. In Quercus this no longer works. It seems that the whole message is wrapped in a single large MIME part of a JavaMail MimeMessage. How can I then send Multipart MIME messages in Quercus? /*---------- * $parts is an array where each entry represents a MIME part and is in turn another array with following entries: * $parts[$i]['content-type'] * $parts[$i]['content-transfer-encoding'] ... 8bit (default), base64 * $parts[$i]['filename'] * $parts[$i]['content'] */ function send_multipart_mail($to, $from, $subject, $parts) { global $mail_error; $boundary = '=_' . strtoupper(md5(uniqid('', true))); $headers = ''; if ($from) $headers .= 'From: ' . $from . CRLF; $headers .= 'MIME-Version: 1.0' . CRLF; $headers .= 'Date: ' . date('r') . CRLF; // 'r' ... RFC 822 $headers .= 'Content-Type: multipart/mixed;' . CRLF; $headers .= ' boundary="' . $boundary . '"'; $headers .= 'Content-Transfer-Encoding: 8bit' . CRLF; $text = 'This is a message with multiple parts in MIME format.' . CRLF; foreach ($parts as $part) { $text .= '--' . $boundary . CRLF; $text .= 'Content-Type: ' . $part['content-type'] . CRLF; $content_transfer_encoding = $part['content-transfer-encoding']; if (!$content_transfer_encoding) $content_transfer_encoding = '8bit'; $text .= 'Content-Transfer-Encoding: ' . $content_transfer_encoding . CRLF; $filename = $part['filename']; if ($filename) $text .= 'Content-Disposition: attachment; filename="' . $filename . '"' . CRLF; $text .= CRLF; $content = $part['content']; if ($content_transfer_encoding == 'base64') $content = trim(chunk_split(base64_encode($content))); $text .= $content . CRLF; } $text .= '--' . $boundary . '--'; set_error_handler(mail_error_handler); $mail_ok = mail($to, $subject, $text, $headers); restore_error_handler(); return $mail_ok; } The code can be used like this (also serves as a testcase): $text = array( 'content-type' => 'text/plain; charset="ISO-8859-1"', 'content' => 'Dear recipient,' . CRLF . CRLF . 'attached you will find the requested information' . CRLF . CRLF . 'regards' . CRLF . 'Server' . CRLF . CRLF ); $attachment = array( 'content-type' => 'text/xml', 'content-transfer-encoding' => 'base64', 'filename' => 'info.xml', 'content' => '<?xml version="1.0" encoding="ISO-8859-1" ?>' . CRLF . '<info>Test</info>'); send_multipart_mail('to@recipient.com', 'from@sender.org', 'Subject', array($text, $attachment)); |
|||||||||||
Additional Information | ||||||||||||
Attached Files | Main.java [^] (1,384 bytes) 02-10-11 10:53 | |||||||||||
|
Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
38 total queries executed. 29 unique queries executed. |