ad_parse_incoming_email (public)
ad_parse_incoming_email message
Defined in packages/acs-tcl/tcl/html-email-procs.tcl
Takes an incoming message and splits it into parts. The main goal of this proc is to return something that can be stuffed into the database somewhere, such as a forum message. Since we aggressively filter HTML, the HTML tags are stripped out of the returned content. The message may have only plain text, plain text and HTML, or plain text and something else (Apple Mail uses text/enhanced, for example). To make our lives simpler we support only text/html as a special case; in all other cases the plain text is returned.
- Parameters:
- message (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: if { [catch {set mime [mime::initialize -string $message]} err ] } { ns_log error "parse_incoming_email: could not parse message; error was $err" return "" } set content [mime::getproperty $mime content] if { [string first "multipart" $content] != -1 } { set parts [mime::getproperty $mime parts] } else { set parts [list $mime] } # Expand any first-level multipart/alternative children. set expanded_parts [list] foreach part $parts { catch {mime::getproperty $part content} this_content if { $this_content eq "multipart/alternative"} { foreach child_part [mime::getproperty $part parts] { lappend expanded_parts $child_part } } else { lappend expanded_parts $part } } foreach part $expanded_parts { catch {mime::getproperty $part content} this_content switch -- $this_content { "text/plain" { if { ![info exists plain] } { set plain [mime::getbody $part] } } "text/html" { if { ![info exists html] } { set html [mime::getbody $part] } } } } if { [info exists plain] } { set body $plain } elseif { [info exists html] } { set body [ad_html_to_text -- $html] } else { set body $message } mime::finalize $mime -subordinates all return $bodyXQL Not present: Generic, PostgreSQL, Oracle