Git Product home page Git Product logo

Comments (2)

temp1029 avatar temp1029 commented on July 26, 2024

So I think I figured out a way to make this work, but the caveat is you can't specify any subject line when using a template. This is fine for my use-case but other's mileage might vary. Allowing this might need a config setting or an extra header to be set. Ideally Laravel would allow for empty subject lines, but that's unlikely.

Since this package is specific to Laravel I figured some special code to handle a Laravel oddity was OK.

In summary we just need to override the 'send' and 'bulkSend' functions in the laravel-mailjet transport file. This just looks for the 'X-MJ-TemplateID' header and removes the subject line if it is found. After removing the subject line it allows processing to proceed as normal.

The entire file should look like this:

<?php

namespace Mailjet\LaravelMailjet\Transport;

use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport as BaseTransport;

use \Swift_Mime_SimpleMessage;

class MailjetTransport extends BaseTransport
{
    public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null)
    {
        if($message->getHeaders()->has('X-MJ-TemplateID'))
        {
            $message->setSubject(null);
        }

        return parent::send($message, $failedRecipients);
    }

    public function bulkSend(array $messages, &$failedRecipients = null)
    {
        foreach($messages as $message)
        {
            if($message->getHeaders()->has('X-MJ-TemplateID'))
            {
                $message->setSubject(null);
            }
        }

        return parent::bulkSend($messages, $failedRecipients);
    }
}

from laravel-mailjet.

oleksandr-mykhailenko avatar oleksandr-mykhailenko commented on July 26, 2024

Hello, we analyzed your solution. For now, it's too specific and we can't implement it as default, for all. But in the future, we will make an improvement to this area.
Thank you

from laravel-mailjet.

Related Issues (20)

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.