Php mail - special character
You need to encode the topic title in whatever text encoding you use. See http://metacpan.org/pod/Encode::MIME::Header and http://www.faqs.org/rfcs/rfc2047.html which talk about this.
Essentially, your subject line should look like this:
Subject: Solicitud de =? UTF-8? Q? cotizaci = C3 = B3n? =
Then any MUA that knows about MIME should render the object correctly using the correct character set.
EDIT . It should be noted that RFC2822 specifies ASCII as the character encoding for mail headers, so quoting is necessary. He also specifies that lines should be no more than 72 characters, so folding may be required, and you should take this into account when creating messages to be processed in RFC (2) 822 mail systems. Finally, using the B encoding doesn't make much sense for the string as you put it, since the Q encoding takes up less space (in which case you just want to quote the mileage of words that actually use characters outside the ASCII character set).
Technically maybe just brute force with B encoding for the entire string, but generally this is a bad form due to wastefulness and it is much more likely that you will exceed the hard limit of 9999 characters in a single string as specified by RFC (2) 822 standards like this way if you have a long subject line.
a source to share
Hi! =) To encode an object, you must do this:
$subject = 'Solicitud de cotización';
// =?UTF-8?B?U29saWNpdHVkIGRlIGNvdGl6YWNpw7Nu?=
$subject = '=?UTF-8?B?' . base64_encode($subject) . '?=';
If you are using PHP 5.3+ you can use instead quoted_printable_encode()
:
$subject = 'Solicitud de cotización';
// =?UTF-8?Q?Solicitud de cotizaci=C3=B3n?=
$subject = '=?UTF-8?Q?' . quoted_printable_encode($subject) . '?=';
a source to share
I had the same problem as it works well for me now - this is to use the ( phpMailer ) class :
<?php
require_once('class.phpmailer.php');
$mail = new PHPMailer(); // defaults to using php "mail()"
// Here the code that allows special chars in subject and body
$mail->CharSet = 'UTF-8';
$mail->Encoding = 'quoted-printable';
// From and reply data
$mail->AddReplyTo('name@yourdomain.com', 'First Last');
$mail->SetFrom('name@yourdomain.com', 'First Last');
$mail->AddReplyTo('name@yourdomain.com', 'First Last');
// Receiver
$address = 'whoto@otherdomain.com';
$mail->AddAddress($address, 'John Doe');
// Message
$mail->Subject = 'PHPMailer Test Subject via mail(), basic';
$mail->Body = 'Message sent from website';
// Attachment(s)
$mail->AddAttachment('images/phpmailer.gif');
$mail->AddAttachment('images/phpmailer_mini.gif');
// Try to send mail
if( ! $mail->Send())
{
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
else
{
echo 'Message sent!';
}
?>
a source to share