The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> mailto command is adding + signs in the mail.
iliano10
post 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.

Attached Image
Attached Image
Attached Image


All help is appreciated. thanks in advance smile.gif

This post has been edited by iliano10: Apr 22 2021, 04:35 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post 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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post 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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
iliano10
post Apr 22 2021, 09:02 AM
Post #4





Group: Members
Posts: 6
Joined: 22-April 21
Member No.: 27,906



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post 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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
iliano10
post Apr 22 2021, 09:57 AM
Post #6





Group: Members
Posts: 6
Joined: 22-April 21
Member No.: 27,906



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.
Attached Image

This post has been edited by iliano10: Apr 22 2021, 10:02 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post 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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post 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. wacko.gif

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>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
iliano10
post Apr 22 2021, 10:55 AM
Post #9





Group: Members
Posts: 6
Joined: 22-April 21
Member No.: 27,906



QUOTE(pandy @ Apr 22 2021, 05:09 PM) *

I'll be... CC works too. wacko.gif

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 tongue.gif but i appreciate you guys having a look.

This post has been edited by iliano10: Apr 22 2021, 10:57 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Apr 22 2021, 01:40 PM
Post #10


.
********

Group: WDG Moderators
Posts: 9,630
Joined: 10-August 06
Member No.: 7



QUOTE(pandy @ Apr 22 2021, 05:09 PM) *

I'll be... CC works too. wacko.gif

Is this something new? Non standard? What?

Where did you find that? wacko.gif 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).
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post 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. rolleyes.gif cool.gif

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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post 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. wacko.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
iliano10
post 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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post 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.


User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
iliano10
post Apr 23 2021, 03:13 AM
Post #15





Group: Members
Posts: 6
Joined: 22-April 21
Member No.: 27,906



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 smile.gif
Hope you all have a great day.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post 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! smile.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 28th March 2024 - 12:06 PM