Solved

Sending japanese email using PEAR

Posted on 2004-09-21
6
273 Views
Last Modified: 2006-11-17
Hi there,

I am using Pears htmlMimeMail class and trying to send mail using this class. For now I am just editing the defaults of the class, which are:

$this->build_params['html_encoding'] = 'quoted-printable';
$this->build_params['text_encoding'] = '7bit';
$this->build_params['html_charset']  = 'ISO-8859-1';
$this->build_params['text_charset']  = 'ISO-8859-1';
$this->build_params['head_charset']  = 'ISO-8859-1';
$this->build_params['text_wrap']     = 998;

I changed these to:

$this->build_params['html_encoding'] = 'quoted-printable';
$this->build_params['text_encoding'] = 'base64';
$this->build_params['html_charset']  = 'UTF-8';
$this->build_params['text_charset']  = 'UTF-8';
$this->build_params['head_charset']  = 'UTF-8';
$this->build_params['text_wrap']     = 998;

which I thought would work but it does not seem to. While those values appear in the header for the email fine, the email just contains entitites instead of japanese characters (when viewed in Outlook). This is the same as what happens when I do not change any of the values above.

The example piece of japanese I am using is simply どうしようどうしよう

Any suggestions on how to accomplish this or what could be going wrong? There is nothing wrong with the japanese data getting into the email, it comes from the database but japanese text input, and display is working perfectly; it is just emailing that is broken.

Thank you.
0
Comment
Question by:thepadders
  • 3
  • 2
6 Comments
 

Author Comment

by:thepadders
ID: 12110437
Oh well it seems that japanese became entities here as well, thats what I am seeing in outlook and that is exactly the problem.
0
 
LVL 27

Accepted Solution

by:
Diablo84 earned 250 total points
ID: 12128511
Two things that i am aware of, 1 is that Japanese mail uses the full 8 bits in a byte rather then 7 as is usual so you may want to try '8bt' transfer encoding.

The other is that in order for the mail client to correctly interpret the mail body content it must be able to recognise to content type so you could try sending the charset as 'iso-2022-jp' .
0
 
LVL 9

Assisted Solution

by:techtonik
techtonik earned 250 total points
ID: 12148520
Are you sure you do have your text encoded in UTF-8?
Maybe there's no correct font in your system?
I'd like to see an example of input and output data in binary form if possible.
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Author Comment

by:thepadders
ID: 12149663
Hi,

I actually had two problems, the first is if you have Japanese text submitted from an English webpage, then browsers covert it into HTML entities. These need converting back into UTF-8 for it to work in an email (unless you use an HTML email of course) so I am working on that.

The other one was about some functions that where affecting the string, that needed removing when I was actually using japanese text.
0
 
LVL 9

Expert Comment

by:techtonik
ID: 12154536
What if you set UTF-8 in meta-info for your page to avoid conversion to entities?

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
0
 

Author Comment

by:thepadders
ID: 12154553
I was considering that, but there are a number of problems with storing everything in utf-8, especially some email readers that can handle utf-8, and you can't convert utf-8 back if you don't know what the language was; or that is as far as I know. I would love to do it all in utf-8 but not sure if its possible.

This is interesting from phpworks

http://www.derickrethans.nl/files/wereldveroverend-phpworks04.pdf
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question