0

非常に単純なクラシック ASP フォームを 123-reg で起動して実行しようとしています。

123-reg はこれを行うためのスクリプトを提供していますが、このスクリプトが私が作成したフォームにどのように接続するのかわかりません。

これが私のhtmlです:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>

<body>

<form id="form" target="_blank" action="script.asp" method="post">

Name: <input name="Name" type="text" /><br />
Customer ID: <input name="Customer ID" type="text" /><br />
Email Address: <input name="Email" type="text" /><br />
Comments:<br />
<textarea name="Comments" rows=5 cols=50></textarea>
<input type="submit" value="Submit" />
<input type="reset" value="Clear" />
</form>

</body>
</html>

そして、これは簡単なスクリプトです:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Secure Mail (ASP)</title>

</head>
<body>
<div id="container" class="index" style="padding:10px">

<br />
<br />
<h2>Secure Mail (ASP)</h2>
<br />

<%
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'To get the script for work please set the following values:

'Set the credentials for your email account to send the email from
username="MYUSERNAME"     'Insert your email account username between the double quotes            
password="MYPASSWORD"     'Insert your email account password between the double quotes              

'Set the from and to email addresses
sendFrom = "admin@MYURL.co.uk"   'Insert the email address you wish to send from   
sendTo = "MYEMAIL"     'Insert the email address to send to in here

'DO NOT CHANGE ANY SCRIPT CODE BELOW THIS LINE.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'This script demonstrates how to send an email using asmtp

'Create a CDO.Configuration object
Set objCdoCfg = Server.CreateObject("CDO.Configuration")

'Configure the settings needed to send an email
objCdoCfg.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="intmail.atlas.pipex.net"
objCdoCfg.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objCdoCfg.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objCdoCfg.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 0
objCdoCfg.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = username
objCdoCfg.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = password
objCdoCfg.Fields.Update

'Create the email that we are going to send
Set objCdoMessage = Server.CreateObject("CDO.Message")
Set objCdoMessage.Configuration = objCdoCfg
objCdoMessage.From = sendFrom
objCdoMessage.To = sendTo
objCdoMessage.Subject = "This is a test email."

'Add the email body text
objCdoMessage.TextBody = "Email sent using ASMTP from a ASP script."


On Error Resume Next

'Send the email
objCdoMessage.Send

'Check if an exception was thrown       
If Err.Number <> 0 Then
    'Response.Write "<FONT color=""Red"">Error: " & Err.Description & " (" & Err.Number & ")</FONT><br/>"
Else
    Response.Write "<FONT color=""Green"">The email has been sent to " & sendTo & ".</FONT>"
End If

'Dispose of the objects after we have used them
Set objCdoMessage = Nothing
Set objCdoCfg = Nothing
Set FSO = nothing
Set TextStream = Nothing
%>


</div>
</body> 
</html>

スクリプトが電子メールを送信するときに機能することはわかっていますが、HTML フォームに含まれる情報は含まれていないようです。

通常はフォームを使用しないでください。アドバイスをいただければ幸いです。

ありがとう、

ダン

4

1 に答える 1

0

ASPのどこにも、メールに含めるフォームデータを要求していません。

たとえば、asp でこれの代わりに:

sendTo = "MYEMAIL"     'Insert the email address to send to in here

フォームからの電子メールを使用する必要があります。

sendTo = Request.Form("Email")     'Insert the email address to send to in here

最初にメールアドレスを検証することをお勧めします:

if isEmailValid(Request.Form("Email")) = true then
    '#### Send your email
else
    '#### Email was invalid, give the user an error
    response.write "Invalid email address"
end if

Function isEmailValid(email) 
    Set regEx = New RegExp 
    regEx.Pattern = "^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w{2,}$" 
    isEmailValid = regEx.Test(trim(email)) 
End Function 

確認のため、request.form コレクションは HTML フォームの name="" プロパティを使用します。つまり、テキストエリアの内容を含めるには:

'Add the email body text
objCdoMessage.TextBody = "The following comment was submitted via the feedback form:" & Request.Form("Comments")
于 2012-07-29T15:57:53.383 に答える