【发布时间】:2013-01-23 06:27:48
【问题描述】:
我们可以从静态网站(html页面)发送电子邮件吗?不使用 asp.net 或其他(我的意思是没有服务器端技术)。
【问题讨论】:
标签: html
我们可以从静态网站(html页面)发送电子邮件吗?不使用 asp.net 或其他(我的意思是没有服务器端技术)。
【问题讨论】:
标签: html
仅使用 javascript 和 html,这是不可能的。 Javascript 不打算做这些事情,并且在与它所在的网络浏览器以外的任何东西交互方面严重受损。您可以使用 mailto: 链接来触发打开用户注册的邮件客户端。
但是,您可以做一个弹出窗口来更好地处理mailto:,例如this 解决方案
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();
}
编辑:也许您不能使用服务器端,但如果您的主机提供formmail.cgi,您可以使用它。大多数主机都支持这一点,instructions for using FormMail 很简单。
【讨论】:
【讨论】:
没有服务器端编码,您只有一个选择通过 HTML 发送电子邮件,那就是
<a href="mailto:emailaddress">Email</a>
【讨论】:
你可以这样做,但你不能保证结果。
以下代码是合法的:
<form method="post" action="mailto:my_adress@my_website.com" enctype="text/plain">
<!-- some inputs here, with a submit of course -->
</form>
但在此之前,请阅读 this。它会告诉你使用它的危险。
【讨论】: