mailto command is adding + signs in the mail. |
mailto command is adding + signs in the mail. |
iliano10 |
Apr 22 2021, 04:34 AM
Post
#1
|
Group: Members Posts: 6 Joined: 22-April 21 Member No.: 27,906 |
I am very new and am kinda teaching myself how to code with HTML and such, after a long time of research i finally found a way to create 2 textarea's and allow people to write the subject and body of the mail themselves. after pressing the submit button it opens the mail client but it now shows + signs where spaces should be.
I am unable to find a way to fix this, anyone here know what to do, or is there an easier way of doing this? You can find the screenshots of the code, web, and the mail i receive below. All help is appreciated. thanks in advance This post has been edited by iliano10: Apr 22 2021, 04:35 AM |
pandy |
Apr 22 2021, 07:23 AM
Post
#2
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,716 Joined: 9-August 06 Member No.: 6 |
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. |
Christian J |
Apr 22 2021, 08:52 AM
Post
#3
|
. Group: WDG Moderators Posts: 9,630 Joined: 10-August 06 Member No.: 7 |
Also you may want to use a single-line INPUT element for the Subject field, rather than a multiline TEXTAREA.
|
iliano10 |
Apr 22 2021, 09:02 AM
Post
#4
|
Group: Members Posts: 6 Joined: 22-April 21 Member No.: 27,906 |
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. |
pandy |
Apr 22 2021, 09:08 AM
Post
#5
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,716 Joined: 9-August 06 Member No.: 6 |
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. |
iliano10 |
Apr 22 2021, 09:57 AM
Post
#6
|
Group: Members Posts: 6 Joined: 22-April 21 Member No.: 27,906 |
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. This post has been edited by iliano10: Apr 22 2021, 10:02 AM |
pandy |
Apr 22 2021, 10:08 AM
Post
#7
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,716 Joined: 9-August 06 Member No.: 6 |
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. |
pandy |
Apr 22 2021, 10:09 AM
Post
#8
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,716 Joined: 9-August 06 Member No.: 6 |
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> |
iliano10 |
Apr 22 2021, 10:55 AM
Post
#9
|
Group: Members Posts: 6 Joined: 22-April 21 Member No.: 27,906 |
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. This post has been edited by iliano10: Apr 22 2021, 10:57 AM |
Christian J |
Apr 22 2021, 01:40 PM
Post
#10
|
. Group: WDG Moderators Posts: 9,630 Joined: 10-August 06 Member No.: 7 |
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). |
pandy |
Apr 22 2021, 02:07 PM
Post
#11
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,716 Joined: 9-August 06 Member No.: 6 |
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. |
pandy |
Apr 22 2021, 02:21 PM
Post
#12
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,716 Joined: 9-August 06 Member No.: 6 |
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-v...767737(v=vs.85) Actually, so does every page I looked at when I googled mailto form. |
iliano10 |
Apr 22 2021, 03:46 PM
Post
#13
|
Group: Members Posts: 6 Joined: 22-April 21 Member No.: 27,906 |
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. |
pandy |
Apr 22 2021, 03:56 PM
Post
#14
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,716 Joined: 9-August 06 Member No.: 6 |
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. |
iliano10 |
Apr 23 2021, 03:13 AM
Post
#15
|
Group: Members Posts: 6 Joined: 22-April 21 Member No.: 27,906 |
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. |
pandy |
Apr 23 2021, 08:07 AM
Post
#16
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,716 Joined: 9-August 06 Member No.: 6 |
I think we learnt more from you, actually. So thank you!
|
Lo-Fi Version | Time is now: 28th March 2024 - 12:06 PM |