Ampersand(&) and Question Mark (?) in mailto’s subject/body

“mailto” is used for email link in website but when we pass “&” or “?” in subject or body parameter then it ignores data after tag.

Read about mailto : mailto : Create e-mail link in website

See below example.

<a href="”">Send email</a>

In above case, clicking on Send email link will open new mail window but it will show only “This is chetan, sabin ” in subject of mail as browser will consider & as parameter seperator.

To avoid this problem, you should use “%26” instead of “&”. You can use str_replace function for this in php.

Now, above example will be look like this which will work as you need.

<a href=” is chetan, sabin %26 sujeesh&body=body line comes here”>Send email</a>

For Question Mark “?”, you can use “%3F”.

For php, it would be good practice if you use urlencode function to encode subject and body text.

Chetan Patel

Chetan Patel is blogger, writes on Tech News, current trends, Gadgets Reviews, Website owner guide and Tips. You can connect him at Google+ & Facebook.