RamblingRoss
The blog of Ross Fruen, a .NET consultant

nms FormMail and Japanese characters

Recently Reev sent me a query about using nms FormMail to collect message containing Japanese characters.

The documentation for nms FormMail seems to suggest that you only need to change the $charset variable in the USER CONFIGURATION SECTION from 'iso-8859-1' to 'utf-8'.

Unfortunately this does not appear to be enough to allow email clients to correctly display emails generated by nms FormMail.

To get the Japanese characters to correctly display in the email client it is necessary to provide some hints on the encoding used. To achieve this the following headers need to be added to the email:

Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=utf-8

These can be added to the email by updating the sub routine** send_main_email_header**, changing the code from

...
$self->mailer->print(<<END);
X-Mailer: ${\( $self->name_and_version )}
To: $to
From: $from
Subject: $subject
END
...

to

...
$self->mailer->print(<<END);
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=utf-8
X-Mailer: ${\( $self->name_and_version )}
To: $to
From: $from
Subject: $subject
END
...

It is also necessary to ensure that the contact form capturing the data for nms FormMail is told to acept utf-8, for example...

...
<form action="formmail.pl" class="cssform" method="post" accept-charset='utf-8'>
...

Add a comment

If you want your comment to appear on this page please complete the form below. Your name and email address are optional, although the latter will be required if you want a response. Your email address will not appear against your comment and will only be used to correspond with yourself (where appropriate).

Thanks!

Thank you for submitting your comment, it will appear here after moderation is complete.

Sorry

There was a problem sending your comment, please try again.