# Custom Email opt out Module

**URL:** <https://community.hubspot.com/t/custom-email-opt-out-module/85675>\
**Category:** CMS Development\
**Created:** [July 19, 2023, 4:51pm UTC](https://community.hubspot.com/t/custom-email-opt-out-module/85675 "2023-07-19T16:51:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![CD20623](https://avatars.discourse-cdn.com/v4/letter/c/13edae/32.png) [@CD20623](https://community.hubspot.com/u/CD20623)\
**Post date:** [July 19, 2023, 4:51pm UTC](https://community.hubspot.com/t/custom-email-opt-out-module/85675/1 "2023-07-19T16:51:25Z")

</div>

Hi -

I’m working on a module and having a little bit of difficulty putting it together. A third party email has an opt out link. It will be something like [XXX.com - XXX Sex Videos - Free Porn Movies](http://www.xxx.com/opt-out?email=xxxx@gmail.com).

I need to build a module that I can put on a page that will pull the email address out of the website url and submit it automatically via a form or something along the lines of this so that I can make a workflow that opts those people out of all emails.

Thank you

---

<div class="post-metadata">

**Author:** ![JasonWang](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jasonwang/32/93984_2.png) [@JasonWang](https://community.hubspot.com/u/JasonWang)\
**Post date:** [July 19, 2023, 8:04pm UTC](https://community.hubspot.com/t/custom-email-opt-out-module/85675/2 "2023-07-19T20:04:06Z")

</div>

Hi there

Firstly you should split the email address from the url using the simple javascript function and save it to a variable.

function getLastPart(url)

{

const parts = url.split(‘=’); return parts.at(-1);

}

After that, you can use the Hubspot FORM API to submit the Hubspot form automatically by javascript API with the email value assigned to form field

[https://legacydocs.hubspot.com/docs/methods/forms/advanced\_form\_options](https://legacydocs.hubspot.com/docs/methods/forms/advanced_form_options)

If you need further assistance, please contact me.

Regards
