Jump to content

UTF-8 Email Subject, Japanese Works, German Does Not


ahs10

Recommended Posts

i have the same script processing utf-8 characters from a mysql database and inserted into a form via an ajax request.  submitting the form via post, i use the php mail function to send an email with these characters.  this is done with several languages, the only one that does not work is the german emails subject line.  why would just german not work properly?

 

i would guess that the problem is going to be in the way i capture the characters from the form submission and mail them, so here's that part.  i don't understand how some utf-8 characters work and others don't so maybe this isn't the section you need to see to help, please let me know if not.  thanks!

$to = html_entity_decode($_POST['couponSendEmail_to']);
$from = html_entity_decode($_POST['couponSendEmail_from']);
$bcc = html_entity_decode($_POST['couponSendEmail_bcc']);
$subject = $_POST['couponSendEmail_subject'];
$message = html_entity_decode($_POST['couponSendEmail_message']);

$charset = 'UTF-8';
$encoded_subject = "=?$charset?B?" . base64_encode($subject) . "?=\n";
$headers = "From: " . $from . "\n"
	. "Bcc: " . $bcc . "\n"
	. "Content-Type: text/plain; charset=$charset; format=flowed\n"
	. "MIME-Version: 1.0\n"
	. "Content-Transfer-Encoding: 8bit\n"
	. "X-Mailer: PHP\n";
mail($to,$encoded_subject, $message,$headers);

 

 

Link to comment
Share on other sites

so after some further testing.  i think the problem is occurring when i fetch the data from my db.  i have the database encoded as utf8 and directly after i make a mysql connection, i have...

mysql_query("SET NAMES utf8");

 

like i said the japanese version works fine.  it is stored in the same table of the database, retrieved and mailed with the same script the german email is too.  furthermore, the german email body (also stored in the same table) works just fine... it's just the subject line.  please... anyone have any ideas?  thanks for your time.

 

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.