简体   繁体   中英

full content for mail body cannot send using <a href='mailto:{$to}?subject={$subject}&body={$body}'>

i'm in trouble with passing multiple lines through mailto: link. in case of small content message body "mailto" link is clickable and also open window for Outlook default mail reader. But in case of large content message body ,the mailto link couldnt clickable and also in some case full body content cannot passed to mail box, it take only limited content size. how solve this issue in PHP and Drupal. can you suggest any other method for this.

my code is following:-

$to= "XXX@mail.com";
$subject = "XXX"
$body = str_replace( array( '\'', '&','amp;','<p>','</p>','nbsp'), ' ', $str_body);
$body = htmlspecialchars($body);

$page.="<div>";
$page.= "<a href='mailto:{$to}?subject={$subject}&body={$body}'>"; 
$page.="</div>";

Use urlencode() on the $subject, $body

$to= "XXX@mail.com";
$subject = urlencode("XXX");
$body = strip_tags($str_body); // use strip tags
$body = urlencode(htmlspecialchars($body));

The behavior of mailto link depends on the browser. There is no way you can influence it. Also you are at the mercy of the special configuration of the client computer : the browser passes the data in the link to the default email account of the default email software. This might work or not.

If you want to have control over the email sent, your page must POST the data on the server and you have to send it using PHP either using the mail() function or a mailer library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM