Wed, November 13, 2019, 21:21:55
 
Home · Latest · Trends  /  PHP
1

Sending HTML Email With Image

rated 1 times [  1] [ 0]  / comments: 0 / hits: 301  / 11 months ago, sun, jan 20, 2019, 19:48:04
<?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 <noreply@example.com>' . "\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 } ?>
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
 
Share
Snippets
2 years ago, mon, may 21, 2018
1 year ago, sat, jun 23, 2018
11 months ago, sun, jan 20, 2019
Posted
my3profile

my3profile

Member since May 21, 2018
Total Code Snippets: 4
Total Comments: 1
Location: n/a
Following
User not following anyone yet.