Posts Tagged ‘mailto’

How to add line break in body for mailto

Posted: August 13, 2015 in HTML, PHP
Tags:

// PHP code

$email = 'myemail.domain.com';
$subject = addslashes("This is Subject: Let's check it...!!!");
$body = addslashes("This is message area. \r\n My Second line...Let's check it...!!!"); // body comes from text area so will have \r and \n
$body = str_replace(array("\r\n","\r","\n"),'%0D%0A',trim($body));

// HTML Code



<a onclick="mailto:<?=$email;?>?subject=<?=$subject;?>&body=<?=$body;?>" >Click here to email me</a>