I have a web site which allows guests to make on line bookings for our B&B. The booking system sends us (and the guest) a 'plain text' e-mail. This has worked well for several years. I did not specify a charset in the e-mail headers.
The UK pound sign '£' seemed to display without difficulty (at least in the copies I received).
Recently I've updated the site. I read that one should specify a charset, to ensure characters are correctly displayed (particularly on machines using non-ASCII charsets). So for the headers for 'mail' I have:
$headers = "From: $sender" . "\\r\
" . "Reply-to: $sender" . "\\r\
" . "Content-Type: text/plain; charset='UTF-8'";
...and further down...
mail ($email, $subject, $message, $headers);
That works OK for the copies I receive from the web site when someone books. The '£' sign is correctly displayed.
At first I didn't have the single quotes around the charset itself, but I found that the '£' sign was either replaced by a black diamond with question mark inside (UTF-8) or preceded by an upper case 'A' with a small circle above it (ISO-8859-1). The single quotes took care of that and the e-mails rendered correctly when they arrived on my computer (using Thunderbird as my e-mail client).
Sorted, I thought, until I responded to a new booking (using 'Reply' in Thunderbird) and discovered that the e-mail that I was sending was blank. The culprit seems to be the single quotes. Thunderbird will send a message with "Content-Type: text/plain; charset=UTF-8" (no single quotes) as normal, but can't cope with "Content-Type: text/plain; charset='UTF-8'", and sends a blank message (although the subject line appears). Thunderbird seems to be using the charset of the incoming e-mail for the outgoing, rather than using a default. I don't know if it's possible to change that, I haven't yet found a way yet.
I've read a lot of stuff on the Internet, where I've found a fair bit of conflicting advice, but everyone seems to recommend specifying a charset.
This may not be directly a PHP problem, but since it starts with setting the headers in the 'mail' function, I thought I should start there too.
Can anyone suggest a solution, please ?