Important alert: (current site time 7/15/2013 11:19:07 PM EDT)
 

VB icon

Add New Users to EzMTS Mail Server from ASP Page

Email
Submitted on: 7/7/2003 6:20:07 AM
By: TonyGG  
Level: Beginner
User Rating: By 2 Users
Compatibility: ASP (Active Server Pages), VbScript (browser/client side)
Views: 10758
author picture
 
     Allows new users to signup for an email account via an ASP webpage. Made for EzMTS e-mail server and is specific to EzMTS. The code edits the user database which is just a text file and adds the new user from the webpage. This automates the system somewhat. It took some effort to edit it properly maintaining the integrity of the file. I have released it for some feeback, hopefully improvements. I think it is far better to do things this way than with the use of editing addusers.exe which then must be run from the webpage using WSH. Note: The file must be set-up properly for this to work. Remember to set the proper permission so this works. FILE MUST LOOK LIKE BELOW NOTHING ELSE. [User] Count=3 User0=Postmaster User1=webmaster User2=Username ;! [Passwords] webmaster=planetsourcecode Username=Password
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: Add New Users to EzMTS Mail Server from ASP Page
' Description:Allows new users to signup for an email account via an ASP webpage. Made for EzMTS e-mail server and is specific to EzMTS.
The code edits the user database which is just a text file and adds the new user from the webpage.
This automates the system somewhat.
It took some effort to edit it properly maintaining the integrity of the file. I have released it for some feeback, hopefully improvements. I think it is far better to do things this way than with the use of editing addusers.exe which then must be run from the webpage using WSH.
Note: The file must be set-up properly for this to work. Remember to set the proper permission so this works. FILE MUST LOOK LIKE BELOW NOTHING ELSE.
[User]
Count=3
User0=Postmaster
User1=webmaster
User2=Username
;!
[Passwords]
webmaster=planetsourcecode
Username=Password
' By: TonyGG
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=8423&lngWId=4'for details.'**************************************

<%@ LANGUAGE="VBSCRIPT" %>
 '##########################################################################################
 'Allows new users to signup for an email account via an ASP webpage. 
 'Made for EzMTS e-mail server and is specific to EzMTS. The code edits the user database 
 'which is just a text file and adds the new user from the webpage. This automates the 
 'system somewhat. It took some effort to edit it properly maintaining the integrity of the 
 'file. I have released it for some feeback, hopefully improvements. I think it is far better 
 'to do things this way than with the use of editing addusers.exe to take two parameters 
 'username and password which then must be run from the webpage using WSH. Note: The file 
 'must be set-up properly for this to work. Remember to set the proper permission so this works. 
 'FILE MUST LOOK LIKE BELOW NOTHING ELSE. 5 lines no '
 
 '[User] 
 'Count=1
 'User0=Postmaster 
 ';! 
 '[Passwords] 
 
 'If this page does not find this structure in EzMTS, it will crash and corrupt the User.file.
 '############################################################################################
 <%
 'New EzMTS Email Accounts
 '#####################################
 'Create a new folder for user
 '#####################################
 Set myFSO = Server.CreateObject("Scripting.FileSystemObject")
 if Not myFSO.FolderExists("C:\Inetpub\mailroot\" & username) Then
 myFSO.CreateFolder("C:\Inetpub\mailroot\" & username)
 Response.Write "Creating environment: E-MAIL FOLDER <BR>"
 Else
 Response.Write "Error creating environment: E-MAIL FOLDER NAME ALREADY EXISTS"
 End if
 '##############################################
 'Delete the renamed EzmTS file previously used
 '##############################################
 if MyFSO.FileExists("C:\EzMTS\EzMTS.old") Then
 myFSO.DeleteFile("C:\EzMTS\EzMTS.old")
 End if
 '####################################################################
 'Create a new EzMTS.User file called EzMTS.txt will rename it later
 'after we have finished using the original EzMTS.User
 '####################################################################
 if Not myFSO.FileExists("C:\EzMTS\EzMTS.txt") Then
 myFSO.CreateTextFile("C:\EzMTS\EzMTS.txt")
 End if
 Const ForReading= 1
 Const ForWriting= 2
 Const ForAppending = 8 
 Counter = 0
 NewPath = ("C:\EzMTS\EzMTS.txt") 'Path
 Path = ("C:\EzMTS\EzMTS.User") 'Path
 Set Fs = CreateObject("Scripting.FileSystemObject")
 Set File = Fs.OpenTextFile(Path, ForReading)
 Do While Not File.AtEndOfStream
 '##################################################
 'Find User Count and add 1 e.g Count=3 now Count=4
 '##################################################
 Select Case Counter
 Case 1:
 File.Skip(6)
 User = File.read(1)
 BeeTime = User + 1
 Gem = (Gem & "Count=" & BeeTime)
 Case Else
 '#####################################
 'Look for ;! identifier and add User#=username
 '#####################################
 F = File.Readline()
 if F = ";!" Then
 Timmy = ("User" & User & "=" & Username & vbCrLf & ";!") 'add variable here
 Gem = (Gem & Timmy & vbCrLf)
 Else
 Gem = (Gem & F & vbCrLf)
 End if
 End Select
 Counter = Counter + 1
 Loop
 Set NewFs = CreateObject("Scripting.FileSystemObject")
 Set Newfile = NewFs.OpenTextFile(newpath, ForWriting)
 '########################################################################
 'Gem now holds the entire edited file write from EzMTS.User to EzMTS.txt
 '########################################################################
Newfile.Write(gem)
 'Response.Write(Gem)
 
 File.Close() 
 NewFile.Close()
 Set NewFs = CreateObject("Scripting.FileSystemObject") 
 Set NewFile = NewFs.OpenTextFile(NewPath, ForAppending)
 '#####################################
 'Append Username=Password to the end of the EzMTS.txt file
 '#####################################
 NewFile.WriteLine(Username & "=" & Password) 'add variables here
 NewFile.Close
 %>
 <%
 '##################################################################
 'Reaname EzMTS.User to EzMTS.old & reaname EzMTS.txt to EzMTS.User
 'In case any goes wrong you can edit this to store old versions of the 
 'User file to try and recover lost information should it happen.
 '##################################################################
 Set objFSO = CreateObject("Scripting.FileSystemObject")
 objFSO.MoveFile "C:\EzMTS\EzMTS.User" , "C:\EzMTS\EzMTS.Old"
 Set objFSO = CreateObject("Scripting.FileSystemObject")
 objFSO.MoveFile "C:\EzMTS\EzMTS.txt" , "C:\EzMTS\EzMTS.User"
 %>


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

7/25/2003 11:36:24 PM

i have no comment about the codes you've been shared, the codes was great. i just want to know is how could i receive the e-mail through asp pages...i have windows2000 server....i'm a beginner, i just want to know about...thanks for your support and for your response....may the Lord bless you always....
(If this comment was disrespectful, please report it.)

 
10/2/2003 10:40:04 AMBrian Battles WS1O

Anyone know how to do this with CDONTS? I'd like to allow users to register for their own e-mail "aliases" on my Web site...eg, if I run blah.com, let my users have e-mail sent to name@blah.com and have then have my server forward their e-mail to their "real" e-mail address. My Web server runs Windows Advanced Server 2000 with Microsoft Exchange 2000. Any ideas? Thanks!
(If this comment was disrespectful, please report it.)

 
2/10/2005 2:41:49 AM

Great code! I dont personally use EzMTS but you've covered the filesystem object use really well! it should help anyone trying to figure out how to read,write or append!
(If this comment was disrespectful, please report it.)

 
10/15/2006 12:15:11 PMRahul

Excellant Codes for Learning....
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.