My code:
$to = '[email protected]';
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
$header = "From: [email protected]\r\n";
$header.= "MIME-Version: 1.0\r\n";
$header.= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$header.= "X-Priority: 1\r\n";
mail($to, $subject, $message, $header);
When i send a mail with special characters such as ®ð-˚©-ʼ“æ,˚ˍðß©
,
in the message, it works but spacing is no longer dealt with (every new line or space gets removed)
And the second problem is that the special characters are not displayed in the subject.
They just output like: øʼªʼ
Thanks in advance!
The best practice is to use one special character per email subject line. At most, use two. But if you remember back to our prior example — the one with the 1, 2, 3 special characters — that also broke the no-more-than-two rule.
Sending plain text email PHP makes use of mail() function to send an email. This function requires three mandatory arguments that specify the recipient's email address, the subject of the the message and the actual message additionally there are other two optional parameters.
PHP mail is the built in PHP function that is used to send emails from PHP scripts. The mail function accepts the following parameters: Email address. Subject. Message.
Content-Type: text/html
If you set this header that means you have to send HTML to the user. You can either decide to use something like TinyMCE to let the user write the message in a Word-style editor and use the HTML output from that. Or set your headers to plaintext.
Content-Type: text/plain
EDIT: Try this
$to = '[email protected]';
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
$header = "From: [email protected]\r\n";
$header.= "MIME-Version: 1.0\r\n";
$header.= "Content-Type: text/plain; charset=utf-8\r\n";
$header.= "X-Priority: 1\r\n";
mail($to, $subject, $message, $header);
I have used this header and this is worked for me...
$headers = '';
$headers = 'MIME-Version: 1.0'.PHP_EOL;
$headers .= 'Content-type: text/html; charset=iso-8859-1'.PHP_EOL;
$headers .= 'From: [email protected]<From: [email protected]>'.PHP_EOL;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With