<%@Language="VBSCRIPT"%> <% Option Explicit Response.buffer = True Response.Expires = 0 ' Set debugging variable. Can be either true or false Dim DebugMode DebugMode=False %> <% '------------------------------------------------------------------------------------ Function vpopmail_RandLTR() '-- Produce a random number between 0 and 63 Randomize() Dim Rand Rand = Int(64*Rnd()) if debugmode then Response.Write "Rand was : " & Rand & "
" Dim RetVal if (rand < 26) then retval = Chr(rand + Asc("a")) if (rand > 25) then retval = Chr(rand - 26 + Asc("A")) if (rand > 51) then retval = Chr(rand - 52 + Asc("0")) if (rand = 62) then retval = ";" if (rand = 63) then retval = "." vpopmail_randltr=retval End Function '------------------------------------------------------------------------------------ Function vpopmail_RandomSalt() Dim Salt Salt = "$1$" Dim i For i = 1 to 5 Salt = Salt & vpopmail_RandLTR() Next ' Salt = Salt & "0" vpopmail_RandomSalt=Salt End Function '------------------------------------------------------------------------------------ %> CREATE MAILBOX RESULTS

CREATE MAILBOX RESULTS


<% '------------------------------------------------------------------------------------ Dim NewAddress, NewName, NewPassword NewAddress = lcase(trim(Request.Form("username"))) NewName = trim(Request.Form("NewName")) NewPassword = lcase(trim(Request.Form("password"))) '------------------------------------------------------------------------------------ '------- Perform data validation on the 3 above values '------- Some validation is already done via javascript on the submitting asp page, but better to do some more checks just to make sure '------- Check lengths if debugmode then response.write "Checking lengths..
" if (Len(NewAddress) <2 or Len(NewAddress) >16) then call SubmitError("Mailbox address invalid length") if (Len(NewName) <2 or Len(NewName) >40) then call SubmitError("Mailbox name invalid length") if (Len(NewPassword)<6 or Len(NewPassword) >12) then call SubmitError("Mailbox password invalid length") '------- Check content if debugmode then response.write "Checking content..
" Const AllowedChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-" Dim i For i=1 to len(NewAddress) if instr(AllowedChars ,Mid(NewAddress,i,1)) = 0 then Call SubmitError ("Invalid Char in emailaddress. Char '"&Mid(NewAddress,i,1)&"' is not allowed") Next For i=1 to len(NewName) if instr(AllowedChars & " .'", Mid(NewName,i,1)) = 0 then Call SubmitError ("Invalid Char in new name. Char '"&Mid(NewName,i,1)&"' is not allowed") Next For i=1 to len(NewPassword) if instr(AllowedChars , Mid(NewPassword,i,1)) = 0 then Call SubmitError ("Invalid Char in new password. Char '"&Mid(NewPassword,i,1)&"' is not allowed") Next [snipped] '-- '-- Note this SQL below assumes vpopmail was compiled with --disable-many-domains '-- If you compiled with --enable-many-domains, you need to do a slightly different '-- insert, something like '-- INSERT INTO vpopmail (pw_name, pw_passwd, pw_uid, pw_gecos, pw_dir, pw_shell, pw_clear_passwd) '-- where pw_name is the full email address of the mailbox '-- Dim strSQL, NumRecords strSQL = "INSERT INTO somedomain_com (pw_name, pw_passwd, pw_uid, pw_gid, pw_gecos, pw_dir, pw_shell, pw_clear_passwd) " strSQL = strSQL & "VALUES (" strSQL = strSQL & "'" & newaddress & "'," strSQL = strSQL & "ENCRYPT('" & newpassword & "','" & vpopmail_RandomSalt &"')," strSQL = strSQL & "0,0," strSQL = strSQL & "'" & newname & "'," strSQL = strSQL & "NULL," strSQL = strSQL & "'20971520S'," strSQL = strSQL & "'" & newpassword & "'" strSQL = strSQL & ")" if debugmode then response.write strSQL & "
" objConVPOPMail.Execute strSQL, NumRecords if NumRecords = 0 then Response.Write "ERROR! Failed to create mailbox in vpopmail SQL" Response.End end if objConVPOPMail.Close Set objConVPOPmail=Nothing '------- Email the accounts staff to advise them the mailbox has been created '------- This is just for the staff's records. They dont need to do anything. [snipped] '------- Send an email to this new mailbox so that it gets created. '------- Otherwise if you try to login to qmailadmin, it will spit chips if debugmode then response.write "Sending confirming email to customer..
" Set objMail=Server.CreateObject("Persits.Mailsender") objMail.Host = "smtp.somedomain.com" objMail.From = "support@somedomain.com" objMail.FromName = "SomeCompany Support" objMail.AddAddress newaddress&"@somedomain.com" objMail.Subject = "New mailbox" objMail.Body = "Welcome to your new mailbox!" on error resume next Err.Clear objMail.Send If Err <> 0 then call submiterror ("Error!. Emailing the customer's new mailbox has failed") On error goto 0 set objMail=Nothing '------- Advise customer that mailbox has been created. %> [snipped] objConPipeInt.Close Set objConPipeInt=Nothing %>