Domain and User not activating

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
Post Reply
New user
New user
Posts: 1
Joined: 2020-11-09 04:47

Domain and User not activating

Post by Gonz182211 » 2020-11-09 04:55

Apologies as I am new to hmailserver. I have the following script which works apart from both the Domain and User Accounts do not activate. I can see they are both created however, they do not activate and currently require me to use the GUI and enable the check box.
Below is my script. Any input regards my finger fault greatly appreciate. I can't see the tress for the forest.

Code: Select all

Dim hmail, domain, account, email, noOfDomains, userName, userPassword, domainName, hMailAdminAccount, hMailAdminPassword

' These are the hMail admin account defaults after a silent install
hMailAdminAccount = "Administrator"
hMailAdminPassword = "myenteredpasswordgoeshere"

' Check for account details from command line
If Wscript.Arguments.Count <> 3 Then
    WScript.Quit 1
End If

userName = Wscript.Arguments(0)
userPassword = Wscript.Arguments(1)
domainName = Wscript.Arguments(2)
'msgbox userName & " / " & userPassword & " @ " & domainName,0,"Input params"
email = userName & "@" & domainName

' Get connection to hMailServer
Set hmail = CreateObject("hMailServer.Application")
hmail.Authenticate hMailAdminAccount,hMailAdminPassword

' Check whether domain already exists
noOfDomains = hmail.Domains.Count
domainExists = false
if noOfDomains > 0 then
	for i = 0 to noOfDomains-1
		set domain = hmail.Domains.Item(i)
		if domain.Name = domainName then
			domainExists = True
			exit for
		end if
end if

' Create domain if it does not yet exist
if domainExists = false
	Set domain = hmail.Domains.ItemByName(domainName)
	domain.Active = True
end if

' Check whether account already exists
Set accountList=domain.Accounts
noOfAccount = accountList.Count
accountExists = false
if noOfAccount > 0 then
	for i = 0 to noOfAccounts
		Set account = accountList.Item(i)
		if account.Address = email then
			accountExists = True
			exit for
		end if
end if

' Create account if it does not yet exist
if accountExists = false
	Set account = hmail.Accounts.Add
	account.Active = True
        account.MaxSize = 100 ' Allow max 100 megabytes
end if

User avatar
Posts: 8917
Joined: 2011-09-08 17:48

Re: Domain and User not activating

Post by jimimaseye » 2020-11-09 10:56

You haven't included domains.add inn the creation of the domain in the 'domainExists = false' section.

[Entered by mobile. Excuse my spelling.]
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs :

Post Reply