I'm making a mail function which could send some text with a picture, it works fine with plain text, but after adding the img code, what recipients got was still plain text. The image was located in the root directory.
Code below:
<form method="POST">
<input name="submit" type="submit" value="send!"/>
</form>
<?php
if(isset($_POST['submit'])){
$to="example@outlook.com";
// subject
$subject = 'test05';
// message
$message = "
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<img id='cat' width='208px' src='/cat.jpg'>
</table>
</body>
</html>
";
// 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";
// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'Reply-To: example@outlook.com' . "\r\n";
// $headers .= 'From: Panpan <general@panpan.tokyo>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
// mail($to, $subject, $message, $headers);
if (mail($to, $subject, $message, $headers)) {
// echo "Mail was sent! Great!";
echo $message;
}
else {
echo "Mission Failed";
}
}
?>