Skip to content Skip to sidebar Skip to footer

Creating A Html Mailto With Php

cannot use the mail function in php, will be creating a mailto link in html instead. (the kind you click on and it pops up a window) I have the body of the message saved under a va

Solution 1:

echo "<a href='mailto:" . $to . "?body=" . $body . "'>";

Solution 2:

$fixed_body = htmlspecialchars($body);
echo <<<EOL
<a href="mailto:$email?body=$fixed_body">Click here</a>
EOL;

htmlspecialchars will prevent any " in the email body from "breaking" the <a> tag. And the heredoc is just a nice little touch so you can use direct variable interpolation without having to escape the href attribute quotes.

Solution 3:

Try with this:

<ahref="mailto:<?phpecho$to; ?>?body=<?phpecho$body; ?>"><?phpecho$to; ?></a>

Will generate

<ahref="mailto:youremail@mail.com?body=This is the body of the message">youremail@mail.com</a>

Solution 4:

What you're looking for is (I've put spaces all over php tags for this editor to take all my characters and not interpret them):

< a href="mailto:< ? php echo $to; ? >?subject=< ? php echo $subject; ? >&cc=< ? php echo $cc; ? >&body=< ? php echo $body;? > " >

Solution 5:

<ahref='mailto:'<?phpecho$to?>'><?phpecho$body?></a>

Post a Comment for "Creating A Html Mailto With Php"