mailto link multiple body lines
You can use URL encoding to encode the newline as %0A
.
mailto:email@address.com?subject=test&body=type%20your%0Amessage%20here
While the above appears to work in many cases, user olibre points out that the RFC governing the mailto URI scheme specifies that %0D%0A
(carriage return + line feed) should be used instead of %0A
(line feed). See also: Newline Representations.
Line break in body of mailto: link
You cannot use HTML tags in body of mailto
According to RFC 2368, this is not possible:
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.
So any solution depends on HTML tags is not possible.
The solution I'm suggesting is to use \r\n along with PHP function rawurlencode
So here's the code
<?php
printf(
'<a class="simple-mail-link" href="mailto:x@y.com?subject=%s&body=%s"><div class="label"><div class="dashicons dashicons-admin-plugins"></div>Forward this to a friend</div></a>',
'My Subject',
rawurlencode(sprintf( "Hi there, this might be interesting for you.\r\nThis is the link: %s.\r\nHave a great day!\r\nStefaan", get_the_permalink()))
);
?>
Note: I tried the code with replacing get_the_permalink() with variable carrying http://example.com/test.php
references:
MailTo with HTML body
What is the equivalent of JavaScript's encodeURIcomponent in PHP?
Insert a line break in mailto body
I would suggest you try the html tag <br>
, in case your marketing application will recognize it.
I use %0D%0A
. This should work as long as the email is HTML formatted.
<a href="mailto:email@mycompany.com?subject=Subscribe&body=Lastame%20%3A%0D%0AFirstname%20%3A"><img alt="Subscribe" class="center" height="50" src="subscribe.png" style="width: 137px; height: 50px; color: #4da6f7; font-size: 20px; display: block;" width="137"></a>
You will likely want to take out the %20 before Firstname, otherwise you will have a space as the first character on the next line.
A note, when I tested this with your code, it worked (along with some extra spacing). Are you using a mail client that doesn't allow HTML formatting?
mailto link using computed property not loading full message body
You must URL-encode your data before assigning it to the HREF property of a hyperlink/anchor tag:
mailToString()
{
return "mailto:" + encodeURIComponent(this.formData.emailList) + "?subject=" + encodeURIComponent(this.formData.subject) + "&body=" + encodeURIComponent(this.emailContent);
},
Otherwise it might interfer with some reserved characters, e.g. ?
or =
or &
or some Unicode character.
Using various inputs of a form in mailto-body
That can't be done.
If you're going to process the data from the form you need a language other than css and html.
HTML & CSS are simple languages. They aren't able to process information, rather they are instructions which are processed by the browsers.
You will need some kind of traditional/scripting language if you're going to retrieve & work with the data from the web-form.
Mailto link that contains a link within the email body?
You just can't use HTML in the mailto:
function.
One other way to put a working link : use the PHP function mail()
and write your link in html.
Mailto: Body formatting
Use %0D%0A
for a line break in your body
- How to enter line break into mailto body command (by Christian Petters; 01 Apr 2008)
Example (Demo):
<a href="mailto:someone@example.com?subject=Suggestions&body=name:%0D%0Aemail:">test</a>
^^^^^^
anchor mailto multiple lines
Just add display:block
to the span tags:
.hello, .domain {
display:block;
}
Demo: http://jsfiddle.net/gGTEN/
It will copy/paste without the "line breaks".
Related Topics
Is Using <Li> Without Enclosing <Ul> Tags Dangerous
Image Width/Height as an Attribute or in CSS
Why Does a Filter Gradient on a Pseudo Element Not Work in IE8
How to Create a Polygon Shape Div
Why Are Dashes Preferred for CSS Selectors/HTML Attributes
How to Justify a Horizontal List
HTML <Input Type='File'> Apply a Filter
Is This HTML Structure Valid? Ul > Div > { Li, Li } , Div > { Li, Li } , Div > { Li, Li }
Add a Pipe Separator After Items in an Unordered List Unless That Item Is the Last on a Line
How to Bevel the Corner of a Block Div
Heading with Horizontal Line on Either Side
CSS Only Animate Draw Circle with Border-Radius and Transparent Background
Divs VS. Tables a Rebuttal Please
Do HTML Websockets Maintain an Open Connection for Each Client? Does This Scale