Printable Version of Topic
HTMLHelp Forums _ Markup (HTML, XHTML, XML) _ mailto command is adding + signs in the mail.
Posted by: pandy Apr 22 2021, 07:23 AM
You typically use POST with mailto, not GET.
Then you will get the name-value pairs without plus signs. In your case it will look like this.
CODE
subject=home page
body=this is a test
With POST the other features of mailto will work, for example if you want the subject line of the email pre-filled. That doesn't work with GET.
CODE
mailto:you@example.com?subject=this%20is%20the%20subject
I have to mention that mailto is totally unreliable, even more so today when many people don't even use an email client (it won't work with webmail). It's OK to play with to learn forms, but don't use it for anything important.
Posted by: Christian J Apr 22 2021, 08:52 AM
Also you may want to use a single-line INPUT element for the Subject field, rather than a multiline TEXTAREA.
Posted by: iliano10 Apr 22 2021, 09:02 AM
QUOTE(pandy @ Apr 22 2021, 02:23 PM)
You typically use POST with mailto, not GET.
Then you will get the name-value pairs without plus signs. In your case it will look like this.
CODE
subject=home page
body=this is a test
With POST the other features of mailto will work, for example if you want the subject line of the email pre-filled. That doesn't work with GET.
CODE
mailto:you@example.com?subject=this%20is%20the%20subject
I have to mention that mailto is totally unreliable, even more so today when many people don't even use an email client (it won't work with webmail). It's OK to play with to learn forms, but don't use it for anything important.
i get that i tried using "post" but when i do that it doesnt fill in at the defined subject or body it just puts this in the body:
subject=home page
body=this is a test
as for this: "mailto:you@example.com?subject=this%20is%20the%20subject" i dont want stuff to be pre-filled. I need to be able to fill in anything in subject or body and when you click submit a mail client has to open with everything filled in so you would just have to press "send" if you get what I mean.
i have achieved this so far appart from the + signs that keep appearing between the text. i need them gone but have no idea how to achieve this.
Posted by: pandy Apr 22 2021, 09:08 AM
This is how it works. Do you expect the subject the user types in to end up in the subject line in the email? That won't happen. Everything in the form fields end up in the body of the email. This is why the name and value pairs are essential. Without name you wouldn't know what's what.
Mailto is very limited. And, as said, very unreliable.
Posted by: iliano10 Apr 22 2021, 09:57 AM
QUOTE(pandy @ Apr 22 2021, 04:08 PM)
This is how it works. Do you expect the subject the user types in to end up in the subject line in the email? That won't happen. Everything in the form fields end up in the body of the email. This is why the name and value pairs are essential. Without name you wouldn't know what's what.
Mailto is very limited. And, as said, very unreliable.
but as you can see in the bottom screenshot "home page" is filled in in the subject and "this is a test" is filled in in the body. I already achieved this part just need the + symbols gone.
as you can see here the subject and body are already done.
Posted by: pandy Apr 22 2021, 10:08 AM
I didn't understand that was the subject line. You've cropped away all identifiers.
You are right. That form field really gets in the subject with GET. I've never heard of this before. Christian?
If you use GET you can get rid of the plus signs by URL encoding the spaces in the form. But you can't expect the user to do that, so you would need to come up with a solution programmatically.
CODE
this%20is%20a%20test
Do you understand that many people won't be able to use this form at all? It isn't worth putting too much effort into it for that reason.
Posted by: pandy Apr 22 2021, 10:09 AM
I'll be... CC works too.
Is this something new? Non standard? What?
Check this out, Christian.
CODE
<form method="get" enctype="text/plain" action="mailto:pandy@example.com">
Subject: <input type="text" name="subject"><br>
CC: <input type="text" name="cc"><br>
Message: <input type="textarea" name="body"><br>
<input type="submit">
</form>
Posted by: iliano10 Apr 22 2021, 10:55 AM
QUOTE(pandy @ Apr 22 2021, 05:09 PM)
I'll be... CC works too.
Is this something new? Non standard? What?
Check this out, Christian.
CODE
<form method="get" enctype="text/plain" action="mailto:pandy@example.com">
Subject: <input type="text" name="subject"><br>
CC: <input type="text" name="cc"><br>
Message: <input type="textarea" name="body"><br>
<input type="submit">
</form>
don't really have a clue if this is new, i was just trying stuff to make this work and this was the result. I understand i have put to much time into this
but i appreciate you guys having a look.
Posted by: Christian J Apr 22 2021, 01:40 PM
QUOTE(pandy @ Apr 22 2021, 05:09 PM)
I'll be... CC works too.
Is this something new? Non standard? What?
Where did you find that?
It seems really kludgy.
https://tools.ietf.org/html/rfc6068 uses the following syntax:
CODE
<mailto:joe@example.com?cc=bob@example.com&body=hello>
(no idea about browser support, or even if it's the latest RFC).
Posted by: pandy Apr 22 2021, 02:07 PM
I wrote it.
The OPs original form actually puts the text from the input with the name subject in the subject line of the email, but only if the method is GET. I didn't understand that to begin with, not until he pointed it out to me. So I thought if that works why wouldn't name="cc" also work, and it does.
There's some logic to it since with GET the data as sent as an URL, but it's crazy none of us knew about it. I've always thought GET is useless for mailto, that the email comes up empty. And it normally does. But obviously it works when the names of the form fields correspond to the desired email headers.
Posted by: pandy Apr 22 2021, 02:21 PM
BCC also works. Reply-to does not. Can't think of any more that's easy to check if they work or not.
Microsoft shows how to do it exactly like this.
https://docs.microsoft.com/en-us/previous-versions/aa767737(v=vs.85)
Actually, so does every page I looked at when I googled mailto form.
Posted by: iliano10 Apr 22 2021, 03:46 PM
This does work so why do the + symbols appear, do you have any idea?
now it is just about solving even though i might not use it cause i have found and stumbled on allot of people who have this same issue.
Posted by: pandy Apr 22 2021, 03:56 PM
Yes, THAT I know. When you use GET the data is sent as an URL and spaces aren't allowed in URLs. They are sometimes replaced by plus signs. Probably the browser does this. To avoid them you need to replace the spaces with %20 as I showed above.
Both Christian and I should have figured out that your way should work. Because the result of it all is the same as when we write a link with mailto. What's sent by your form is actually this.
CODE
mailto:abc@test.be?subject=home page&body=this is a test
With the spaces URL properly URL encoded...
CODE
mailto:abc@test.be?subject=home%20page&body=this%20is%20a%20test
Which could be plugged into a link just as it is. And we both knew THAT works.
Posted by: iliano10 Apr 23 2021, 03:13 AM
QUOTE(pandy @ Apr 22 2021, 10:56 PM)
Yes, THAT I know. When you use GET the data is sent as an URL and spaces aren't allowed in URLs. They are sometimes replaced by plus signs. Probably the browser does this. To avoid them you need to replace the spaces with %20 as I showed above.
Both Christian and I should have figured out that your way should work. Because the result of it all is the same as when we write a link with mailto. What's sent by your form is actually this.
CODE
mailto:abc@test.be?subject=home page&body=this is a test
With the spaces URL properly URL encoded...
CODE
mailto:abc@test.be?subject=home%20page&body=this%20is%20a%20test
Which could be plugged into a link just as it is. And we both knew THAT works.
Well thanks for all the fast replies and the help, i learned some stuff from you guys
Hope you all have a great day.
Posted by: pandy Apr 23 2021, 08:07 AM
I think we learnt more from you, actually. So thank you!
Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)