user621162
user621162

Reputation:

How to add html codes in email?

I have created a script that sends email automatically! My mail message is included in the following variable

$message

But when i include a html code like or something else it is not shown properly in my mail!

Upvotes: 0

Views: 470

Answers (2)

Shaun Hare
Shaun Hare

Reputation: 3871

If you are using the mail command make sure you Are setting the right headers eg

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

  mail($to, $subject, $message, $headers);

Upvotes: 1

TNC
TNC

Reputation: 5386

You could do something like:

$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$subject = "Subject here";
$message = "email message here";

$sendMail = mail("[email protected]", "$subject", "$message", "$headers" );   

Upvotes: 2

Related Questions