Thu, December 2, 2021
 
https://devcodepro.comdevcodepro
X
InterServer Web Hosting and VPS
Home · Latest · Trends
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: 1017  / 3 years ago, sun, jan 20, 19, 07:48:04
More From » PHP
 

Comments

There are no comments for this Snippet yet
Only authorized users can post. Please sign in first, or register a free account
Login with Google
 
Share
Posted
my3profile
Member since May 21, 2018
Total Code Snippets: 4
Total Comments: 1
Location: n/a
my3profile snippets
4 years ago, mon, may 21, 18, 4:27:10
comments: 0 / hits: 1249
4 years ago, sat, jun 23, 18, 11:07:37
comments: 1 / hits: 2198
3 years ago, sun, jan 20, 19, 8:37:34
comments: 0 / hits: 892
PHP