Is there any way to include an HTML template for the mailto()
function body? E.g. I have the next link:
echo "<a href="mailto:[email protected]?subject=subject&body=the%20body>Send email</a>";
and I want to do something like this:
$template = "<h1>Some text</h1><p>More text<p><img src='imageurl' />";
echo "<a href="mailto:[email protected]?subject=subject&body=" . $template . ">Send email</a>";
Of course, the above code is putting the raw HTML into the body. So, how to give format to it? I've found a similar question here, but this is an old one, and the accepted answer doesn't let to give HTML format to the content.
Note: I know that it's not the best way to send mails, but it is just an option to let the user to change the content of the default body, and send it with its own mail account.
It is not possible to pass the HTML in email body while using mailto link. It takes only string/text value. It says, for line breaks, instead of using <br /> use %0D%0A .
subject=<subject> to the mailto tag. For example, the complete tag would look similar to the example below. You can also add body text by adding &body=body to the end of the tag, as shown in the example below. You can also include &cc= or &bcc= to fill out the CC and BCC fields.
For example, mailto:[email protected] . You can also: Specify multiple recipients in the To field, separating addresses with a comma (,) or a semicolon (;). For example: mailto:[email protected],[email protected].
Insert the email field into your signature template. Select the email field and click Add Hyperlink option. If the desired hyperlink if already present in the template, you can simply edit it.
What you want is not possible, you cannot put html tags into mailto body.
Answer from subject : MailTo with HTML body :
The special hname "body" indicates that the associated hvalue is the body of the message. The "body" hname should contain the content for the first text/plain body part of the message. The mailto URL is primarily intended for generation of short text messages that are actually the content of automatic processing (such as "subscribe" messages for mailing lists), not general MIME bodies.
mailto:[email protected]?body=this is the body
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