Peace, I made a mail form and I want to enable The HTML in the Mail Message, How can I do it?... I wrote in the headers:
$headers='From:Management<[EMAIL="info@3malas.com>'"]>'[/EMAIL];

Dani AI

Generated

Good progress so far: was right to add the MIME and Content-Type headers to allow HTML bodies, and caught the parsing problem (a missing space after From: will break the header). Two remaining points explain the anonymous sender and the desire to use non‑Latin display names.

What mail clients show is a combination of the message From: header and the SMTP envelope sender (Return-Path). Many hosts or MTAs will rewrite the envelope or replace the visible sender if they do not accept arbitrary From addresses. To control the envelope sender from PHP use the mail() fifth parameter (the additional parameters) so the MTA sees the correct envelope address; see the PHP manual for details:

mail($to, $subject, $message, $headers, '-finfo@3malas.com');

If your provider prevents that, sending via authenticated SMTP (for example with PHPMailer) is the reliable alternative.

For non‑ASCII display names (other languages) you must encode the header per RFC 2047. In PHP the convenient helper is mb_encode_mimeheader(); build the display name, then put it in the From header and use a UTF-8 Content-Type. Example idea:

$display = mb_encode_mimeheader("3Malas Chat Management", "UTF-8");
$from = "$display <info@3malas.com>";

Also use CRLF (\r\n) for header line endings as required by the message format standard; inconsistent newlines can break header parsing (see RFC 5322). If the host still rewrites the sender, check mail logs or contact support, and consider SPF/DKIM and authenticated SMTP to avoid delivery rewrites and spam filtering.

References: PHP mail() manual, mb_encode_mimeheader(), RFC 5322 / RFC 2047.

Recommended Answers

All 13 Replies

try this:

<?php
$subject = "HTML Test";
$header = "MIME-Version: 1.0\n";
$header .= "Content-type: text/html; charset=iso-8859-1\n";
$header .= "From: CodeRewind <>\r\n";
$to = "";
$body = "";
$body = $body.'<b>Test HTML Mail</b>';

mail($to, $subject, $body, $header);
?>

I will must try it... Thanks.

Let me know.

It did not work, Another question why should I write \n and \r?

What is the error?

\n is for New line

In fact there is no error, It goes well but the Email doesn't send.
This is the Code:

$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=windows-1256\n";
$headers .="From:3Malas Chat Managment<[EMAIL="info@3malas.com>\n\r"]info@3malas.com>\n\r[/EMAIL]";
$Going="[EMAIL="info@3malas.com"]info@3malas.com[/EMAIL]"; 
$Subj="Hello";
$Msg="Bla bla bla bla..............";
mail($Going,$Subj,$Msg,$headers);

try sending the mail to a different email address.

Peace,
It tried it and it worked but The Sender Name was:
[email]anymous@(MYCPNAME).com[/email]
However I want the (From) Shows: 3Malas Chat Room Management <>
How can I do it?

So you replaced both the variable with [EMAIL="anymous@(MYCPNAME).com"]anymous@(MYCPNAME).com[/EMAIL] . The header and the going?

Peace, No I wrote the same code which you gave me, I didn't change the variables,
But when I send the message it comes like these:

From:
To:
Subject: HTML Test
Message: Bla Bla Bla...


How ever I want the (From): comes like this: Managment of the chat room .

Peace, No I wrote the same code which you gave me, I didn't change the variables,
But when I send the message it comes like these:

From:
To:
Subject: HTML Test
Message: Bla Bla Bla...


How ever I want the (From): comes like this: Managment of the chat room > How can I do it?

in the $header,make sure you have a space after From:

$headers="From:  Mycompany asdfa@asfa.com";

in the $header,make sure you have a space after From:

$headers="From: Mycompany asdfa

I did it... It works thanks, But Can I write the From Form in other language?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.