Jump to content

send mail with iso-8859-1


zoffmann

Recommended Posts

Hi,

 

I would like to make a form which collects information from the visitors of the site,

then this information is send to my email.

 

everything works, but the messages are sent as UTF-8 and I would like to send as iso-8859-1

 

I have the following piece of code in my sendmail.php file:

 

$mailsent = mail ($to, $subject,  $message);

 

My question is:

how to format variable $message as iso-8859-1 ?

 

Thanks in advance

:)

Link to comment
Share on other sites

What you need is to send some "custom" headers with your message - do something like this:

 

 

$to = "therecievers@email.com";
$subject = "the subject";
$message = "the message";

$headers  = 'MIME-Version: 1.0' . '\r\n';
$headers .= 'Content-type: text/html; charset=iso-8859-1' . '\r\n';
$headers .= 'From: TheSender <TheSenders@Email.com>' . '\r\n';	

$sendmail = mail($to,$subject,$message,$headers);

 

The header information 'From: ' is of course optional but it is nice to show who send the mail. The 'Content-type: ' is the piece of header information which tells what the content is, plain text / html and which charset/charencoding is used...

Link to comment
Share on other sites

I have tried on your way but I can't receive mail at all.

 

I have also tried like this:

 

mail( $to, $subject, "\r\n--deadbeef-for-dinner\r\n" .  "Content-Type: text/plain; " . "charset=\"iso-8859-1\"\r\n" . "Content-Transfer-Encoding: 7bit\r\n\r\n" . $message);

 

an I get the messages but they are not formated as  iso-8859-1 ???

 

 

And I didn't tell you I would like to send messages as plain text in iso-8859-1

Link to comment
Share on other sites

Then just use text/plain instead :)

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

 

 

But of course the text doesn't get formatted as iso-8859-1 just because you make a header which says it is so... Lets say you write this script:

 

$to = "your@email.com";
$subject = "Sending e-mails using php";
$message = "I'm trying to send a iso-8859-1 formatted/encoded e-mail but it just wont work";

$headers  = 'MIME-Version: 1.0' . '\r\n';
$headers .= 'Content-type: text/html; charset=iso-8859-1' . '\r\n';
$headers .= 'From: PHP Script <Go@PHP.net>' . '\r\n';	

$sendmail = mail($to,$subject,$message,$headers);

 

and then save it using UTF-8 the e-mail will of content will of course be formatted/encoded using UTF-8 and not iso-8859-1 as your header says. So you have to make sure that the text you are actually sending is formatted/encoded with iso-8859-1...

Link to comment
Share on other sites

I have two files:

 

the form.html (collecting information) is saved as UTF-8

and sendmail.php (sending information as email) is saved as UTF-8

 

If i don't use your piece of code

 

If I look in my "yahoo" mail account and change to UTF-8 in my browser then everything is all right.

 

If I look in my "webmaster mail" account: browser changes automatically to UTF-8 and letters are wrong anyway.

 

Now after some changes I have to send emails from the form to the "webmaster" account and I don't care which encoding to use only if it works in webmaster account:

 

What shall I do ? ???

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.