我可以使用JavaScript创建客户端电子邮件吗?

Tel*_*tar 16 javascript email

我想创建一个客户端邮件创建者网页.我知道在html表单中使用mailto操作的问题(非标准,客户端上没有设置默认邮件应用程序).但网页不是很重要,他们并不在乎.

mailto操作创建的邮件具有以下语法:

主题:未定义的
主体:

param1 = value1
param2 = value2
.
.
.
paramn =值N

我可以使用JavaScript来格式化这样的邮件吗?

主题:XXXXX

正文:Value1; Value2; Value3 ... ValueN

Vin*_*ert 17

我们在projet中使用的是一个打开mailto:链接的弹出窗口,这是我们发现在默认邮件客户端中编写邮件的唯一方式,该邮件客户端适用于所有邮件客户端(至少我们使用的所有客户端).

var addresses = "";//between the speech mark goes the receptient. Seperate addresses with a ;
var body = ""//write the message text between the speech marks or put a variable in the place of the speech marks
var subject = ""//between the speech marks goes the subject of the message
var href = "mailto:" + addresses + "?"
         + "subject=" + subject + "&"
         + "body=" + body;
var wndMail;
wndMail = window.open(href, "_blank", "scrollbars=yes,resizable=yes,width=10,height=10");
if(wndMail)
{
    wndMail.close();    
}
Run Code Online (Sandbox Code Playgroud)


Lar*_*lum 6

通过浏览器发送邮件时,您或多或少只有两种选择.

  1. 创建一个接受用户输入的页面,并允许他们通过您的Web服务器发送邮件.您需要某种服务器端脚本.
  2. 使用mailto:link来触发用户注册邮件客户端的打开.这有你提到的明显陷阱,而且灵活性较差.但它需要的工作量更少.