我是ASP的新手。任何人都可以建议如何编辑ASP表单脚本以发送正确的身份验证邮件。我无法找到编辑它的正确脚本。
目前尚未发送!
答案 0 :(得分:0)
我们在谈论经典ASP还是ASP.net?你的标签会使这个含糊不清,答案会有很大差异,具体取决于哪个
这是一个经典的ASP示例 - 连接超时行是可选的,如果你没有使用ssl,你应该省略ssl行 - 显然。
smtpserverport通常为25或587
<%
Dim objMail, iConfg, Flds
Set objMail = Server.CreateObject("CDO.Message")
Set iConfg = Server.CreateObject("CDO.Configuration")
Set Flds = iConfg.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "your.smtpserver.address"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "yourmailboxname@yourdomain.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "yourpassword"
.Update
End With
.Configuration = iConfg
objMail.Subject = Request("subject")
objMail.From = Request("senderemail")
objMail.To = "yourmailboxname@yourdomain.com"
objMail.TextBody= Request("message")
objMail.Send
set objMail = nothing
response.write "Thank you for emailing us, we will be in touch shortly"
%>
如果上面的脚本位于名为sendcdo.asp的文件中,那么您的表单将是这样的
<form method="post" action="sendcdo.asp">
Subject: <input type="text" name="subject" /><br />
Your email:<input type="text" name="senderemail" /><br />
Your message<textarea name="message"></textarea><br />
<input type="submit" value="Send">
</form>