Hebrew & The mail() Function

Reply

Join Date: Apr 2005
Posts: 1
Reputation: guyshahaf is an unknown quantity at this point 
Solved Threads: 0
guyshahaf guyshahaf is offline Offline
Newbie Poster

Hebrew & The mail() Function

 
0
  #1
Apr 21st, 2005
i need to use a php script to recieve an email body text from flash and send that email to a fix address with a fix subject.

i was able to do so but i got stuck with 2 problems:

1. why does a multiline text data get sended as a single line one?

2. The body text alone is in Hebrew and Hebrew ONLY... the email keeps coming in 'Jibrish'.

What can be done about these 2??

P.s.

Here is the php script i use:
<?php
$name = 'Wedding';
$email = 'june9@lycos.co.uk';
$subject = 'Confirmation';
$message=utf8_decode($HTTP_POST_VARS['message']);
$toaddress='haba97@int.gov.il';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=ISO-8859-8' . "\r\n";

mail($toaddress,$subject,$message,"From: $name <$email>", $headers);

?>
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 348
Reputation: paradox814 is an unknown quantity at this point 
Solved Threads: 4
paradox814's Avatar
paradox814 paradox814 is offline Offline
Posting Whiz

Re: Hebrew & The mail() Function

 
0
  #2
Apr 21st, 2005
1. why does a multiline text data get sended as a single line one?
this is because you are sending your e-mail as a html document, you need to insert <br> to break the line, alternatively you could just send it as a plain text email to do that replace
Content-type: text/html;
with this instead:
Content-type: text/plain;

2. The body text alone is in Hebrew and Hebrew ONLY... the email keeps coming in 'Jibrish'.
the emails keep getting sent in Hebew because that is the character encoding you are sending them in. If you want regular latin then modify your last header from this:
charset=ISO-8859-8
to this:
charset=ISO-8859-1

so basically your last header line should look like this:
[php]$headers .="Content-type: text/plain; charset=ISO-8859-1\r\n"[/php]
charset=iso-8859-1

some other headers I would recommend adding are the following:
[php]$headers .= "From: ".$sender_name." <".$_POST['email'].">\r\n";
$headers .= "Reply-To: <".$sender_email.">\r\n";
$headers .= "Return-Path: <".$sender_email.">\r\n";[/php]

obviously there are other headers you could use, but it's always good to have a return path in case whomever you email decides to hit the reply button
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 1
Reputation: veetee is an unknown quantity at this point 
Solved Threads: 0
veetee veetee is offline Offline
Newbie Poster

Re: Hebrew & The mail() Function

 
0
  #3
Sep 21st, 2009
After many trials and errors I've managed to send a simple text Hebrew email using this code:
  1. $to = "somebody@mail.com";
  2. $from = "somebodyelse@email.com";
  3. $subject = "Sebject goes here";
  4. $message = "Message text in Hebrew here!";
  5.  
  6. $headers = "From: $from" . "\r\n";
  7. $headers .= "MIME-Version: 1.0" . "\r\n";
  8. $headers .= "Content-type: text/plain; charset=ISO-8859-1";
  9. mail($to, "Subject: $subject", $message, $headers);
  10. echo "Email sent!";

I don't know if this is important, but I've also used this meta tag in the HTML head:
  1. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Guess it won't hurt to have it up there.
Last edited by veetee; Sep 21st, 2009 at 11:58 am.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 4242 | Replies: 2
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC