Hejsa jeg har en hjemmeside hvor følgende script bruges til at sende
password ud til brugere.
Min udbyder har nu lavet om i sikkerheden hvilket betyder der skal sendes
med godkendelse af brugernavn
og adgangskode.
Er der en venlig sjæl der gider og kigge på hvad der skal til for at det
virker det er linie 91 den melder fejl på og det er denne objCDOSYSMail.Send
Hilsen
Johnny
<!--#include file='includes/dbconnection.inc'-->
<!--#include file="includes/md5.asp"-->
<!--#include file='header.inc'-->
<!--#include file='includes/settings.asp'-->
<!--#include file='includes/title.asp'-->
<script language="javascript">
function invalid() {
if (document.Login.txtUserPass.value != document.Login.txtUserPass2.value) {
alert("Passwords don't match. Please re-enter.");
return false;
}
if (document.Login.txtUserPass.value=="") {
alert("Password is blank. Please re-enter.");
document.Login.txtUserPass.focus();
return false;
}
}
</script>
<%
If Session("userAdmin") = 0 or IsNull(Session("userAdmin")) = True then
Response.Redirect"default.asp"
End If
Function RandomPW(myLength)
Const minLength = 6
Const maxLength = 20
Dim X, Y, strPW
If myLength = 0 Then
Randomize
myLength = Int((maxLength * Rnd) + minLength)
End If
For X = 1 To myLength
'Randomize the type of this character
Y = Int((3 * Rnd) + 1) '(1) Numeric, (2) Uppercase, (3) Lowercase
Select Case Y
Case 1
Randomize
strPW = strPW & CHR(Int((9 * Rnd) + 48))
Case 2
Randomize
strPW = strPW & CHR(Int((25 * Rnd) + 65))
Case 3
Randomize
strPW = strPW & CHR(Int((25 * Rnd) + 97))
End Select
Next
RandomPW = strPW
End Function
If Request.querystring("mode") = "add" then
strUserName = Replace(Request.Form("txtUserName"), "'", "''")
strUserPassNE = Replace(Request.Form("txtUserPass"), "'", "''")
strUserPass = md5(Replace(Request.Form("txtUserPass"), "'", "''"))
strEmail = Replace(Request.Form("txtEmail"), "'", "''")
strConfirm = RandomPW(0)
IF strUserName = "" then
Response.Write ("<center><font color=red>Please enter a
UserName</font></center><br><br>")
Elseif strEmail = "" then
Response.Write ("<center><font color=red>Please enter a Email
Address</font></center><br><br>")
Else
strSQL = "INSERT INTO tblUsers ([username], [password], [email],
[suspend], [Timestamp], [confirm]) VALUES('" & strUserName & "', '" &
strUserPass & "','" & strEmail & "', '1', '" & date() & "', '" & strConfirm
& "')"
strSQLCheck = "SELECT [username] from tblUsers where username = '" &
strUserName & "'"
strEmailCheck = "SELECT [email] from tblUsers where email = '" & strEmail
& "'"
Set rsNewUser = adoCon.Execute(strSQLCheck)
Set rsNewEmailUser = adoCon.Execute(strEmailCheck)
IF rsNewUser.EOF then
IF rsNewEmailUser.EOF then
Set rsNewUser = adoCon.Execute(strSQL)
htmlBody = "Welcome to ASPLogin Secure Site<br><br>Please keep this
email for your records. Your account information is as
follows:<br><br>--------------------<br>Username: "
htmlBody = htmlBody & strUserName & "<br>"
htmlBody = htmlBody & "Password: "
htmlBody = htmlBody & strUserPassNE & "<br>--------------------<br>"
htmlBody = htmlBody & "<br>Your account is currently inactive. You
cannot use it until you visit the following link:<br><br>"
htmlBody = htmlBody & "<a href=http://" &
Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("URL") &
"?mode=activate&email=" & strEmail & "&confirm=" & strConfirm & ">"
htmlBody = htmlBody & "http://" & Request.ServerVariables("HTTP_HOST")
& Request.ServerVariables("URL") & "?mode=activate&email=" & strEmail &
"&confirm=" & strConfirm & "</a>"
htmlBody = htmlBody & "<br>"
htmlBody = htmlBody & "<br>--------------------<br><br> Thank you for
registering."
Set objCDOSYSMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
objCDOSYSCon.Fields("
http://schemas.microsoft.com/cdo/configuration/smtpserver")
= vEmailServer
objCDOSYSCon.Fields("
http://schemas.microsoft.com/cdo/configuration/smtpserverport")
= 25
objCDOSYSCon.Fields("
http://schemas.microsoft.com/cdo/configuration/sendusing")
= 2
objCDOSYSCon.Fields("
http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout")
= 60
objCDOSYSCon.Fields.Update
Set objCDOSYSMail.Configuration = objCDOSYSCon
objCDOSYSMail.From = vSiteEmail
objCDOSYSMail.To = strEmail
objCDOSYSMail.Subject = "New Account"
objCDOSYSMail.HTMLBody = htmlBody
objCDOSYSMail.Send
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing
Response.Write ("<center>Your Account was successfully created. Please
check the email account given for login details.</center>")
Else
Response.Write ("<b><center><font color='red'>Email is already
taken.</center></font>")
Call ShowForm
End If
Else
Response.Write ("<b><center><font color='red'>Username is already
taken.</center></font>")
Call ShowForm
End If
Set rsNewUser = Nothing
Set rsNewEmailUser = Nothing
Set adoCon = Nothing
End If
End If
If Request.querystring("mode") = "activate" then
strEmail = Replace(Request.querystring("email"), "'", "''")
strConfirm = Replace(Request.querystring("confirm"), "'", "''")
Set rsConfirm = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT [email], [confirm] from tblUsers where email = '" &
strEmail & "'"
rsConfirm.Open strSQL, adoCon
IF rsConfirm("confirm") = strConfirm then
strUpdateSQL = "UPDATE tblUsers SET tblUsers.suspend='0' WHERE email = '"
& strEmail & "'"
adoCon.Execute(strUpdateSQL)
Response.Write ("<center>Your Account was successfully activated. Please
login.</center>")
Response.Write ("<form name='Login' method='post' action='login.asp'>")
Response.Write ("<table width='273' border='0' align='center'
cellspacing='0' cellpadding='0' bgcolor='#CCCCCC' style='BORDER-BOTTOM:
#000000 1px solid; border-top:1px solid #000000; border-left:1px solid
#000000; border-right:1px solid #000000'><tr>")
Response.Write ("<td align='right' height='47' valign='bottom'
width='94'>User name: </td>")
Response.Write ("<td height='47' valign='bottom' width='172'>")
Response.Write ("<input type='text' name='txtUserName'>")
Response.Write ("</td></tr><tr>")
Response.Write ("<td align='right' width='94'>Password: </td>")
Response.Write ("<td width='172'>")
Response.Write ("<input type='password' name='txtUserPass'>")
Response.Write ("</td></tr><tr>")
Response.Write ("<td align='right' height='44' width='94'> </td>")
Response.Write ("<td height='44 width='172'>")
Response.Write ("<input type='image' src='images/forward_16.gif'
name='Submit' value='Enter' alt='Enter'>")
Response.Write (" ")
Response.Write ("<input type='image' src='images/cancel_16.gif'
name='Reset' value='Reset' alt='Reset'>")
Response.Write ("</td></tr></table></form>")
htmlBody = "The account owned by <a href=mailto:" & strEmail & ">" &
strEmail & "</a> has been created."
Set objCDOSYSMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
objCDOSYSCon.Fields("
http://schemas.microsoft.com/cdo/configuration/smtpserver")
= vEmailServer
objCDOSYSCon.Fields("
http://schemas.microsoft.com/cdo/configuration/smtpserverport")
= 25
objCDOSYSCon.Fields("
http://schemas.microsoft.com/cdo/configuration/sendusing")
= 2
objCDOSYSCon.Fields("
http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout")
= 60
objCDOSYSCon.Fields.Update
Set objCDOSYSMail.Configuration = objCDOSYSCon
objCDOSYSMail.From = vSiteEmail
objCDOSYSMail.To = vSiteEmail
objCDOSYSMail.Subject = "New Account"
objCDOSYSMail.HTMLBody = htmlBody
objCDOSYSMail.Send
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing
Else
Response.Write ("<center>An error occured when activating your account.
Please contact the administrator <a href=mailto:" & vSiteEmail & ">" &
vSiteEmail & "</center>")
End If
Set rsConfirm = Nothing
End If
If Request.Querystring("mode") = "" Then
Call ShowForm
End If
Sub ShowForm()
%>
<b><center>Register for an account</center></b>
<form name='Login' method='post' action='register.asp?mode=add'
onSubmit='return invalid()'>
<table width='273' border='0' align='center' cellspacing='0' cellpadding='0'
bgcolor='#CCCCCC' style="BORDER-BOTTOM: #000000 1px solid; border-top:1px
solid #000000; border-left:1px solid #000000; border-right:1px solid
#000000">
<tr>
<td align='right' height='47' valign='bottom' width='94'>User name: </td>
<td height='47' valign='bottom' width='172'>
<input type='text' name='txtUserName'>
</td></tr><tr>
<td align='right' width='94'>Password: </td>
<td width='172'>
<input type='password' name='txtUserPass'>
</td></tr><tr>
<td align='right' width='94'>Confirm Password: </td>
<td width='172'>
<input type='password' name='txtUserPass2'>
</td></tr><tr>
<td align='right' width='94'>Email: </td>
<td width='172'>
<input type='text' name='txtEmail'>
</td></tr><tr>
<td align='right' height='44' width='94'> </td><td height='44
width='172'>
<input type='image' src='images/forward_16.gif' name='Submit' value='Enter'
alt='Enter'>
<input type='image' src='images/cancel_16.gif' name='Reset' value='Reset'
alt='Reset'>
</td></tr></table></form>
<%
End Sub
%>
<center><table><tr><td><a href=
http://www.toddwoolums.com/asplogin.asp
target=_new><img src=images/poweredby.gif alt='Powered By ASP Login'
border=0></a></td></tr></table></center>
<!--#include file='footer.inc'-->