944,081 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 5964
  • PHP RSS
Apr 21st, 2005
0

Hebrew & The mail() Function

Expand Post »
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);

?>
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
guyshahaf is offline Offline
1 posts
since Apr 2005
Apr 21st, 2005
0

Re: Hebrew & The mail() Function

Quote ...
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;

Quote ...
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
Reputation Points: 13
Solved Threads: 4
Posting Whiz
paradox814 is offline Offline
351 posts
since Oct 2004
Sep 21st, 2009
0

Re: Hebrew & The mail() Function

After many trials and errors I've managed to send a simple text Hebrew email using this code:
PHP Syntax (Toggle Plain Text)
  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:
PHP Syntax (Toggle Plain Text)
  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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
veetee is offline Offline
1 posts
since Sep 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Warning: Cannot modify header information
Next Thread in PHP Forum Timeline: PHP array_merge memory limit - Optimise function





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC