nliautaud / p01contact

Create contact forms by writing simple tags. Also a plugin for GetSimple and Pico CMS.
MIT License
16 stars 15 forks source link

UTF8 text inside subject and form field #4

Closed ilijaljubicic closed 6 years ago

ilijaljubicic commented 8 years ago

Hi,

I had greek chars not working in subject and form fields.

To make them work I had to patch send_mail() function with following:

$subject="=?utf-8?Q?".html_entity_decode($subject, ENT_COMPAT, 'UTF-8')."?=";

    $headers  = "From: ". html_entity_decode($name, ENT_COMPAT, 'UTF-8')."<$email>\r\n";
    $headers .= "Reply-To: ". html_entity_decode($name, ENT_COMPAT, 'UTF-8')." <$email>\r\n";
    $headers .= "Return-Path: ". html_entity_decode($name, ENT_COMPAT, 'UTF-8')." <$email>\r\n";

Could you please review this patch and if possible include it in next release so that we don't have to patch it ourselves after every update.

Thanks.

ilijaljubicic commented 8 years ago

ops....had small error, this is new version:

$subject=html_entity_decode($subject, ENT_COMPAT, 'UTF-8');

    $headers  = "From: ". html_entity_decode($name, ENT_COMPAT, 'UTF-8')."<$email>\r\n";
    $headers .= "Reply-To: ". html_entity_decode($name, ENT_COMPAT, 'UTF-8')." <$email>\r\n";
    $headers .= "Return-Path: ". html_entity_decode($name, ENT_COMPAT, 'UTF-8')." <$email>\r\n";
ilijaljubicic commented 8 years ago

in previous comment I sent header fields weren't working in Outlook while working in most other email clients. Subject worked in major email clients.

This version of code works in outlook as well, actually this one is creating Quoted Printable text for subject and header fields:

    $subject= mb_encode_mimeheader(html_entity_decode($subject, ENT_COMPAT, 'UTF-8'), 'UTF-8', 'Q');

        $headers  = "From: ". mb_encode_mimeheader(html_entity_decode($name, ENT_COMPAT, 'UTF-8'), 'UTF-8', 'Q') . " <$email>\r\n";
        $headers .= "Reply-To: ". mb_encode_mimeheader(html_entity_decode($name, ENT_COMPAT, 'UTF-8'), 'UTF-8', 'Q') . " <$email>\r\n";
        $headers .= "Return-Path: ". mb_encode_mimeheader(html_entity_decode($name, ENT_COMPAT, 'UTF-8'), 'UTF-8', 'Q') . " <$email>\r\n";