我是新来的,不确定我是否正确发布。我为我的网站创建了一个自定义表单,提交后它不会向指定的电子邮件发送电子邮件。我已经搜索并尝试了多种方法来尝试使其正常工作。
我的表格是:
<form name="myForm" action="subform.asp" onSubmit="return validateForm();" method="post">
First Name:<input type="text" size="30" name="fname" maxlength="5"><br>
Last name:<input type="text" size="30" name="lname" maxlength="30"><br>
Email:<input type="text" size="30" name="email" maxlength="30"><br>
Comments:<textarea rows="2" cols="22" name="comments"></textarea>
<input type="submit" value="Submit">
</form>
我的 subform.asp:
<%
Option Explicit
Dim referer
Dim siteurl
Dim email_from
Dim email_to
Dim strMsg
Dim vsmtpKey
referer = Request.ServerVariables("HTTP_REFERER")
siteurl = "www.mysite.com"
email_from = "email@mysite.com"
email_to = "email@mysite.com"
vsmtpKey = "my key"
strMsg = "First Name : " & request.form("fname") & "<br>"
strMsg = "Last Name : " & request.form("lname") & "<br>"
strMsg = "Email : " & request.form("email") & "<br>"
strMsg = "Comments : " & request.form("comments") & "<br>"
if InStr(referer, siteurl ) > 0 Then
Dim HTTPRequest
Set HTTPRequest = CreateObject("WinHTTP.WinHTTPRequest.5.1")
HTTPRequest.Open "POST", "http://" & Request.ServerVariables("LOCAL_ADDR") & "subform.asp", False
HTTPRequest.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
HTTPRequest.SetRequestHeader "Host", Request.ServerVariables("SERVER_NAME")
HTTPRequest.Send _
"VsmtpKey=" & vsmtpKey &_
"&Subject=" & Server.URLEncode("Mailing List Submission") &_
"&FromEmailAddress=" & email_from &_
"&ToEmailAddress=" & email_to &_
"&Body_HTML=" & Server.URLEncode(strMsg)
response.write(HTTPRequest.ResponseText)
Set HTTPRequest = Nothing
End If
%>