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);
$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);

?>

Recommended Answers

All 2 Replies

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:

$headers .="Content-type: text/plain; charset=ISO-8859-1\r\n"

charset=iso-8859-1

some other headers I would recommend adding are the following:

$headers .= "From: ".$sender_name." <".$_POST['email'].">\r\n";
$headers .= "Reply-To: <".$sender_email.">\r\n";
$headers .= "Return-Path: <".$sender_email.">\r\n";

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

After many trials and errors I've managed to send a simple text Hebrew email using this code:

$to = "somebody@mail.com";
$from = "somebodyelse@email.com";
$subject = "Sebject goes here";
$message = "Message text in Hebrew here!";

$headers = "From: $from" . "\r\n";
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/plain; charset=ISO-8859-1";
mail($to, "Subject: $subject", $message, $headers);
echo "Email sent!";

I don't know if this is important, but I've also used this meta tag in the HTML head:

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

Guess it won't hurt to have it up there.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.