1
Sending HTML Email With Image
<?php
if (isset($_POST['query'])) {
$email = $_POST['email'];
$message = $_POST['message'];
$body = '
<html>
<head>
<title>Email With Image</title>
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
</head>
<body>
<div style="margin:20px;padding:20px;font-size:16px;font-family:"Montserrat",sans-serif;border:2px solid #aaa;">
<h1 style="font-size:24px;font-weight:400;">Sending HTML Email With Image</h1>
<img src="https://www.google.ca/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" /><br />
' . $message . '<br />
</div>
</body>
';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= 'From: Example.com <[email protected]>' . "\r\n";
$subject = "HTML Mail";
$mail = mail($email, $subject, $body, $headers);
if (!$mail) {
echo "Mail was not successful";
} else {
echo "Message successfully sent.";
}
} else {
?>
<form action="index.php" method="post">
Email Address<br />
<input type="text" name="email" /><br /><br />
Message<br />
<textarea name="message"></textarea><br/><br />
<input type="submit" value="Submit" name="query" />
</form>
<?php } ?>
rated 1 times
(1)
(0)
comments: 0 / hits: 1109
/ 3 years ago, sun, jan 20, 19, 07:48:04
More From
» PHP
Comments
There are no comments for this Snippet yet