Wed, May 25, 2022
https://devcodepro.comdevcodepro
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: 1109  / 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
<div itemscope itemtype="http://schema.org/Article"> <h4 class="black" itemprop="name">My Article Name</h4> <meta itemprop="headline" content="My Article Headline" /> <meta itemprop="image" content="http://www.example.com/myarticleimage.jpg" /> <time datetime="2018-05-21" itemprop="datePublished"></time> <div itemprop="description">My Description</div> <span itemtype="https://schema.org/Person" itemscope="itemscope" itemprop="author"> <span itemprop="name">Name</span> </span> <span itemtype="https://schema.org/Organization" itemscope="itemscope" itemprop="publisher"> <span itemprop="name">Website Articles</span> <span itemprop="logo" itemscope itemtype="https://schema.org/ImageObject"> <meta itemprop="url" content="http://www.example.com/images/logo.png" /> <meta itemprop="width" content="250" /> <meta itemprop="height" content="45" /> </span> </span> <span itemtype="https://schema.org/review" itemscope="itemscope" itemprop="review"> <span itemtype="https://schema.org/Rating" itemscope="itemscope" itemprop="reviewRating"> <span itemprop="ratingValue" content="4">4</span> out of 5 stars based on 1 votes </span> <span itemtype="https://schema.org/Person" itemscope="itemscope" itemprop="author"> <meta itemprop="name" content="Name" /> </span> </span> </div>
comments: 0 / hits: 1344
4 years ago, sat, jun 23, 18, 11:07:37
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} off RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] </IfModule>
comments: 1 / hits: 2379
3 years ago, sun, jan 20, 19, 8:37:34
<?php $string = '<?php /** * @author me * @copyright 2019 */ $foo = "Highlight String"; echo $foo; ?>'; echo '<pre style="line-height:18px;padding:5px;border:1px solid #aaa;max-width:600px;white-space:normal;background-color:#eff0f1;">'; highlight_string($string); echo '</pre>'; ?>
comments: 0 / hits: 979
PHP