문제

How can convert this mail to HTML

$message =' Hello ' . $row['first_name'] . ' ' . $row['last_name'] . '

Below is your login information:

Username: '.$row['username'].';
Password: '.$row['password'].';

We recommend changing your password once you have logged.

mail ($row[email], 'Login Information', $message, 'From: ' . $company . ' <' . $row['email'] . '>');
$sent = true;

To like this :

$message ='
<*html>
<*head>
<*title>HTML email<*/title>
<*/head>
<*body>
<*div>Hello ' . $row['first_name'] . ' ' . $row['last_name'] . '<*/div>
<*p>John<*/p>
<*img src="image.png" alt="" >
<*/body>
<*/html>
';
도움이 되었습니까?

해결책

Add Content-type:text/html;charset=UTF-8 to you header and remove * from html tags like this

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= "From: <****@example.com>' . "\r\n";
$headers .= "Cc: ****@example.com' . "\r\n";
$message ="
<html>
<head>
<title>HTML email</title>
</head>
<body>
<div>Hello " . $row['first_name'] . " " . $row['last_name'] . "</div>
<p>John</p>
<img src='image.png' alt='' >
</body>
</html>
";


mail("tomailid","subject",$message,$headers);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top