I am attempting to create a mailto link which populates the body of the email with the current URL. The problem I am having, is that the gmail android app strips out equals signs, including %3D
Here is the code I am using.
$currentUrl = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
$currentUrl = str_replace('&', '%26', $currentUrl);
$currentUrl = str_replace('=', '%3D', $currentUrl);
<a href='mailto:?subject=".$emailsubject."&body=".$currentUrl."' class='actions'>Click to Send</a>
Example Href
<a href='mailto:?subject=12/12/2019 2L36 Brighton to Lewes&body=https://live.rail-record.co.uk/train/?c%3DW26711%26d%3D12/12/2019' class='actions'>Create Email</a>
On desktop, it works fine. On mobile, the query strings get cut off and the equals signs do not get included in the email body.
Would anyone be able to assist please, as to how to get the equals into gmail app? Thanks.
An example of the mailto body would contain a link like this: https://live.rail-record.co.uk/train/?c=H17216&d=11/12/2019 The URL inserted into the email body however, is cut off after ?c - the first equals sign. Works fine in desktop mail apps but doesnt work on gmail android. Regarding the above link, there is a bit at the bottom that says "Create Email" you can click that to test it.
In Android URL encoding is not enough, you need to double encode the URL and it will work fine (tied it out myself).
Here you can see how to do it in js: How to double encodeURIComponent in javascript?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With