mailto的主体断点:link [英] Line break in body of mailto: link
问题描述
我想创建一个转发给朋友链接下面的博客文章,打开我的电子邮件客户端准备的消息。我可以让它工作一个单行消息,但我想要能够打破邮件正文内的行。我该怎么做?
<?php
printf(
'< a href = mailto:?subject =%s& body =%s>将其转发给朋友< / a>',
the_title_attribute('echo = 0'),
sprintf('链接: %s有一个美好的一天!Stefaan',get_the_permalink())
);
?>
如何在上一行空行的新行上开始有一个美好的一天!
链接:...
有一个美好的一天! p>
Stefaan
我的博客使用WordPress与Genesis主题,我把我的代码进入启用PHP的 genesis_footer_entry
钩子(请参阅屏幕截图 - 电子邮件文本是荷兰语)
您不能在 正文中使用HTML标签 mailto
根据 RFC 2368 ,这是不可能的:
特殊的hnamebody表示相关联的hval是消息的
正文。 bodyhname应该包含消息的第一个文本/纯文本部分
的内容。 mailto URL是
,主要用于生成
的短文本,实际上是自动处理的内容(例如订阅
邮件列表的邮件),而不是一般的MIME主体。 / p>
所以任何解决方案都取决于HTML标签是不可能的。
我建议的解决方案是使用 \r\\\
以及PHP函数 rawurlencode
所以这里是代码
<?php
printf(
'< a class =simple-mail-linkhref =mailto:x@y.com?subject =%s& body =%s>< ; div class =label>< div class =dashicons dashicons-admin-plugins>< / div>将其转发给朋友< / div>< / a>',
'我的主题',
rawurlencode(sprintf(你好,这可能是有趣的你.\r\\\
这是链接:%s.\r\\\
nave伟大的一天!\r\\ \\ nStefaan,get_the_permalink()))
);
?>
注意:我尝试使用替换 get_the_permalink() http://example.com/test.php
参考:
PHP中的JavaScript的encodeURIcomponent相当于什么?
I want to create a "Forward this to a friend" link below a blog post that opens my email client with a prepared message. I can get it to work for a single-line message, but I’d like to be able to break lines inside the message body. How can I do that?
<?php
printf(
'<a href="mailto:?subject=%s&body=%s">Forward this to a friend</a>',
the_title_attribute('echo=0'),
sprintf('The link: %s Have a great day! Stefaan', get_the_permalink())
);
?>
How do I start "Have a great day!" on a new line with an empty line above?
The link: ...
Have a great day!
Stefaan
My blog uses WordPress with a Genesis theme and I put my code into the genesis_footer_entry
hook with PHP enabled (see screenshot – email text is in Dutch).
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:
What is the equivalent of JavaScript's encodeURIcomponent in PHP?
这篇关于mailto的主体断点:link的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!