Strange characters in PHP mail()

the mail() function

Moderators: macek, egami, gesf

ieaarva
New php-forum User
New php-forum User
Posts: 2
Joined: Thu Jan 19, 2012 3:27 am

Strange characters in PHP mail()

Postby ieaarva » Thu Jan 19, 2012 3:34 am

Hi!
This is my first posting here. I hope someone can offer some help with a problem I have:

I have a web page which submits a text to a php-script which uses the mail() function to send a mail. That's working just fine, with one exception: If I use the special Nordic characters in the mail text, it replaces them with some strange character combinations. I am really struggeling to figure out how to convert the text so it shows up right in the receiving mailbox.

Here is an example of a mail I have sent:
Navn : Iver Erling Ã…rva
Telefon : 90037541
Melding : This is a test of nordic special characters in php mail(). E.g. the letter Æ (or AE) and Ø (O with a slash). How do they look?

You see what I mean?

Thanks for any help!

Iver in Oslo

TheProdigyGuy
New php-forum User
New php-forum User
Posts: 215
Joined: Wed Dec 07, 2011 5:25 pm

Re: Strange characters in PHP mail()

Postby TheProdigyGuy » Thu Jan 19, 2012 1:48 pm

Hello Iver.
If i understand correctly it is UTF8 characters Yeah?

Then i think solution to specify additional headers properly:
In ex:

Code: Select all

$header= 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/plain; charset=UTF-8' . PHP_EOL;
$header.='Reply to: etc etc more stuff goes here' .PHP_EOL;

then:
@mail($to,$subject,$bodyofmail,$header);


After all this I think it should handle correctly that characters.

ieaarva
New php-forum User
New php-forum User
Posts: 2
Joined: Thu Jan 19, 2012 3:27 am

Re: Strange characters in PHP mail()

Postby ieaarva » Fri Jan 20, 2012 12:47 am

Thanks!

Now it works just fine.

I just cannot believe that I didn't try that. I have tried so many things including headers, but obviously not with characterset UTF-8.

Iver in Oslo :D


Return to “PHP coding => Mail”

Who is online

Users browsing this forum: No registered users and 3 guests