[AOLSERVER] ns_sendmail is wrong for non-ascii strings
Hello! ns_sendmail can't work for non-ascii subject and body. I wrote the simple wrapper. is it possible to fix upstream version or add like wrapper? # note: _ns_sendmail is exists! if {[info commands orig_ns_sendmail] eq {}} { rename ns_sendmail orig_ns_sendmail package require base64 # headers are ignored! proc ns_sendmail {to from subject body args} { set headerSet [ns_set create] ns_set put $headerSet Content-Type {text/plain; charset=UTF-8} ns_set put $headerSet Content-Transfer-Encoding base64 ns_set put $headerSet MIME-Version 1.0 set subject [base64::encode [encoding convertto utf-8 $subject]] set subject =?UTF-8?B?${subject}?= set body [base64::encode [encoding convertto utf-8 $body]] orig_ns_sendmail $to $from $subject $body $headerSet [lindex $args 1] } } Best regards, Alexey Pechnikov. http://pechnikov.tel/ -- AOLserver - http://www.aolserver.com/ To Remove yourself from this list, simply send an email to lists...@listserv.aol.com with the body of SIGNOFF AOLSERVER in the email message. You can leave the Subject: field of your email blank.
Re: [AOLSERVER] ns_sendmail is wrong for non-ascii strings
On 5/26/09 2:00 PM, Alexey Pechnikov wrote: ns_sendmail can't work for non-ascii subject and body. I wrote the simple wrapper. is it possible to fix upstream version or add like wrapper? Nice wrapper - this assumes the receipient can understand MIME-encoded mail, which is probably the case but would break existing code that expects outgoing mail having the old behavior. Perhaps only define the wrapper if a ns_param is set in the configuration, and by default not apply the wrapper? Or, better yet: integrate your change into ns_sendmail directly and again, activate it using an optional proc argument or ns_param config setting. Ideally, it's probably best to work to define a reasonable ns_mail interface and implement it. ns_sendmail is an ugly wart that needs to go ... -- Dossy Shiobara | do...@panoptic.com | http://dossy.org/ Panoptic Computer Network | http://panoptic.com/ He realized the fastest way to change is to laugh at your own folly -- then you can let go and quickly move on. (p. 70) -- AOLserver - http://www.aolserver.com/ To Remove yourself from this list, simply send an email to lists...@listserv.aol.com with the body of SIGNOFF AOLSERVER in the email message. You can leave the Subject: field of your email blank.
Re: [AOLSERVER] ns_sendmail is wrong for non-ascii strings
If the subject is long then it should really go on multiple lines using header folding. checkout mime::word_encode in tcllib The From and To headers may also contain non ASCII characters. I use the following proc to fold and encode header values proc email_header_fold {string} { # Fold header into lines starting with a space as per rfc2822 set width 78 set start 0 set list {} while { $start[string length $string] \ [regexp -indices -start $start -- {(\[^\]+\)|(\([^\)]+\))|([^ ]+)} $string match] } { set atom [string range $string [lindex $match 0] [lindex $match 1]] # If characters above 127 then encode if { [regexp {([\u007F-\u00FF])} $atom] } { set list [concat $list [split [mime::word_encode utf-8 quoted-printable $atom] \r\n]] } else { lappend list $atom } set start [expr {[lindex $match 1]+1}] } set result {} set line [lindex $list 0] foreach string [lrange $list 1 end] { if { [string length $line $string]=78 } { append line $string } else { lappend result $line set line $string } } lappend result $line return [string map {\r\n \r\n } [join $result \r\n]] } -- Bernhard 2009/5/26 Alexey Pechnikov pechni...@mobigroup.ru Hello! ns_sendmail can't work for non-ascii subject and body. I wrote the simple wrapper. is it possible to fix upstream version or add like wrapper? # note: _ns_sendmail is exists! if {[info commands orig_ns_sendmail] eq {}} { rename ns_sendmail orig_ns_sendmail package require base64 # headers are ignored! proc ns_sendmail {to from subject body args} { set headerSet [ns_set create] ns_set put $headerSet Content-Type {text/plain; charset=UTF-8} ns_set put $headerSet Content-Transfer-Encoding base64 ns_set put $headerSet MIME-Version 1.0 set subject [base64::encode [encoding convertto utf-8 $subject]] set subject =?UTF-8?B?${subject}?= set body [base64::encode [encoding convertto utf-8 $body]] orig_ns_sendmail $to $from $subject $body $headerSet [lindex $args 1] } } Best regards, Alexey Pechnikov. http://pechnikov.tel/ -- AOLserver - http://www.aolserver.com/ To Remove yourself from this list, simply send an email to lists...@listserv.aol.com with the body of SIGNOFF AOLSERVER in the email message. You can leave the Subject: field of your email blank. -- AOLserver - http://www.aolserver.com/ To Remove yourself from this list, simply send an email to lists...@listserv.aol.com with the body of SIGNOFF AOLSERVER in the email message. You can leave the Subject: field of your email blank.