問題描述
當我使用 mailto 時,可以設定電子郵件的主題/內容嗎?
最佳解決方案
是的,看看 mailto 的所有提示和技巧:http://www.angelfire.com/dc/html-webmaster/mailto.htm
mailto 主題示例:
<a href="mailto:no-one@snai1mai1.com?subject=free%20chocolate">example</a>
mailto 與內容:
<a href="mailto:?subject=look%20at%20this%20website&body=Hi,I%20found%20this%20websiteand%20thought%20you%20might%20like%20it%20http://www.geocities.com/wowhtml/">tell a friend</a>
次佳解決方案
<a href="mailto:manish@simplygraphix.com?subject=Feedback%20for%20webdevelopersnotes.com&body=The%20Tips%20and%20Tricks%20section%20is%20great&cc=anotheremailaddress@anotherdomain.com&bcc=onemore@anotherdomain.com">Send me an email</a>
您可以使用此程式碼設定主題,正文,cc,bcc
第三種解決方案
您可以使用以下任意一種方法新增新增到 mailto 命令的主題。新增?將郵件傳送到 mailto 標籤。
<a href="mailto:test@example.com?subject=testing%20out%20mailto">First Example</a>
我們還可以透過將& body 新增到標籤的末尾,將訊息的正文新增到下面的示例中。
<a href="mailto:test@example.com?subject=testing%20out%20mailto&body=Just%20testing">Second Example</a>
除了身體之外,使用者還可以鍵入& cc 或&bcc 來填寫 CC 和 BCC 欄位。
<a href="mailto:test@example.com?subject=testing%20out%20mailto&body=Just%20testing&cc=test1@example.com&bcc=test1@example.com">Third
Example</a>
How to add subject to mailto tag
第四種方案
mailto:joe@company.com?subject=Your+subject
第五種方案
是:
使用 this 來實驗 mailto 表單元素和連結編碼。
您可以在表單中輸入主題,正文 (內容) 等,點選按鈕並檢視您可以貼上到頁面中的 mailto html 連結。
您甚至可以指定很少知道和使用的元素:cc,bcc,從電子郵件。
第六種方案
是的,你可以這樣:
mailto: email@host.com?subject=something
第七種方案
這裡是訣竅 http://neworganizing.com/content/blog/tip-prepopulate-mailto-links-with-subject-body-text
<a href="mailto:tips@neworganizing.com?subject=Your+tip+on+mailto+links&body=Thanks+for+this+tip">tell a friend</a>
第八種方案
mailto: URL 方案在 RFC 2368 中定義。此外,將資訊編碼為 URL 和 URI 的約定在 RFC 1738 中定義,然後在 RFC 3986 中定義。這些規定了如何將 body 和 subject 標頭包含到 URL(URI) 中:
mailto:infobot@example.com?subject=current-issue&body=send%20current-issue
具體來說,您必須將電子郵件地址,主題和正文放在 percent-encode 上,並將其放入上述格式。 Percent-encoded 文字適用於 HTML,但根據 HTML4 standard,該 URL 必須是實體編碼的,用於 href 屬性中:
<a href="mailto:infobot@example.com?subject=current-issue&body=send%20current-issue">Send email</a>
最普遍的是,這裡是一個簡單的 PHP 指令碼,可以按照上面的方式進行編碼。
<?php
$encodedTo = rawurlencode($message->to);
$encodedSubject = rawurlencode($message->subject);
$encodedBody = rawurlencode($message->body);
$uri = "mailto:$encodedTo&subject=$encodedSubject&body=$encodedBody";
$encodedUri = htmlspecialchars($uri);
echo "<a href="$encodedUri">Send email</a>";
?>
第九種方案
我把它分成幾行,使它更可讀。
<a href="mailto:johndoe@gmail.com%20%20%20%20?subject=My+great+email+to+you%20%20%20%20&body=This+is+an+awesome+email%20%20%20%20&cc=janedoe@gmail.com%20%20%20%20&bcc=billybob@yahoo.com">Click here to send email!</a>
參考文獻
注:本文內容整合自 Google/Baidu/Bing 輔助翻譯的英文資料結果。如果您對結果不滿意,可以加入我們改善翻譯效果:薇曉朵技術論壇。