mailto 进入mailto 进入mailto

问题描述 投票:0回答:1

我正在努力开发一个基于联系表单的简单任务/工作流程系统。

我唯一想做的就是通过“接受”按钮向预定义的收件人发送电子邮件,并自动链接到新电子邮件。到目前为止,这有效,但现在发送的电子邮件还应该包含此按钮以及链接的 mailto 并转到另一个预定义的发件人。整个事情应该可以重复两到三次。换句话说,应该从电子邮件生成一封电子邮件,然后再生成另一封电子邮件。一连串的电子邮件。不幸的是,问题是即使第二个 mailto 链接也会破坏整个过程。附有图像和代码。整个系统应该充当非营利组织的轻量级任务系统/审批系统。

html 内有一些来自在线表单的短代码 { } 和内容。

有人知道我该如何解决这个问题吗?或者知道我可以使用哪个工具来做到这一点?

<a href="mailto:[email protected]?subject=Best%C3%A4tigung%20Ehrung%3A%20f%C3%BCr%20{element|id:17|Vorname des zu...enden Mitglieds}%20{element|id:18|Nachname des z...enden Mitglieds}%20{element|id:20|Auswahl des Verdienstorden}
&body=Sehr%20geehrter%20Herr%20Pr%C3%A4sident%2C%20%20%0A%20%0A%20%20%0Ahiermit%20bitte%20ich%20um%20Freigabe%20der%20Ehrung.%20Ich%20habe%20die%20Voraussetzungen%20nach%20meinen%20Mitteln%20gepr%C3%BCft%20und%20Best%C3%A4tige%20diese.%20%20%20%0A%20%0A%20%0AAnbei%20die%20Daten%20zur%20Ehrung%3A%20%20%0A%20%0A%20%0AMitgliedsnummerverein%3A%20{element|id:3|Mitgliedsnummer}  %20%0ABezirk%3A%20{element|id:43|Bezirk} %20%0AName%20des%20Vereins%3A%20{element|id:4|Name des Vereins%20%20%0AE-Mail-Antragsteller%3A%20%20%20%20%0AName%20Antragsteller%3A%20{element|id:5|Vorname Antragsteller}%20{element|id:6|Nachname Antragsteller}  %20%0ATelefon%20Antragsteller%3A%20{element|id:29|Telefonnummer Antragsteller} %20%0A%0AVersandadresse%20f%C3%BCr%20den%20Orden%3A%20{element|id:33|Straße}{element|id:35|PLZ}{element|id:34|Hausnummer}{element|id:36|Ort}%0A%0AZu%20ehrendes%20Mitglied%3A%0AName%3A%20{element|id:17|Vorname des zu...enden Mitglieds}{element|id:18|Nachname des z...enden Mitglieds}%20%0AVereinszugeh%C3%B6rigkeit%3A%20{element|id:13|Name des Verei...enden Mitglieds} 
%0A%0AVereinzugeh%C3%B6rigkeit%20in%20Jahren%3A%20{element|id:39|Zugehörigkeit Verein in Jahren%20%0AAmt%3A%20{element|id:42|Ausgeführtes Amt/Ämter}%20%0AWelche%20Ehrung%3A%20{element|id:20|Auswahl des Verdienstorden}%20%20%0A%0AVoraussetzungen%20erf%C3%BCllt%3F%3A%20Erf%C3%BCllt%20%20%0A%0A%0AJahr%20der%20letzten%20Ehrung%3A%20{element|id:27|Jahr der Ehrung}%20%20%0A%0A%0AZus%C3%A4tzliche%20Informationen%20{element|id:38|Zuästzliche Informationen}
<a href="mailto:[email protected]?subject=Best%C3%A4tigung%20Ehrung%3A%20f%C3%BCr%20{element|id:17|Vorname des zu...enden Mitglieds}%20{element|id:18|Nachname des z...enden Mitglieds}%20{element|id:20|Auswahl des Verdienstorden}
&body=Sehr%20geehrter%20Herr%20Pr%C3%A4sident%2C%20%20%0A%20%0A%20%20%0Ahiermit%20bitte%20ich%20um%20Freigabe%20der%20Ehrung.%20Ich%20habe%20die%20Voraussetzungen%20nach%20meinen%20Mitteln%20gepr%C3%BCft%20und%20Best%C3%A4tige%20diese.%20%20%20%0A%20%0A%20%0AAnbei%20die%20Daten%20zur%20Ehrung%3A%20%20%0A%20%0A%20%0AMitgliedsnummerverein%3A%20{element|id:3|Mitgliedsnummer}  %20%0ABezirk%3A%20{element|id:43|Bezirk} %20%0AName%20des%20Vereins%3A%20{element|id:4|Name des Vereins%20%20%0AE-Mail-Antragsteller%3A%20%20%20%20%0AName%20Antragsteller%3A%20{element|id:5|Vorname Antragsteller}%20{element|id:6|Nachname Antragsteller}  %20%0ATelefon%20Antragsteller%3A%20{element|id:29|Telefonnummer Antragsteller} %20%0A%0AVersandadresse%20f%C3%BCr%20den%20Orden%3A%20{element|id:33|Straße}{element|id:35|PLZ}{element|id:34|Hausnummer}{element|id:36|Ort}%0A%0AZu%20ehrendes%20Mitglied%3A%0AName%3A%20{element|id:17|Vorname des zu...enden Mitglieds}{element|id:18|Nachname des z...enden Mitglieds}%20%0AVereinszugeh%C3%B6rigkeit%3A%20{element|id:13|Name des Verei...enden Mitglieds} 
%0A%0AVereinzugeh%C3%B6rigkeit%20in%20Jahren%3A%20{element|id:39|Zugehörigkeit Verein in Jahren%20%0AAmt%3A%20{element|id:42|Ausgeführtes Amt/Ämter}%20%0AWelche%20Ehrung%3A%20{element|id:20|Auswahl des Verdienstorden}%20%20%0A%0AVoraussetzungen%20erf%C3%BCllt%3F%3A%20Erf%C3%BCllt%20%20%0A%0A%0AJahr%20der%20letzten%20Ehrung%3A%20{element|id:27|Jahr der Ehrung}%20%20%0A%0A%0AZus%C3%A4tzliche%20Informationen%20{element|id:38|Zuästzliche Informationen}
%20%20">Freigabe</a>
 
%20%20">Freigabe</a>
html forms button mailto
1个回答
0
投票

我无法想象这种设计可以解决什么用例,但是

mailto:
URL 是发送电子邮件的最不可靠的方式,并且您希望为 HTML 消息堆积多个嵌套级别。这或多或少相当于用纸板建造一座铁路吊桥。所以简短的回答是:请不要!

这么说,这看起来像是一种有趣的虐待,所以让我们看看如何做到这一点。我将使用 PHP 来模拟这个,因为我不是受虐狂,但我想这可以用笔和纸来完成,并直接在 HTML 编辑器中键入。

我们将从一些关于格式的研究开始。它没有明确提及发送 HTML 的方法,但它说“任何标准邮件标头字段都可以添加到您提供的 mailto URL 中”。所以我们可以尝试看看会发生什么:

$headers = [
    'Subject' => 'This is a test',
    'Content-Type' => 'text/html',
    'body' => '<a href="https://www.google.com/">Open Google</a>'
];
printf(
    '<a href="mailto:%s?%s">Email link</a>',
    htmlspecialchars($to),
    htmlspecialchars(http_build_query($headers))
);

这呈现:

<a href="mailto:[email protected]?Subject=This+is+a+test&amp;Content-Type=text%2Fhtml&amp;body=%3Ca+href%3D%22https%3A%2F%2Fwww.google.com%2F%22%3EOpen+Google%3C%2Fa%3E">Email link</a>

我只有 Gmail 可供测试,但它对我来说根本不起作用:

但是,这就是

mailto:
的魔力,由访问者本地可用的电子邮件客户端来决定哪些有效,哪些无效。假设有一些电子邮件客户端可以呈现 HTML。然后,我们只需要嵌套我们的链接。将把以前的代码移动到一个函数并链接多个调用:

function generateMailtoLink(string $to, string $subject, string $body): string
{
    $headers = [
        'Subject' => $subject,
        'Content-Type' => 'text/html',
        'body' => $body,
    ];
    return sprintf(
        '<a href="mailto:%s?%s">Email link</a>',
        htmlspecialchars($to),
        htmlspecialchars(http_build_query($headers))
    );
}

$link = '<a href="https://www.google.com/">Open Google</a>';
for ($i = 0; $i < 5; $i++) {
    $link = generateMailtoLink('[email protected]', 'Test subject', $link);
}

echo $link;

输出:

<a href="mailto:[email protected]?Subject=Test+subject&amp;Content-Type=text%2Fhtml&amp;body=%3Ca+href%3D%22mailto%3Atest%40example.com%3FSubject%3DTest%2Bsubject%26amp%3BContent-Type%3Dtext%252Fhtml%26amp%3Bbody%3D%253Ca%2Bhref%253D%2522mailto%253Atest%2540example.com%253FSubject%253DTest%252Bsubject%2526amp%253BContent-Type%253Dtext%25252Fhtml%2526amp%253Bbody%253D%25253Ca%252Bhref%25253D%252522mailto%25253Atest%252540example.com%25253FSubject%25253DTest%25252Bsubject%252526amp%25253BContent-Type%25253Dtext%2525252Fhtml%252526amp%25253Bbody%25253D%2525253Ca%25252Bhref%2525253D%25252522mailto%2525253Atest%25252540example.com%2525253FSubject%2525253DTest%2525252Bsubject%25252526amp%2525253BContent-Type%2525253Dtext%252525252Fhtml%25252526amp%2525253Bbody%2525253D%252525253Ca%2525252Bhref%252525253D%2525252522https%252525253A%252525252F%252525252Fwww.google.com%252525252F%2525252522%252525253EOpen%2525252BGoogle%252525253C%252525252Fa%252525253E%25252522%2525253EEmail%25252Blink%2525253C%2525252Fa%2525253E%252522%25253EEmail%252Blink%25253C%25252Fa%25253E%2522%253EEmail%2Blink%253C%252Fa%253E%22%3EEmail+link%3C%2Fa%3E">Email link</a>

正如我所说,它对我不起作用,所以我无法直接测试它。但我将通过使用 Stack Overflow 可运行代码片段来运行每个 HTML 版本、单击链接并从 Gmail 正文中获取 HTML 来间接验证:

<a href="mailto:[email protected]?Subject=Test+subject&amp;Content-Type=text%2Fhtml&amp;body=%3Ca+href%3D%22mailto%3Atest%40example.com%3FSubject%3DTest%2Bsubject%26amp%3BContent-Type%3Dtext%252Fhtml%26amp%3Bbody%3D%253Ca%2Bhref%253D%2522mailto%253Atest%2540example.com%253FSubject%253DTest%252Bsubject%2526amp%253BContent-Type%253Dtext%25252Fhtml%2526amp%253Bbody%253D%25253Ca%252Bhref%25253D%252522mailto%25253Atest%252540example.com%25253FSubject%25253DTest%25252Bsubject%252526amp%25253BContent-Type%25253Dtext%2525252Fhtml%252526amp%25253Bbody%25253D%2525253Ca%25252Bhref%2525253D%25252522https%2525253A%2525252F%2525252Fwww.google.com%2525252F%25252522%2525253EOpen%25252BGoogle%2525253C%2525252Fa%2525253E%252522%25253EEmail%252Blink%25253C%25252Fa%25253E%2522%253EEmail%2Blink%253C%252Fa%253E%22%3EEmail+link%3C%2Fa%3E">Email link</a>

<a href="mailto:[email protected]?Subject=Test+subject&amp;Content-Type=text%2Fhtml&amp;body=%3Ca+href%3D%22mailto%3Atest%40example.com%3FSubject%3DTest%2Bsubject%26amp%3BContent-Type%3Dtext%252Fhtml%26amp%3Bbody%3D%253Ca%2Bhref%253D%2522mailto%253Atest%2540example.com%253FSubject%253DTest%252Bsubject%2526amp%253BContent-Type%253Dtext%25252Fhtml%2526amp%253Bbody%253D%25253Ca%252Bhref%25253D%252522https%25253A%25252F%25252Fwww.google.com%25252F%252522%25253EOpen%252BGoogle%25253C%25252Fa%25253E%2522%253EEmail%2Blink%253C%252Fa%253E%22%3EEmail+link%3C%2Fa%3E">Email link</a>

<a href="mailto:[email protected]?Subject=Test+subject&amp;Content-Type=text%2Fhtml&amp;body=%3Ca+href%3D%22mailto%3Atest%40example.com%3FSubject%3DTest%2Bsubject%26amp%3BContent-Type%3Dtext%252Fhtml%26amp%3Bbody%3D%253Ca%2Bhref%253D%2522https%253A%252F%252Fwww.google.com%252F%2522%253EOpen%2BGoogle%253C%252Fa%253E%22%3EEmail+link%3C%2Fa%3E">Email link</a>

<a href="mailto:[email protected]?Subject=Test+subject&amp;Content-Type=text%2Fhtml&amp;body=%3Ca+href%3D%22https%3A%2F%2Fwww.google.com%2F%22%3EOpen+Google%3C%2Fa%3E">Email link</a>

<a href="https://www.google.com/">Open Google</a>

© www.soinside.com 2019 - 2024. All rights reserved.