Skip to main content

Add Image to Email

In this guide, you will learn how to easily add an image to your email templates when using the Email Manager plugin for Kirby CMS.

Add the Image to the Template Folder

Upload your image to the template folder, for example:site/templates/email/contact-form/assets/your-logo.png.

  • site/templates/email
    • contact-form
      • assets
        • your-logo.png
      • mail.html.php
      • mail.text.php
      • reply.html.php
      • reply.text.php

Embed the Image in the Email Template

You can embed the image directly into the HTML of your email template using the base64_encode() function. Below is an example of how to include the image:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
    <img src="data:image/png;base64,<?= base64_encode(file_get_contents(__DIR__ . '/assets/your-logo.png')) ?>" alt="Logo">
</body>
</html>

This method will ensure that the image is displayed correctly when the email is received, without needing to rely on external image URLs.