spatie / mailcoach-support

Questions and support for Mailcoach
https://mailcoach.app
31 stars 2 forks source link

Unsubscribe link truncated? #201

Closed ziming closed 4 years ago

ziming commented 4 years ago

So i have some error logs related to unsubscribed due to me trying to access $event->send->subscriber in my UnsubscribedListener. As send is null.

https://my-domain.censored/mailcoach/unsubscribe/ef02e66d-24d6-477c-8aec-0ed638c89866/ZGIzYzQwYT

The Email List part is the correct UUID. But the Send UUID is totally weird. Ends up the user unsubscribe from the email list, but because ZGIzYzQwYT does not match to any Send uuid, it's not linked to a campaign unsubscribe.

Any idea what could possibly cause this ZGIzYzQwYT? (Which doesn't even look like a uuid btw)

Thank you.

freekmurze commented 4 years ago

Mailcoach itself does not trim the links. I suggest you send a campaign to yourself, check in the email client if the link is correct.

Any tips on how to recreate this behaviour are welcome.

ziming commented 4 years ago

Hi @freekmurze

Sending the campaign to myself looks fine although I discovered a new bug.

In Helo during development, My unsubscribe link is a proper link with the word Unsubscribe

But in production. In my Web and desktop Outlook. The Unsubscribe link appears literally as:

[Unsubscribe](https://thelink.com)

The markdown is completely escaped. My email template view is a markdown view and all other parts of the email render correctly. So I am not sure why The unsubscribe link markdown is totally escaped.

Thank you

My email sending code looks like this

$htmlContent = (new CustomMarkdownMailable($item))->render();

$campaign = Campaign::create([
            'name' => "ABC",
            'subject' => "ABC",
            'html' => $htmlContent,
            'email_list_id' => $emailList->id,
        ])->segment(new CustomSegment($item))->send();

Hope it helps!

freekmurze commented 4 years ago

Which email provider do you use? Have you set up tracking op clicks / opens?

ziming commented 4 years ago

ses

I did not set up clicks so it should be the raw unsubscribe link

rubenvanassche commented 4 years ago

Hi @ziming a few questions:

Thanks!

ziming commented 4 years ago

Hi @rubenvanassche

Sorry for the late reply

The CustomMarkdownMailable is just this

/**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this
            ->markdown('emails.the-email-view');
    }

Here is how the code is like in the email view (the last few lines)

Should you have any feedback, please feel free to contact us at [support@myemail.com](mailto:support@myemail.com).

Thanks,<br>
{{ config('app.name') }}

<div style="text-align: center;"><small>[Unsubscribe](::unsubscribeUrl::)</small></div>
@endcomponent

When the email is sent out in production, all the markdown gets converted to HTML. Except the Unsubscribe link.

The unsubscribe link looks like this. It shows up like the raw markdown tags instead of being changed to proper link with the Unsubscribe word. See screenshot

https://share.getcloudapp.com/yAuYgzZJ

freekmurze commented 4 years ago

I've tried to reproduce this but wasn't able to. We also are not getting reports on this from other users. My guess it's caused by something specific to your setup.

Did you figure it out in the meantime?

ziming commented 4 years ago

No. Everything in that email blade file convert to markdown correctly except the unsubscribe link where ::unsubscribeUrl:: gets replaced with the actual unsubscribe url correctly, but the markdown didn't convert and change it to a proper link with the Unsubscribe word. Causing it to display as

[Unsubscribe](https://thelink.com) // as shown in the screenshot

I believe if my link in the brackets isn't ::unsubscribeUrl:: but an actual url, the markdown will convert fine. Or maybe it's the fact that my markdown tag are wrapped in html tags

<div style="text-align: center;"><small>[Unsubscribe](::unsubscribeUrl::)</small></div>

I will try to remove the div tag in my next email and see if it makes a difference. Although that would mean the unsubscribe link will not be centered.

ziming commented 4 years ago

Ok I did some extra testing so:

If it is

<div style="text-align: center;"><small>[Unsubscribe](::unsubscribeUrl::)</small></div>

The email will display it literally as [Unsubscribe](::unsubscribeUrl::)

But if it is just

[Unsubscribe](::unsubscribeUrl::)

The email will display a proper Unsubscribe link that is aligned to the left (since it is not centered).

llbbl commented 4 years ago

For me: The Spatie\Mailcoach\Support\Replacers aren't firing before it gets to SendMailJob or SendTestMailJob. Haven't figured it out yet. (I think my issue might be related to this)

rubenvanassche commented 4 years ago

Hi,

Sorry for the late response! Could you please try to update Mailcoach to the newest version? I'll guess this PR should fix the problem: https://github.com/spatie/laravel-mailcoach/pull/274

ziming commented 4 years ago

Hi @rubenvanassche , thanks for informing me.

I will test it on my next email campaign send and update this issue on the results.

riasvdv commented 4 years ago

Closing due to inactivity, let us know in a new issue or by reopening if you're still having problems.