Forum OpenACS Q&A: error when trying to encode japanese subject

I'm encoding a japanese email subject and getting a failure. The subject is obtained from a form, then passed to a confirmation page and stored in a hidden form variable, then passed to a page that encodes the subject, then calls ns_sendmail to actually send the mail. Here is what I am doing to encode:

set subject [encoding convertto "iso2022-jp" 
 set student_mail_subject [ns_uuencode $subject]
set student_mail_subject "=?ISO-2022-
the error:
[14/Sep/2001:17:26:43][30459.2325509][-conn932-] Error: invalid 
string "^[(B=?ISO-2022-JP?B?^[(B=?ISO-2022-JP?
B?^[(B^[$@$8$c?=?=": must be less than 48 characters
invalid string "^[(B=?ISO-2022-JP?B?^[(B=?ISO-2022-JP?B?^[(B^
[$@$8$c?=?=": must be less than 48 characters
    while executing
"ns_uuencode $subject"
the error seems to be occuring at ns_uuencode. any ideas on why this error is occuring, and how to work around it?
Posted by good bye on
note, the linebreaks above were inflicted by the text box, and are
not in my source file.
Posted by Don Baccus on
ns_uuencode in AOLserver Tcl 8.x is broken.  Vinod Kurup has worked out a patch with Rob Mayoff which we'd hoped would be included in a future AOL3.3+ad14 patchset.  Unfortunately aD has no interest in AOLserver and keeps Rob very busy with other tasks, so apparently this
patchset isn't going to happen.

There have been some discussions among Vinod and "the gatekeepers" about whether or not we should bite the bullet and provide a download of AOL3.3+ad13+oacs1(+nsvhr?) for our user base but we've not decided.
There are benefits obviously but we also aren't terribly thrilled about further balkanization.

Vinod ran into this when working on acs-mail, since attachments must be uuencoded.  He fixed acs-mail to properly handle attachments (as inherited from aD it didn't) then ran into the ns_uuencode wall, decided to learn C and to some degree AOLserver internals, and figured
out how to fix it (with some help from Rob).

Vinod rocks :)

Posted by Henry Minsky on
As a quick workaround, there is a library file which I think ships in Openacs3.2.5 which contains Tcl routines to encode/decode base 64 which is lying around in the /tcl directory, it was used by the bulkmail package that Greg Haverkamp wrote at one point. This is non-optimal because it is written in Tcl and thus some orders of magnitude slower than a native C routine.
Posted by good bye on
Hi, my japanese subject encoding is still broken. I don't get any errors, just junk in the subject.

I am still using the method i described above, but have tried the following instead of ns_uuencode.

  • using bulkmail_base64_encode on the subject
  • using vinod's patch against aol33+ad13 and the new resulting ns_uuencode on the subject
i followed henry's other instructions in patching sendmail.tcl as described at

the baffling thing is that on a different machine, I can send japanese subjects just fine, and I DIDN'T use vinod's patch or the bulkmail_base64_encode.

In fact, i didn't even have to call ns_uuencode, or encoding convertto on the subject, it just works by passing it throug the form.

I tried doing this on my broken machine, but it doesn't work.

Then, I tried doing the bonehead thing and moved my aolserver directory (with compiled binaries) from the working machine to the broken machine. This still doesn't work. Both machines are running AOL33+ad13. Both have sendmail.tcl modified to send shiftjis. I'm totally confused as to why this works on one system and not the other. I guess for reference, the working machine is running SuSe and the non working machine is running RedHat. Anyone have any idea what else I should check?

6: Sendmail Sucks (response to 1)
Posted by good bye on
Ok. I looked at my two servers, and realized the japanese server was running the default sendmail SMTP listener. No matter how many patches I applied to AOLserver or whatever uuencoding procedure I used, my mailer was still wrecking the japanese encoded subject. My own personal machine, running the qmail SMTP listener, worked fine. So, I relayed through my box running qmail, and everything worked fine....even without encoding the subject in the manner henry describes in his page on sending japanese email linked from Thus, the problem is sendmail, not AOLserver.

lessons learned:

  1. sendmail sucks
  2. suntory boss "HG" blend canned coffee causes less of a caffiene hangover than the standard blend
  3. bill by the hour, not by the project