Giter VIP home page Giter VIP logo

swiftmailer-image-embed's Introduction

Swiftmailer Image Embed Plugin

Build Status Total Downloads Latest Stable Version

Swiftmailer plugin to automatically embed images into message by using CID (Content-ID).

See https://swiftmailer.symfony.com/docs/messages.html#embedding-inline-media-files for more informations.

Example:

<html>
    <head></head>
    <body>
        <p>some text</p>
        <img src="images/swiftmailer_rocks.png" alt="placeholder">
    </body>
</html>

With the plugin the following email will be generated:

<html>
    <head></head>
    <body>
        <p>some text</p>
        <img src="cid:[email protected]" alt="placeholder">
    </body>
</html>

Installation

composer require hexanet/swiftmailer-image-embed

Usage

use Hexanet\Swiftmailer\ImageEmbedPlugin;

$mailer = new Swift_Mailer($yourTransport);

$mailer->registerPlugin(new ImageEmbedPlugin());

or for symfony in your services.yaml:

Hexanet\Swiftmailer\ImageEmbedPlugin:
    arguments:
        - '%kernel.root_dir%/../web/'
    tags: [swiftmailer.default.plugin]

The arguments are optional.

Credits

Developed by Hexanet.

License

Swiftmailer Image Embed Plugin is licensed under the MIT license.

swiftmailer-image-embed's People

Contributors

kirkerafael avatar n3o77 avatar nclshart avatar notfloran avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

swiftmailer-image-embed's Issues

Condition doesn't work if message has an attachments

In file /src/ImageEmbedPlugin.php:21 there is an condition:
if ($message->getContentType() === 'text/html') { $message->setBody($this->embedImages($message)); }
But if message got an attachments, then returned content type will be multipart/mixed and plugin will not work

Better README

  • More explanation about the goal of this plugin
  • Add an example

Invalid src when base path is set and url are present in the email

Example I have the following email :

<img src="https://fdsea51.fr/myproject/images/logo.png" />

<img src="{{ asset('build/images/interface/ico_linkedin.png')) }}" />
{% endmjml %}

With base path configured:

    Hexanet\Swiftmailer\ImageEmbedPlugin:
        arguments:
            - '%kernel.project_dir%/public/'
        tags: [swiftmailer.default.plugin]

The plugin fails with:

Unable to open file for reading [/home/fbrutel/dev/mission/public/https://fdsea51.fr/myproject/images/logo.png]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.