How to enter line break into mailto body html link

You are writing a html mailto link and fill the body section but you don’t know how to enter line break ?
You need to read the RFC 2368. It tell that line breaks must be encoded using the %0D%0A sequence.

<a href="mailto:?subject=wordpress&body=First%20line%0D%0ASecond%20line" >send mail</a>

Yes, white spaces should also be replaced by %20.

Another way to do it is to use php function, plus, it will convert all your special characters

<?php
$body=" Bonjour,

Ceci est un test de mail avec caractères spéciaux";
$body = rawurlencode($body);
?>
<a href="mailto:?subject=Question concernant un message client&body=<?php echo $body; ?>" class="mail">Partager par mail</a>

Leave a Reply