简体   繁体   中英

PHP Mailgun wrong link in href

I'm sending an activation email to newly registered users on my page. The mail arrives like it should and everything but I have on problem.

The variable that is passed to the email template is used 2 times.

First time on the button that activates you account:

   <a style="padding: 10px 20px; background-color: #A3D900; color: #ffffff;" href="<?php echo $activate_url; ?>"><b><?php echo __('Activate') ?></b></a>

And the second time under the button in normal text:

<p style="color:#333;">
    <?php echo $activate_url; ?>
</p>

The link is properly added only the second time. The first on (the button href) links to the email itself (email.mydomain.com/....).

Why is this happening? How can I fix it?

There was a problem with mailgun. Mailgun was rewriting "hrefs" in my emails. I disabled the link-tracking and now it works fine. I don't really need link tracking, since I'm tracking the activation page already.

This isn't a "problem" with Mailgun, it is the intended behavior when you have "Click Tracking" turned on for a domain.

Mailgun only changes URLs in HREF attributes on HTML parts, but changes URLs found everywhere in plaintext parts. I recently used this to show a new url to my users, but track their click-throughs: please sign in and update your bookmark to our new web address <a href="http://this.will.be.rewritten.by.mailgun">http://this.will.NOT.be.rewritten.by.mailgun.org</a>

The HTTP-based API allows you to send additional parameters to override the default open and/or click tracking settings for individual emails:

o:tracking - Toggles tracking on a per-message basis, see Tracking Messages for details. Pass yes or no .

o:tracking-clicks - Toggles clicks tracking on a per-message basis. Has higher priority than domain-level setting. Pass yes , no or htmlonly .

o:tracking-opens - Toggles opens tracking on a per-message basis. Has higher priority than domain-level setting. Pass yes or no .

You can manage this using the Mailgun Control Panel by setting o:tracking-opens and/or o:tracking-clicks params to false. Also, changing the subdomain name can fix too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM