jdavidbakr / mail-tracker

Package for Laravel to inject tracking code into outgoing emails.
MIT License
567 stars 129 forks source link

Message sends as file (not as html) v.6.0.1 #168

Closed rommeA closed 2 years ago

rommeA commented 2 years ago

Thanks for the quik fix for v.6.0. I've upgraded to v.6.0.1 and i'm getting this bug when sending an email. image This file actually contains original HTML of the message. My code: Mail::to($email)->send(new NewLogin()); in NewLogin.php:

    public function build()
    {
        return $this->markdown('emails.login.new');
    }

I think there's smth wrong with setBody method here (MailTracker.php):

$message->setBody(new TextPart(
                            $this->addTrackers($original_html, $hash),
                            null,
                            $original_content->getMediaSubtype(),
                            null
                        )
                    );
rommeA commented 2 years ago

Yeah, clearly the problem is in calling the setBody method - I commented it and got correct email.

rommeA commented 2 years ago

upd: works fine with this:

$message->setBody(
                        new TextPart(
                            $this->addTrackers($original_html, $hash),
                            $message->getHtmlCharset(),
                            'html'
                        ));

original subtype was "alternative", but for proper work it needs to be changed to "html"...

jdavidbakr commented 2 years ago

Ok, seems that the issue is the structure of the messages is a bit more complicated than it was with SwiftMailer. I've made some more adjustments in 6.0.2 and extended the test case coverage. Please continue to report any issues in 6.0.x that come up as they are found.