I'm trying to use the SendContactForm function from Aram's tutorial "Creating a simple contact form", and everything works fine except that special characters looks VERY special. Maybe they do get double encoded or something...
Here is the function:
//The function that handles our form submission
function SendContactForm($data, $form)
{
//Set data
$submission = new ContactFormSubmission();
$form->saveInto($submission);
$submission->write();
$mailto = $this->Mailto;
if($mailto == '') { $mailto = 'thomas@visionweb.no'; }
$From = $data['Email'];
$To = $this->Mailto;
$Subject = "Website Contact message";
//setting header values
$Header = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=UTF-8' . "\r\n" . 'Content-Transfer-Encoding: quoted-printable' . "\r\n";
$email = new Email($From, $To, $Subject, $Header);
//$email = new Email($From, $To, $Subject);
//set template
$email->setTemplate('ContactEmail');
//populate template
$email->populateTemplate($data);
//send mail
$email->send();
//return to submitted message
$this->redirect(Director::baseURL(). $this->URLSegment . "/?success=1");
}
I have tried different kind of encoding on the data array, but since it is an array it doesn't work and set the charset to UTF-8 in the header:
$Header = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=UTF-8' . "\r\n" . 'Content-Transfer-Encoding: quoted-printable' . "\r\n";
$email = new Email($From, $To, $Subject, $Header);
Is this a known problem when sending data posted in a form like this? Or is it just me? :)
This is how my characters look like: Ü å å
Anyway if anybody here have experienced similar behaviour, and found a solution to it. It would be great if you could share some of your experience.
PS! Using SS 3.0 (but that shouldn't be relevant to the problem, I suppose..)