目前我正在编写一个充满数据的网络界面。我想将此数据导出为电子邮件模板,以便您之后可以编辑电子邮件。是否有像 *.oft 这样的格式,可以被所有电子邮件程序读取?
我知道HTML(<a href="mailto:[...]">
)中有这样的功能。由于电子邮件文本很长,我想附加文件,这似乎不是一个好的解决方案。
有人能帮我吗?
没有您正在寻找的格式。设计电子邮件协议和格式的互联网工程师关心的是通过网络发送的内容,而不是机器内部的内容。因此,电子邮件在发送和接收消息时具有高度的互操作性,但内部 API 没有类似的标准主体。有时,模仿流行软件的行为会产生事实上的标准,但对于您正在寻找的电子邮件功能来说,这并没有发生。
也许您的意思是 .EML 文件?我记得这个文件几乎可以用 Outlook、Thunderbird 等所有电子邮件客户端打开。
据我所知,您可以采用以下两种方式之一:
1 - 使用预构建的解决方案,例如这些人在postageapp.com提供的解决方案,他们的 API 看起来非常简单,并且可以完成您想要实现的一切。
2 - 更耗时,但您可以使用 PHP 创建自己的模板。我会沿着这些思路去做。这是一种非常简单的方法。您可以在头脑中编写自己的 CSS 并发疯。请记住,当涉及到 HTML 电子邮件时,表格是王道:) 编写模板后,您可以通过 $content 来填充它...。
发件人.php
<?php
$email = "Hello, \n";
$email.= "Very <strong>impressed</strong> with your email! \n\n";
$email.= "Faithfully\n";
$email.= "Mr Example\n";
$to = "me@me.me"; // <-- Set this as yours for testing...
$from = "someone@nice.me";
$subject = "An email";
$headers = "From: Someone nice <" . $from . ">\r\n";
$headers .= "Reply-To: ". $from . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body>';
$message .= nl2br($email); // <---- if your email contains newline characters - it will convert them to <br />
$message .= '<br /><a href="http://www.example.com" target="_blank">www.example.com</a>';
$message .= "</body></html>";
mail($to, $subject, $message, $headers);
// ADD LOTS OF PROTECTION IF NOT HARD CODING :)
?>
为了扩展这一点——例如,如果你使用 Gmail,那么你可以使用 Google 的 SMTP 来发送它——这样电子邮件就不会说“代表发送”。
只需使用没有 CSS 的 HTML 创建电子邮件。任何数据或二进制文件都可以通过 PHP 传递,然后通过电子邮件发送给收件人。
To get you started, Create a file using fopen();. PHP has other functions that would allow you to edit, open, search&replace and even convert a file to a format of your choice. This is equivalent to a .oft file if not better, because all emails are be sent in text or a html equivalent regardless of the email client.
If you'd would like some more info on how to create this, let me know.