Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I had no idea that you could use the mailto: URL for a form action.


Same. How would that work? What would be the end result (email body)?


It passes all form fields in URL encoded format in the body (example, name=Billy+Cravens&state=TX)


Sounds like a really bad UX

I think if my mom was trying to submit a form, and it opened her email client with a body consisting of URL encoded data she’d probably just close the email client thinking that something went wrong. Then she’d try again and the same thing would happen again. Then she might call me, and I’d probably tell her to just forget about it and try to call them on the phone instead or give up and try another company instead.


> with a body consisting of URL encoded data

The e-mail client decodes the URL encoded data. So you actually see plain text. The encoding is only done for the purpose of passing the data from the browser to the e-mail client.


I created a form with a dropdown and a some other inputs.

The result when using enctype=application/x-www-form-urlencoded and method=post in the form html is that the body that is shown in my email client is URL encoded.

They have a different enc type that you could use to specifically make it plain text. That one is not recommended because then you're gonna have a bad time parsing out the fields that were submitted from the form.


And for reference, here is what the mail body looks like with enctype=text/plain and method=post when it is opened in iCloud mail ready to send

    cat=services
    btext=adsfasdfsdafsdf afsdfas asd fa sdf as dfs
    subscribe-newsletter-weekly-yes=yes
Other email clients might create different looking body for text/plain enc type.


One variant that seemed interesting was method=get with enctype=application/x-www-form-urlencoded

In this case the values from the form get added as headers in the email so they are not directly visible to the user

I thought that I could still add user-visible subject and body by adding ?subject=foo&body=bar to the mailto: url

For example I could then have the subject say "Web form submission", and have the body of the mail contain a description that tells the user to send the email and that the data they filled into the form will be sent along with the email.

Even that is not great UX imo, but could still be interesting.

However from my testing with Brave web browser and Apple Mail, the subject and body are not filled in for the user in this case.


Looks like it can also be plaintext encoded[1], so something like:

    name=Billy%20Cravens
    state=TX
[1]: https://html.spec.whatwg.org/multipage/form-control-infrastr...


Email body is in the “body” form field, subject line in “subject”, destination in “email”.

https://www.w3docs.com/snippets/html/how-to-create-mailto-fo...


Those parameters need to be passed in the mailto: URL, not the form, if the FORM is a POST

mailto:example@gmail.com?subject=About+your+extended+warranty


You see that in the "email" forms of for example most "contact" sites. Like, for example, here on HN, in the right end of the site's footer (on desktop), by clicking "Contact" (but this isn't a form, just a "mailto:..." link).


this was something that was more commonly used in the late 90s/early/2000s, an early internet feature, but still works to this day.

there are some niceties that have been added or maybe they were always possible - you can add a subject and message body, possibly cc etc.

i used it just last year to make an easy contact form for contacting local municipalities from a single website for my wife's NP




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: