0

How can i add tag inside the email php ? for instance , i want to bold my $for_pass .Any idea ? thanks

$subject = "Password Recovery";
$message = "Hi! Your member password is <strong>$for_pass</strong>";
$from = "[email protected]";
$headers = "From:" . $from;
 // send mail
$mail_sent = @mail( $forgot_email, $subject, $message,$headers );
 //echo "Thank you for sending us feedback";

?>
<script>

alert("Your password has been sent to your email address. ");

</script>
<?php
1
  • so what output you get for <strong> ?? Is your text appearing bold or not ?? Commented May 8, 2014 at 11:22

2 Answers 2

3

You need send MIME headers in your mail to tell its HTML, as follows:

$headers = "From:" . $from . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

$mail_sent = @mail($forgot_email, $subject, $message, $headers);
Sign up to request clarification or add additional context in comments.

7 Comments

You won't be using the suppress (@) in production though, right?
thanks you so much . I want to ask you another question is if i put background image does it must be a link or set the background url as usual ?
You can set the background url as the full path of the image: <div style="background: url('http://example.com/path/to/image.png');">...</div>
able to put like this ? <div style="background: url('images/image.png');">...</div>
No. I don't think so. You need the absolute path to the image.
|
1

As you have it in the mail body but you need to declare content type on header

  ...
  $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
  $headers .= "From:" . $from;

the message body can have any inline styling you wish.

Comments

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.