主题:  帮我看看代码哪儿错了?(邮件发送)

onojh

职务:普通成员
等级:1
金币:0.0
发贴:7
注册:2002/11/20 17:14:23
#12002/11/20 17:25:37
<%
response.buffer="True"
If len(request("year"))<4 Then
response.write ""
response.end
End If
if trim(request("oicq"))<>"" then
If not isnumeric(request("oicq")) Then
response.write ""
response.end
End If
If len(request("oicq"))<5 Then
response.write ""
response.end
End If
end if
If isnumeric(request("question")) or isnumeric(request("answer")) or isnumeric(request("rname")) Then
response.write ""
response.end
End If
function chuser(u)
dim filter,xx,usernameenable,su
for i=1 to len(u)
su=mid(u,i,1)
xx=asc(su)
zhengchu = -1*xx \ 256
yushu = -1*xx mod 256
if (xx>122 or (xx>57 and xx<97) or (xx<-10241 and xx>-10247) or yushu=129 or yushu>192 or (yushu<2 and yushu>-1) or (((zhengchu>1 and zhengchu<8) or (zhengchu>79 and zhengchu<86)) and yushu<96 ) or (xx>-352 and xx<48) or (xx<-22016 and xx>-24321) or (xx<-32448)) then
chuser=true
exit function
end if
next
chuser=false
end function
if chuser(trim(request("user"))) then
response.write ""
response.end
End If
%>

<%if session("regok")<>1 then response.redirect "reg.asp"
sql="select username from USER where username='"&trim(request("user"))&"'"
rs.open sql,conn,1,1
if not rs.eof then response.redirect "reg.asp"
rs.close

sql="select * from user"
rs.open sql,conn,1,3
rs.addnew
rs("username")=trim(request("user"))
cc=makePassword(9)
rs("password")=cc
rs("question")=trim(request("question"))
rs("answer")=trim(request("answer"))
rs("rname")=trim(request("rname"))
rs("sex")=trim(request("sex"))
rs("email")=trim(request("email"))
rs("year")=trim(request("year"))
rs("month")=trim(request("month"))
rs("day")=trim(request("day"))
rs("user_province")=trim(request("user_province"))
if request("user_city")="" then
rs("user_city")=trim(request("user_province"))
else
rs("user_city")=trim(request("user_city"))
end if
rs("user_homepage")=trim(request("user_homepage"))
rs("user_danwei")=trim(request("user_danwei"))
rs("user_position")=trim(request("user_position"))
rs("user_bookmark")=trim(request("user_bookmark"))
rs("user_post_code")=trim(request("user_post_code"))
rs("oicq")=trim(request("oicq"))
rs.update

if sysemail=1 then
dim objCDOMail,SendMail
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
objCDOMail.MailServerUserName = "webmaster@onojh.com"
objCDOMail.MailServerPassword = "password"
    objCDOMail.From = "webmaster@onojh.com"
objCDOMail.FromName ="name"
objCDOMail.To =request("email")
objCDOMail.Subject = "欢迎您注册"
    objCDOMail.BodyFormat = 0
    objCDOMail.MailFormat = 0
    objCDOMail.Body =request("user")&"您好,欢迎您注册成为会员,您的密码是"&cc&" ,您的密码提示问题是:"&trim(request("question"))&",问题的答案是:"&trim(request("answer"))
    objCDOMail.Send ("mail.onojh.com")
    Set objCDOMail = Nothing
end if

%> <%session("regok")=""%>
<%if sysemail=1 then%>



<%else%>



<% end if%>





这是注册会员系统,通过email发送密码,但是为什么总收不到邮件呢?(服务器只支持CDONTS.NewMail)

那位高手,帮忙修改一下,感激不尽!



内蒙古飞翔鸟

职务:普通成员
等级:1
金币:0.0
发贴:67
注册:2002/5/4 22:57:07
#22002/11/20 19:52:01
先 看看 您的服务器 是否 支持 SMTP 功能 ,能否建立cdont.newmail 吧 ,然后 在查程序 错误 。
另外 在 调用 后的第 四行代码 你为什么用 if not rs.eof then response.redirect "reg.asp"
rs.close
如果 该用户存在 ,你为何 还要让 用户 去 注册 ?
况且 你 还 拉 了 end if 作 为结束 的标记 吧

我的回答不一定 正确 ,还请多多 指教 !



onojh

职务:普通成员
等级:1
金币:0.0
发贴:7
注册:2002/11/20 17:14:23
#32002/11/21 11:09:08
首先谢谢您看我的贴子
1,我已经用asp探针测试过服务器,能够使用CDONT.newmail
2,您的疑问:(在 调用 后的第 四行代码 你为什么用 if not rs.eof then response.redirect "reg.asp"
rs.close
如果 该用户存在 ,你为何 还要让 用户 去 注册 ? )

这一点,是因为注册的时候,如果该用户名存在,就返回到reg.asp,请注册人换一个用户名字,这些都没问题!

3,主要是邮件发送的那一部分:
dim objCDOMail,SendMail
Set objCDOMail = Server.CreateObject("CDONTS.NewMail"
objCDOMail.MailServerUserName = "webmaster@onojh.com"
objCDOMail.MailServerPassword = "password"
objCDOMail.From = "webmaster@onojh.com"
objCDOMail.FromName ="name"
objCDOMail.To =request("email"
objCDOMail.Subject = "欢迎您注册"
objCDOMail.BodyFormat = 0
objCDOMail.MailFormat = 0
objCDOMail.Body =request("user"&"您好,欢迎您注册成为会员,您的密码是"&cc&" ,您的密码提示问题是:"&trim(request("question")&",问题的答案是:"&trim(request("answer")
objCDOMail.Send ("mail.onojh.com"
Set objCDOMail = Nothing


麻烦帮我看看有没有问题,我觉得没问题了,那为什么收不到信呢?



内蒙古飞翔鸟

职务:普通成员
等级:1
金币:0.0
发贴:67
注册:2002/5/4 22:57:07
#42002/11/21 11:33:39
你 能不能把 原程序和数据库打成 压缩包 寄 给 我 , 我 可以在 我的服务器上 调试一下 ,另外 你可以先做一个 form 表单 有 姓名 密码 ,再 调用 你的 newmail 对象 ,看看 能否直接收到 信 。如果可以 证明 你的 方法没错 再 检查 剩下的 变量 赋值 和 传递过程 有没有 问题 。
思路 如 上 逐步测试吧 :)