Re: How do I encode Hebrew in PHP?

2007-03-10 Thread Dotan Cohen

On 07/03/07, Ira Abramov [EMAIL PROTECTED] wrote:

 You could get a voice line from HOT. It includes 2000 free minutes to
 BEZEQ numbers.

did they solve the problems of sending faxes over those voip lines?



Sorry for the late reply. I have hot VOIP service at home (nesher). I
can send and receive faxes. So it works.

Dotan Cohen

http://what-is-what.com/what_is/voip.html

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: How do I encode Hebrew in PHP?

2007-03-08 Thread Uri Even-Chen

  As for emails, I'm willing to bet that 99% of the emails that find their
  way to the M.K. do so on paper.

 I'd say more like 90%. there ARE a few tech-oriented MKs out there...


Most of the MKs have parliamentary assistants who read their E-mail
and pass it to them (probably on paper).  Some of them even bother to
reply.  If you are interested, here are examples:




-- Forwarded message --
From: עתניאל שנלר [EMAIL PROTECTED]
Date: Mar 8, 2007 10:07 AM
Subject: RE: אסירים פוליטיים ומנהליים
To: אורי אבן-חן [EMAIL PROTECTED]




אורי, שלום!
קיבלנו את פנייתך בעניין האסירים.
אעביר את מכתבך לעיונו של חכ שנלר.


בברכה,

חגית
עפ לחכ שנלר


חכ עתניאל שנלר
משרד: 02-6408383
פקס: 02-6496742



-Original Message-
From: אורי אבן-חן [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 08, 2007 3:49 AM
To: [EMAIL PROTECTED]
Subject: אסירים פוליטיים ומנהליים

שלום רב,

אני קורא לך לשחרר את כל האסירים הפוליטיים והמנהליים מבתי הכלא באופן
מיידי. כיום יש אלפי אסירים היושבים בבתי הכלא של מדינת ישראל, אך ורק
בגלל שהם ערבים. מדינת ישראל מפעילה מדיניות של אפליה גזענית בשטחים
שנמצאים בשליטתה. אני קורא לך לבטל את האפליה הגזעית במדינת ישראל, את
הרישום מיהו יהודי וזכויות היתר הניתנות ליהודים, ולהפוך את מדינת ישראל
למדינה שבה לכל תושב ואזרח יש זכויות שוות, בלי קשר למוצאו, דתו, מינו או
גזעו.

בברכה,
אורי אבן-חן.




-- Forwarded message --
From: רוחמה אברהם [EMAIL PROTECTED]
Date: Mar 8, 2007 12:07 PM
Subject: FW: אסירים פוליטיים ומנהליים
To: [EMAIL PROTECTED] [EMAIL PROTECTED]




אורי שלום רב,

אני מאשרת קבלת פנייתך לחכ רוחמה אברהם.

פנייתך תועבר לעיונה של חכ אברהם.

בברכה,

הילה אלון
עוזרת פרלמנטרית לחכ אברהם


-Original Message-


From: אורי אבן-חן [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 08, 2007 2:49 AM
To: [EMAIL PROTECTED]
Subject: אסירים פוליטיים ומנהליים

שלום רב,

אני קורא לך לשחרר את כל האסירים הפוליטיים והמנהליים מבתי הכלא באופן
מיידי. כיום יש אלפי אסירים היושבים בבתי הכלא של מדינת ישראל, אך ורק
בגלל שהם ערבים. מדינת ישראל מפעילה מדיניות של אפליה גזענית בשטחים
שנמצאים בשליטתה. אני קורא לך לבטל את האפליה הגזעית במדינת ישראל, את
הרישום מיהו יהודי וזכויות היתר הניתנות ליהודים, ולהפוך את מדינת ישראל
למדינה שבה לכל תושב ואזרח יש זכויות שוות, בלי קשר למוצאו, דתו, מינו או
גזעו.

בברכה,
אורי אבן-חן.


Re: How do I encode Hebrew in PHP?

2007-03-07 Thread Uri Even-Chen

Thanks for the information.  But I guess I need to connect HylaFAX to
a phone line such as bezek.  For each fax I will pay bezek a small
fee.  It's not worth it since I want to give a free service, and also
it will waste so much paper!  120 papers each time.  That's why I
prefer sending by E-mail, although I'm aware that there are more
chances they read their faxes and ignore E-mails (at least some of
them).

By the way, I checked some online fax services and they charge about
$0.10 per sent fax.  120 faxes will cost me $12.  It's far too
expensive.  E-mail is free!

Uri.

On 3/7/07, Geoffrey S. Mendelson [EMAIL PROTECTED] wrote:

On Wed, Mar 07, 2007 at 05:15:41AM +0200, Uri Even-Chen wrote:
 On 3/6/07, Geoffrey S. Mendelson [EMAIL PROTECTED] wrote:
 No, but you can send 120 single faxes using Hylfax.

 Where do I find more information about Hylfax?


Look it up with the correct spelling. I mistyped it, it's HYLAFAX.
Sorry.

It's a system that runs on a *NIX (it was first run on IRIX)  that
provides a full serivce FAX system. If you don't want to receive
faxes, you can use it as a send only system.


It has all sorts of features and a several contributed packages such as an
email to fax gateway, a printer que to fax driver, and several Windows
clients.

I use it under Linux with an Intel HAM clone modem, but you can use
almost any faxmodem you can get. The less intelligent the modem the
better.

For best results, IMHO, feed it ASCII text or postscript files. It
uses ghostscript to RIP the page images, so you can easily configure
it to print almost anything.

For example, you can send a fax by using the command:

   sendfax -d phone-number files

or without a generated cover page:

   sendfax -n -d phone-number files

files can be 1 or more files, and each file can be one or more pages.

With some clever programing, you can write a PERL or similar program
to generate a postsrcipt cover letter, complete with a customized name
and an image of your signature, a customized letter and then send them to
a fax. Combine it with a file of names, and you can send each MK, or
each contributor, member of your group, etc personalized letters.


If you are doing this not 100% open source, you could use an Access
database, WordBasic for the program and the Windows Hylafax client to
send them.

Geoff.

--
Geoffrey S. Mendelson, Jerusalem, Israel [EMAIL PROTECTED]  N3OWJ/4X1GM
IL Voice: (07)-7424-1667  Fax ONLY: 972-2-648-1443 U.S. Voice: 1-215-821-1838
Visit my 'blog at http://geoffstechno.livejournal.com/



=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: How do I encode Hebrew in PHP?

2007-03-07 Thread Geoffrey S. Mendelson
On Wed, Mar 07, 2007 at 12:39:06PM +0200, Uri Even-Chen wrote:
 Thanks for the information.  But I guess I need to connect HylaFAX to
 a phone line such as bezek.  For each fax I will pay bezek a small
 fee.  It's not worth it since I want to give a free service, and also
 it will waste so much paper!  120 papers each time.  That's why I
 prefer sending by E-mail, although I'm aware that there are more
 chances they read their faxes and ignore E-mails (at least some of
 them).
 
 By the way, I checked some online fax services and they charge about
 $0.10 per sent fax.  120 faxes will cost me $12.  It's far too
 expensive.  E-mail is free!


You could get a voice line from HOT. It includes 2000 free minutes to
BEZEQ numbers. 

As for emails, I'm willing to bet that 99% of the emails that find their
way to the M.K. do so on paper. 


Geoff.

-- 
Geoffrey S. Mendelson, Jerusalem, Israel [EMAIL PROTECTED]  N3OWJ/4X1GM
IL Voice: (07)-7424-1667  Fax ONLY: 972-2-648-1443 U.S. Voice: 1-215-821-1838 
Visit my 'blog at http://geoffstechno.livejournal.com/

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: How do I encode Hebrew in PHP?

2007-03-07 Thread Ira Abramov
Quoting Geoffrey S. Mendelson, from the post of Wed, 07 Mar:
  By the way, I checked some online fax services and they charge about
  $0.10 per sent fax.  120 faxes will cost me $12.  It's far too
  expensive.  E-mail is free!

indeed it is, that's why spam works!

 You could get a voice line from HOT. It includes 2000 free minutes to
 BEZEQ numbers. 

did they solve the problems of sending faxes over those voip lines?

 
 As for emails, I'm willing to bet that 99% of the emails that find their
 way to the M.K. do so on paper. 

I'd say more like 90%. there ARE a few tech-oriented MKs out there...

-- 
Ridiculously good-looking
Ira Abramov
http://ira.abramov.org/email/

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: How do I encode Hebrew in PHP?

2007-03-07 Thread Uri Even-Chen

On 3/7/07, Ira Abramov [EMAIL PROTECTED] wrote:

 As for emails, I'm willing to bet that 99% of the emails that find their
 way to the M.K. do so on paper.

I'd say more like 90%. there ARE a few tech-oriented MKs out there...


Indeed there are.

Uri.

-- Forwarded message --
From: רן כהן [EMAIL PROTECTED]
Date: Feb 4, 2007 1:54 PM
Subject: RE: ניסויים בבעלי-חיים
To: [EMAIL PROTECTED] [EMAIL PROTECTED]




לאורי אבן-חן שלום רב,

אני בהחלט מסכים עימך כי יש לקדם את עניין זכויות בעלי החיים בישראל וכי
יש למצוא פתרון מוסרי, כזה המקטין למינימום את השימוש בבעלי חיים למטרות
קוסמטיקה.

אני מצטער לשמוע על האישפוז הכפוי שלך ואני מאחל לך בריאות שלמה.
כל טוב,
רן כהן

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, January 24, 2007 9:02 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: ניסויים בבעלי-חיים

לכבוד
חכ רן כהן
שלום רב,

אני פונה אליך בבקשה להפסקת הניסויים בבעלי-חיים בכלל, וניסויים
בבעלי-חיים למטרות קוסמטיקה, חומרי ניקוי ופיתוח תרופות בפרט. כאדם
שמתנגד להתעללות בבעלי-חיים מכל סוג שהוא, צר שלי שבמדינת ישראל עדיין
מתבצעים ניסויים אכזריים ביותר בבעלי-חיים על בסיס קבוע. אני מאמין
שלבני-אדם אין זכות מוסרית וחוקית לבצע ניסויים בבעלי-חיים, מה שנוגד גם
חוקים קיימים האוסרים התעללות מכוונת בבעלי-חיים.

אני גם מבקש לשחרר אותי מבית החולים שלוותה, שם אני מאושפז בכפייה ונגד
רצוני כבר חודשיים וחצי (מאז ה-7 לנובמבר 2006), כאשר חומרים מזיקים
הוזרקו לגופי ונקשרתי למיטה מספר פעמים, לא ניתנה לי אפשרות לקום לעשות
את צרכיי, הושפלתי והוטרדתי מינית על-ידי הצוות הרפואי.

בברכה,
אורי אבן-חן (אדם חופשי).


__
Mordechai Vanunu is legally a Free Man (Adam Hofshi) He is illegally
arrested, his lawyer doesn't really represent him And the entire
supreme court of the state of israel is remaining silent about it.

http://www.speedy.net/prisoners/


Re: How do I encode Hebrew in PHP?

2007-03-06 Thread Uri Even-Chen

Thanks for the help.  Although RFC requires breaking long header
lines, and your code doesn't break long lines.  But besides that, it
works.

If you want to send mail to all your 120 Knesset members at once, here it is:
http://www.speedy.net/knesset/

Uri.

On 3/6/07, Meir Kriheli [EMAIL PROTECTED] wrote:

Uri Even-Chen wrote:
 Hi people,

 I'm trying to encode Hebrew in PHP, when sending automatic mail (using
 UTF-8).  I searched and found function mb_encode_mimeheader(), but it
 doesn't work.  It sends the mail, but the Hebrew becomes Jibrish.  I
 tried to do it using mb_encode_mimeheader().  Here is my mail sending
 code:

 ?php
  $tmp_addresses_clone= $tmp_addresses;

  $tmp_count= count($tmp_addresses_clone);
  while ($tmp_count  0)
  {
 $tmp_random= rand(0, $tmp_count - 1);

 // Open Mail Command.
 $tmp_mail_command= '/usr/sbin/sendmail -f ' . $tmp_email . '
 ' . $tmp_addresses_clone[$tmp_random] . '  /dev/null 21';

 $tmp_mail_file_pointer= popen($tmp_mail_command, w);
 if ($tmp_mail_file_pointer)
 {
// Print mail header.
fputs($tmp_mail_file_pointer, From:  .
 mb_encode_mimeheader('' . $tmp_name . '', 'UTF-8', 'B', \n) . ' '
 '' . $tmp_email . '' . \n);
fputs($tmp_mail_file_pointer, To:  .
 $tmp_addresses_clone[$tmp_random] . \n);
fputs($tmp_mail_file_pointer, Subject:  .
 mb_encode_mimeheader($tmp_subject, 'UTF-8', 'B', \n) . \n);
fputs($tmp_mail_file_pointer, MIME-Version: 1.0\n);
fputs($tmp_mail_file_pointer, Content-Type: text/plain;
 charset=UTF-8\n);
fputs($tmp_mail_file_pointer, \n);

// Print mail body.
fputs($tmp_mail_file_pointer, $tmp_content . \n);
fputs($tmp_mail_file_pointer, \n);

// Close file.
pclose($tmp_mail_file_pointer);
 }

 echo ($tmp_addresses_clone[$tmp_random] . 'br' . \n);
 $tmp_addresses_clone[$tmp_random]=
 $tmp_addresses_clone[$tmp_count - 1];
 unset($tmp_addresses_clone[$tmp_count - 1]);
 $tmp_count= count($tmp_addresses_clone);
  }
 ?

 How do I correctly encode Hebrew in PHP?

 By the way, the body of the message looks OK.

 I'm using PHP 4, I can't use PHP 5 functions such as iconv_mime_encode().


Usually what needs to be encoded are the headers. It's a simple format,
and base64 [1] for the content, something like:


=?encoding_name?B?bas64_encoded_content_blabla?=

The body itself can be left as utf-8 (specifying the content-type). You
can use the mail() function [2] to send it (configure the program
sending the mail in php.ini). Don't execute sendmail directly (prevents
code portability)


Here's a sample code which worked for me in many projects (php4 included):

$msubj==?utf-8?B? . base64_encode($subject) . ?=;
$mextra=From: =?utf-8?B?.base64_encode($from).?= .$email.\n;
$mextra.=Content-type: text/plain; charset=utf-8\n\n;

mail($to, $msubj, $mmsg, $utf8_message);


[1] http://il2.php.net/manual/en/function.base64-encode.php
[2] http://il2.php.net/manual/en/function.mail.php


Cheers
--
Meir Kriheli



=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: How do I encode Hebrew in PHP?

2007-03-06 Thread Shachar Shemesh
Uri Even-Chen wrote:
 If you want to send mail to all your 120 Knesset members at once, here
 it is:
 http://www.speedy.net/knesset/
Just so you know, a study conducted some time ago showed that the less
people were addressed in one go, the more likely you were the mails
would be read.
 Uri.
Shachar

-- 
Shachar Shemesh
Lingnu Open Source Consulting ltd.
Have you backed up today's work? http://www.lingnu.com/backup.html


=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: How do I encode Hebrew in PHP?

2007-03-06 Thread Uri Even-Chen

On 3/6/07, Shachar Shemesh [EMAIL PROTECTED] wrote:

Just so you know, a study conducted some time ago showed that the less
people were addressed in one go, the more likely you were the mails
would be read.


I know.  And therefore, each Knesset member receives a personal mail
where he is the only recipient.

The problem is, many of them don't read E-mail at all.  It's always
better to write them by fax.  But I can't send automatic faxes to 120
fax numbers at once.  Or can I?

Uri.

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: How do I encode Hebrew in PHP?

2007-03-06 Thread Maxim Veksler

On 3/6/07, Uri Even-Chen [EMAIL PROTECTED] wrote:

Thanks for the help.  Although RFC requires breaking long header
lines, and your code doesn't break long lines.  But besides that, it
works.

If you want to send mail to all your 120 Knesset members at once, here it is:
http://www.speedy.net/knesset/



I hope no one actually considers taking such a foolish act.



--
Cheers,
Maxim Veksler

Free as in Freedom - Do u GNU ?

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: How do I encode Hebrew in PHP?

2007-03-06 Thread Shachar Shemesh
Uri Even-Chen wrote:
  But I can't send automatic faxes to 120
 fax numbers at once.  Or can I?
If you have a fax modem, I really don't see why not.

Shachar

-- 
Shachar Shemesh
Lingnu Open Source Consulting ltd.
Have you backed up today's work? http://www.lingnu.com/backup.html


=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: How do I encode Hebrew in PHP?

2007-03-06 Thread Geoffrey S. Mendelson
On Tue, Mar 06, 2007 at 04:02:48PM +0200, Shachar Shemesh wrote:
 Just so you know, a study conducted some time ago showed that the less
 people were addressed in one go, the more likely you were the mails
 would be read.

I don't think it matters, 5 times zero is still zero. :-(

Geoff.

-- 
Geoffrey S. Mendelson, Jerusalem, Israel [EMAIL PROTECTED]  N3OWJ/4X1GM
IL Voice: (07)-7424-1667  Fax ONLY: 972-2-648-1443 U.S. Voice: 1-215-821-1838 
Visit my 'blog at http://geoffstechno.livejournal.com/

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: How do I encode Hebrew in PHP?

2007-03-06 Thread Geoffrey S. Mendelson
On Tue, Mar 06, 2007 at 04:10:54PM +0200, Uri Even-Chen wrote:
 
 The problem is, many of them don't read E-mail at all.  It's always
 better to write them by fax.  But I can't send automatic faxes to 120
 fax numbers at once.  Or can I?

No, but you can send 120 single faxes using Hylfax. Besides you don't
want to send the SAME fax to each person. You want to customize by
at least adressing it to them personally. 

A fax is also better because you can add a signature and make it look
like you wrote it, instead of SPAMING them. You may also want to
include a personalized cover page.

Geoff.
-- 
Geoffrey S. Mendelson, Jerusalem, Israel [EMAIL PROTECTED]  N3OWJ/4X1GM
IL Voice: (07)-7424-1667  Fax ONLY: 972-2-648-1443 U.S. Voice: 1-215-821-1838 
Visit my 'blog at http://geoffstechno.livejournal.com/

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: How do I encode Hebrew in PHP?

2007-03-06 Thread Uri Even-Chen

On 3/6/07, Geoffrey S. Mendelson [EMAIL PROTECTED] wrote:

On Tue, Mar 06, 2007 at 04:10:54PM +0200, Uri Even-Chen wrote:

 The problem is, many of them don't read E-mail at all.  It's always
 better to write them by fax.  But I can't send automatic faxes to 120
 fax numbers at once.  Or can I?

No, but you can send 120 single faxes using Hylfax. Besides you don't
want to send the SAME fax to each person. You want to customize by
at least adressing it to them personally.

A fax is also better because you can add a signature and make it look
like you wrote it, instead of SPAMING them. You may also want to
include a personalized cover page.


I think more chances are they will read faxes than E-mails.  But fax
is such a waste of paper.  And besides, by sending a fax I have to pay
bezek, and I think 120 faxes will cost me at least a few shekels.
Sending E-mail is free, and remember that I'm providing a free service
here.  I'm not charging anything for sending these 120 E-mails.

Uri.

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: How do I encode Hebrew in PHP?

2007-03-06 Thread Uri Even-Chen

On 3/6/07, Geoffrey S. Mendelson [EMAIL PROTECTED] wrote:

No, but you can send 120 single faxes using Hylfax.


Where do I find more information about Hylfax?

Uri.

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



How do I encode Hebrew in PHP?

2007-03-05 Thread Uri Even-Chen

Hi people,

I'm trying to encode Hebrew in PHP, when sending automatic mail (using
UTF-8).  I searched and found function mb_encode_mimeheader(), but it
doesn't work.  It sends the mail, but the Hebrew becomes Jibrish.  I
tried to do it using mb_encode_mimeheader().  Here is my mail sending
code:

?php
 $tmp_addresses_clone= $tmp_addresses;

 $tmp_count= count($tmp_addresses_clone);
 while ($tmp_count  0)
 {
$tmp_random= rand(0, $tmp_count - 1);

// Open Mail Command.
$tmp_mail_command= '/usr/sbin/sendmail -f ' . $tmp_email . '
' . $tmp_addresses_clone[$tmp_random] . '  /dev/null 21';

$tmp_mail_file_pointer= popen($tmp_mail_command, w);
if ($tmp_mail_file_pointer)
{
   // Print mail header.
   fputs($tmp_mail_file_pointer, From:  .
mb_encode_mimeheader('' . $tmp_name . '', 'UTF-8', 'B', \n) . ' '
'' . $tmp_email . '' . \n);
   fputs($tmp_mail_file_pointer, To:  .
$tmp_addresses_clone[$tmp_random] . \n);
   fputs($tmp_mail_file_pointer, Subject:  .
mb_encode_mimeheader($tmp_subject, 'UTF-8', 'B', \n) . \n);
   fputs($tmp_mail_file_pointer, MIME-Version: 1.0\n);
   fputs($tmp_mail_file_pointer, Content-Type: text/plain;
charset=UTF-8\n);
   fputs($tmp_mail_file_pointer, \n);

   // Print mail body.
   fputs($tmp_mail_file_pointer, $tmp_content . \n);
   fputs($tmp_mail_file_pointer, \n);

   // Close file.
   pclose($tmp_mail_file_pointer);
}

echo ($tmp_addresses_clone[$tmp_random] . 'br' . \n);
$tmp_addresses_clone[$tmp_random]=
$tmp_addresses_clone[$tmp_count - 1];
unset($tmp_addresses_clone[$tmp_count - 1]);
$tmp_count= count($tmp_addresses_clone);
 }
?

How do I correctly encode Hebrew in PHP?

By the way, the body of the message looks OK.

I'm using PHP 4, I can't use PHP 5 functions such as iconv_mime_encode().

Best Regards,
Uri Even-Chen
Speedy Net
www.speedy.net

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: How do I encode Hebrew in PHP?

2007-03-05 Thread Meir Kriheli
Uri Even-Chen wrote:
 Hi people,
 
 I'm trying to encode Hebrew in PHP, when sending automatic mail (using
 UTF-8).  I searched and found function mb_encode_mimeheader(), but it
 doesn't work.  It sends the mail, but the Hebrew becomes Jibrish.  I
 tried to do it using mb_encode_mimeheader().  Here is my mail sending
 code:
 
 ?php
  $tmp_addresses_clone= $tmp_addresses;
 
  $tmp_count= count($tmp_addresses_clone);
  while ($tmp_count  0)
  {
 $tmp_random= rand(0, $tmp_count - 1);
 
 // Open Mail Command.
 $tmp_mail_command= '/usr/sbin/sendmail -f ' . $tmp_email . '
 ' . $tmp_addresses_clone[$tmp_random] . '  /dev/null 21';
 
 $tmp_mail_file_pointer= popen($tmp_mail_command, w);
 if ($tmp_mail_file_pointer)
 {
// Print mail header.
fputs($tmp_mail_file_pointer, From:  .
 mb_encode_mimeheader('' . $tmp_name . '', 'UTF-8', 'B', \n) . ' '
 '' . $tmp_email . '' . \n);
fputs($tmp_mail_file_pointer, To:  .
 $tmp_addresses_clone[$tmp_random] . \n);
fputs($tmp_mail_file_pointer, Subject:  .
 mb_encode_mimeheader($tmp_subject, 'UTF-8', 'B', \n) . \n);
fputs($tmp_mail_file_pointer, MIME-Version: 1.0\n);
fputs($tmp_mail_file_pointer, Content-Type: text/plain;
 charset=UTF-8\n);
fputs($tmp_mail_file_pointer, \n);
 
// Print mail body.
fputs($tmp_mail_file_pointer, $tmp_content . \n);
fputs($tmp_mail_file_pointer, \n);
 
// Close file.
pclose($tmp_mail_file_pointer);
 }
 
 echo ($tmp_addresses_clone[$tmp_random] . 'br' . \n);
 $tmp_addresses_clone[$tmp_random]=
 $tmp_addresses_clone[$tmp_count - 1];
 unset($tmp_addresses_clone[$tmp_count - 1]);
 $tmp_count= count($tmp_addresses_clone);
  }
 ?
 
 How do I correctly encode Hebrew in PHP?
 
 By the way, the body of the message looks OK.
 
 I'm using PHP 4, I can't use PHP 5 functions such as iconv_mime_encode().


Usually what needs to be encoded are the headers. It's a simple format,
and base64 [1] for the content, something like:


=?encoding_name?B?bas64_encoded_content_blabla?=

The body itself can be left as utf-8 (specifying the content-type). You
can use the mail() function [2] to send it (configure the program
sending the mail in php.ini). Don't execute sendmail directly (prevents
code portability)


Here's a sample code which worked for me in many projects (php4 included):

$msubj==?utf-8?B? . base64_encode($subject) . ?=;
$mextra=From: =?utf-8?B?.base64_encode($from).?= .$email.\n;
$mextra.=Content-type: text/plain; charset=utf-8\n\n;

mail($to, $msubj, $mmsg, $utf8_message);


[1] http://il2.php.net/manual/en/function.base64-encode.php
[2] http://il2.php.net/manual/en/function.mail.php


Cheers
--
Meir Kriheli

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: How do I encode Hebrew in PHP?

2007-03-05 Thread Meir Kriheli
Sorry, forgot the extra headers to the mail function (below).

Uri Even-Chen wrote:
 Hi people,
 
 I'm trying to encode Hebrew in PHP, when sending automatic mail (using
 UTF-8).  I searched and found function mb_encode_mimeheader(), but it
 doesn't work.  It sends the mail, but the Hebrew becomes Jibrish.  I
 tried to do it using mb_encode_mimeheader().  Here is my mail sending
 code:
 
 ?php
  $tmp_addresses_clone= $tmp_addresses;
 
  $tmp_count= count($tmp_addresses_clone);
  while ($tmp_count  0)
  {
 $tmp_random= rand(0, $tmp_count - 1);
 
 // Open Mail Command.
 $tmp_mail_command= '/usr/sbin/sendmail -f ' . $tmp_email . '
 ' . $tmp_addresses_clone[$tmp_random] . '  /dev/null 21';
 
 $tmp_mail_file_pointer= popen($tmp_mail_command, w);
 if ($tmp_mail_file_pointer)
 {
// Print mail header.
fputs($tmp_mail_file_pointer, From:  .
 mb_encode_mimeheader('' . $tmp_name . '', 'UTF-8', 'B', \n) . ' '
 '' . $tmp_email . '' . \n);
fputs($tmp_mail_file_pointer, To:  .
 $tmp_addresses_clone[$tmp_random] . \n);
fputs($tmp_mail_file_pointer, Subject:  .
 mb_encode_mimeheader($tmp_subject, 'UTF-8', 'B', \n) . \n);
fputs($tmp_mail_file_pointer, MIME-Version: 1.0\n);
fputs($tmp_mail_file_pointer, Content-Type: text/plain;
 charset=UTF-8\n);
fputs($tmp_mail_file_pointer, \n);
 
// Print mail body.
fputs($tmp_mail_file_pointer, $tmp_content . \n);
fputs($tmp_mail_file_pointer, \n);
 
// Close file.
pclose($tmp_mail_file_pointer);
 }
 
 echo ($tmp_addresses_clone[$tmp_random] . 'br' . \n);
 $tmp_addresses_clone[$tmp_random]=
 $tmp_addresses_clone[$tmp_count - 1];
 unset($tmp_addresses_clone[$tmp_count - 1]);
 $tmp_count= count($tmp_addresses_clone);
  }
 ?
 
 How do I correctly encode Hebrew in PHP?
 
 By the way, the body of the message looks OK.
 
 I'm using PHP 4, I can't use PHP 5 functions such as iconv_mime_encode().
 

Usually what needs to be encoded are the headers. It's a simple format,
and base64 [1] for the content, something like:


=?encoding_name?B?bas64_encoded_content_blabla?=

The body itself can be left as utf-8 (specifying the content-type). You
can use the mail() function [2] to send it (configure the program
sending the mail in php.ini). Don't execute sendmail directly (prevents
code portability)


Here's a sample code which worked for me in many projects (php4 included):

$msubj==?utf-8?B? . base64_encode($subject) . ?=;
$mextra=From: =?utf-8?B? . base64_encode($from) . ?= .$email.\n;
$mextra.=Content-type: text/plain; charset=utf-8\n\n;

mail($to, $msubj, $message, $mextra);


[1] http://il2.php.net/manual/en/function.base64-encode.php
[2] http://il2.php.net/manual/en/function.mail.php


Cheers
--
Meir Kriheli

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]