# Getting the encoded mail address from (email:...) without the anchor – possible?

**URL:** <https://forum.getkirby.com/t/getting-the-encoded-mail-address-from-email-without-the-anchor-possible/21291>\
**Category:** Questions\
**Tags:** v3\
**Created:** [February 20, 2021, 2:32pm UTC](https://forum.getkirby.com/t/getting-the-encoded-mail-address-from-email-without-the-anchor-possible/21291 "2021-02-20T14:32:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![exeldoc](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/exeldoc/32/6224_2.png) [@exeldoc](https://forum.getkirby.com/u/exeldoc)\
**Post date:** [February 20, 2021, 2:32pm UTC](https://forum.getkirby.com/t/getting-the-encoded-mail-address-from-email-without-the-anchor-possible/21291/1 "2021-02-20T14:32:41Z")

</div>

Hey there.  
First, here is an overview of my structure:

```
<a class="button someClass" href="mailto:hello@mail.com">
  <div class="someClass">
    <p class="button_text someClass"> <?= $support->support_button()->ktr() ?></p>
  </div>
  <div class="someClass button-shadow">
  </div>
</a>

```

It is supposed to be a button, that is basically a mailto: link.  
I love the (email:…) function automatically encoding the mail address, and would like to embed it into my structure. Is that possible?  
Right now it doesn’t work, because it builds a new anchor with the (email:…) function.:

```
<a class="button someClass" href="<?= $support->email_from_the_function()->ktr() ?>">
  <div class="someClass">
    <p class="button_text someClass"> <?= $support->support_button()->ktr() ?></p>
  </div>
  <div class="someClass button-shadow">
  </div>
</a>

```

**I guess the real question is, is there a way to get the email encoded in Kirby without getting the anchor as well?**

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [February 20, 2021, 2:45pm UTC](https://forum.getkirby.com/t/getting-the-encoded-mail-address-from-email-without-the-anchor-possible/21291/2 "2021-02-20T14:45:53Z")

</div>

> [@exeldoc](#):
>
> `support_button`

What is in the `support_button` field? and what is `ktr()`

Why don’t you just store the email address instead of an email kirbytag in the field?

And use `Str::encode()` to encode the email address.

---

<div class="post-metadata">

**Author:** ![ahmetbora](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/ahmetbora/32/11671_2.png) [@ahmetbora](https://forum.getkirby.com/u/ahmetbora)\
**Post date:** [February 20, 2021, 2:52pm UTC](https://forum.getkirby.com/t/getting-the-encoded-mail-address-from-email-without-the-anchor-possible/21291/3 "2021-02-20T14:52:59Z")

</div>

I use like that: `<?= $page->emailField()->encode() ?>`

```php
Kirby::plugin('my/plugin', [
    'fieldMethods' => [
        'encode' => function ($field) {
            return \Kirby\Toolkit\Str::encode($field->value);
        }
    ]
]);

```

---

<div class="post-metadata">

**Author:** ![exeldoc](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/exeldoc/32/6224_2.png) [@exeldoc](https://forum.getkirby.com/u/exeldoc)\
**Post date:** [February 20, 2021, 7:06pm UTC](https://forum.getkirby.com/t/getting-the-encoded-mail-address-from-email-without-the-anchor-possible/21291/4 "2021-02-20T19:06:29Z")

</div>

support\_button is in the .txt the (email:…) kirbytag.  
ktr() is kirbytext raw… guess not needed here at all.

Ah nice. Didn’t know the encode() option. This is what I needed  
thanks.
