1

This is my mailer's $header code.

I wanted to print the value of $em in from:<> but sadly it is not working.

i don't know PHP at expert level so kindly fix this problem, also I would like to know why this is happening.

$em="[email protected]";
// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From:  <$em>" . "\r\n";
echo $headers;

Current Output:


MIME-Version: 1.0 Content-type: text/html; charset=iso-8859-1 From: 

Expected Output:

MIME-Version: 1.0 Content-type: text/html; charset=iso-8859-1 From: <[email protected]>

1 Answer 1

3

as <> denotes a HTML tag your browser is hiding what it thinks is the broken HTML, if you view source you will see your string.

alternatively

echo htmlspecialchars($headers);
Sign up to request clarification or add additional context in comments.

1 Comment

$flag = mail($to, $subject, $message, $headers); can you please look over this code my mail is not working

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.