Search code examples
special-charactersmailto

Occurence of "?" leads to body being combined with the subject?


Occurence of "?" in the body content leads to body being combined with the subject and also content after "?" is truncated

<a href="mailto:[email protected]?Subject=Your Friend Wants to Share A Link&body=   <%=str%>">Email to a friend</a>

Solution

  • The last questionmark in an href is used to split query from path. You should url-encode your parameters. Since you seem to be using ruby, you can just use url_encode ( http://rdoc.info/stdlib/erb/1.8.7/ERB/Util:url_encode ).