1. Home
  2. Knowledge Base
  3. GMS
  4. How do I set up a free email registration webpage in MML?

How do I set up a free email registration webpage in MML?

Answer

There are many ways that email accounts can be created in GMS. For example:

  • Using Gordano’s MML to create accounts (see below);
  • Using ASP pages from Microsoft’s IIS;
  • Using COM from any windows application;
  • Using the "AddUser" utility.

Here we will illustrate how Gordano’s MML can be used to create an email registration page.


The MML below, in conjunction with image exclaim.gif, is meant to be used within a form on your webpage to allow users to create their own email accounts on your server. Currently the script gives a 20 second delay before automatically sending the user to a GLWebMail interface.

You MUST change the URL information to be that of your own server in the script. You will also need to change the domain, username and password for the admin privileges required to add a user. If this is someone other than
postmaster, the script will still work. Incorrect values return errors.

There are 2 parts to the information below. The first section is the registerprocess.mml and the second part is register.mml – please be sure to use the 2 seperate pieces of code in their intended sections or problems will occur.

The following top section of code should be saved as a file called RegisterProcess.mml and saved to the gordanomml directory.

<#
    /* This program, in conjunction with register.mml and the image exclaim.gif, */
    /* is meant to be used within a form on your webpage to allow users to create */
    /* their own email accounts on your server.  Currently the script gives a 20 sec. */
    /* delay before automatically sending the user to a GMS Webmail interface. You */
    /* MUST change the URL information to be that of your own server or the script */
    /* As well, you will need to change the domain, username and password for the */
    /* admin privilages required to add a user.  If this is someone other than */
    /* postmaster, the script will still work.  Incorrect values return errors. */
    /* This code is copyright Gordano Ltd and was commented by Judith Lewis */
#>
<#
    if (action == " Add Account ")
    {
        /* This checks to see if the fields are all filled in otherwise it returns an error */
        if (EmailAddress != "" && Password != "" && ConfirmPassword != "")
        {
            account = ConvertToUser(EmailAddress);
            domain = ConvertToDomain(EmailAddress);

            /* this checks to ensure the domain used exists on your system */
            if (ExistDomain(domain))
            {
                /* this checks to see if the account name is valid according to your security settings */
                if (IsValidUserName(account))
                {
                    /* checks to ensure account does not already exist */
                    if (!ExistUser(account, domain))
                    {
                        /* checks to see if the password is valid according to your settings */
                        if (IsValidPassword(Password))
                        {
                            /* checks to ensure that the two passwords entered match */
                            if (ConfirmPassword == Password)
                            {
                                addOK = FALSE;

                                /* This is where the administrator domain, username and password must be entered. */

                                AddSession ("john.dom\postmaster","password1");

                                if (AddUser(account, domain, password))
                                {
                                    /* Sets user details */
                                    #domain##account#Fullname = FullName;
                                    /* Sets a maximum account size of 10 MB for total size of all folders in the created account */
                                    #domain##account#MaxAccountSize = 10240;
                                    addOK = TRUE;
                                }
                                /* This is where the administrator is logged off no matter what happens */
                                DelSession();

                                if (addOK)
                                {
                                    /* This provides space for your logo and a welcome message you can change */
                                    WarningMsg = "<img src="glwlogo.gif"><p>Welcome to " & domain & ".<br>Your account has been set up and is available for use. <br> We will now take you to the WebMail interface.";
                                    sendtowebml = "<meta http-equiv="refresh" content="5; URL=http://localhost:9000/index.mml">";
                                }
                                else
                                {
                                    WarningMsg = "<img src="exclaim.gif">   An unknown error occured - failed to add the user.";
                                }
                            }
                            else
                            {
                            	WarningMsg = "<img src="exclaim.gif">   Your password confirmation failed - please try again.";
                            }
                        }
                        else
                        {
                            WarningMsg = "<img src="exclaim.gif">   Your password is invalid.<br>We require for security reasons that your password be at least 5 characters long.";
                        }
                    }
                    else
                    {
                        WarningMsg = "<img src="exclaim.gif">   A user with this name already exists.";

                        /* Test some other account names to offer as alternatives */
                        testAccount = account & "1";
                        if (!ExistUser(testAccount, domain))
                        {
                            WarningMsg = WarningMsg & "<br>The account " & ConvertToEmailAddress(testAccount, domain) & " is available for use.";
                        }
                    }
                }
                else
                {
                    WarningMsg = "<img src="exclaim.gif">   The account name provided is invalid.";
                }
            }
            else
            {
                WarningMsg = "<img src="exclaim.gif">   The domain " & domain & " does not exist on this server.";
            }
        }
        else
        {
            WarningMsg = "<img src="exclaim.gif">   You must supply all of the details.";
        }
    }

    include "/register.mml";
#>

The following bottom section of code should be saved as a file called Register.mml and saved to the gordanomml directory.

<html>
<title>Signup Now!</title>
<#
    /* This code adds the redirect to the GMS Webmail page only if the addition of a user is successful */
    if (sendtowebml != "")
    {
print(sendtowebml);
    }
#>

<body bgcolor=white font=arial style="TEXT-DECORATION: NONE" text=black vlink=gold alink=red link=silver leftmargin=0>
<#
    /* This will show any warnings, including a successful add os a new user to the customer */
    if (WarningMsg != "")
    {
#>
        <center><font size=4 color=crimson face=Arial><# print(WarningMsg); #></font></center><p>
<#
    }

	if (sendtowebml == "")
	{
#>

<!- font scheme has been left neutral to allow you to change this page to suit your environment ->

<center><font size=4 color=slategray face=comic sans MS>Create a new account</font></center><p>
<center>

<form action="registerprocess.mml" method="post">
    <table width=100%>
        <tr><td nowrap align=right><font face="arial" size=2>Your Full Name</font></td><td><font face="arial" size=3><INPUT name="FullName" size=20></font></td></tr>
        <tr><td nowrap align=right><font face="arial" size=2>Email Address</font></td><td><font face="arial" size=3><INPUT name="EmailAddress" size=20></font></td></tr>
        <tr><td nowrap align=right><font face="arial" size=2>Password</font></td><td><font face="arial" size=3><input name="password" size=20 type=password></font></td></tr>
        <tr><td nowrap align=right><font face="arial" size=2>Confirm Password</font></td><td><font face="arial" size=3><input name="confirmpassword" size=20 type=password></font></td></tr>
        <tr><td colspan=2 align=center><font face="arial" size=2><br><input name="action" type="submit" value=" Add Account "></td></tr>
    </table>
</form>
</center>
<#
	}
#>
</body>
</html>

NOTE: Gordano do not support the debugging or writing of MML scripts.

See Also:

Keywords:mml registration free automatic hotmail

Was this article helpful?

Related Articles

Contents

Need Support?

Can't find the answer you're looking for?
Contact Support