setting up e-mail accounts using cgi script

Hi,
   Is it possible to set up an e-mail account through a cgi script ? If so how ? System will be on UNIX O.S. If you need any further information, please ask.

Thanks in advance
somiyaAsked:
Who is Participating?
 
mouattsConnect With a Mentor Commented:
It is but you don't want to do it within a CGI for a couple of reasons both of which concern security.

Firstly a CGI should always be run in an account with few privilages (often as nobody) so that any hack can't do to much damage. But to create an email account requires greater privilages and therefore the CGI can't do it.

Secondly by repeatedly hitting the CGI thousands of Email accounts could be created and thus killing you email system. Now you can avoid this by ensuring that each CGI call must be unique by including a non-predictive parameter within the call.

The only way in which you can really safely automate this is and overcome the lack of privilages is to have either a daemon program or a batch program that accepts the request from the CGI or from a file modified by the batch file and allow this program to create the entries within the email system. This program should be able to detect when excessive request have been made to prevent a DOS attack on your mail system.

How this final bit is done depends on the mail server involved and you will need to determine the command sequence needed depending on you mail server or directory server.

I would suggest that unless you anticpate doing a large number of accounts the better way would be simply email a webmaster and set the account up manually.

Sorry to be a bit negative but what you ask is not without significant problems.

Steve
0
 
somiyaAuthor Commented:
Thanks a lot for that. The System will be on UNIX server and it is absolutely essential to set up the account through the script itself as this has to be done immediately on submission of form. So how do you suggest this should be done. What will the actual code in the CGI script be ? If you can guide me on this I will be happy.

Thanks in advance
0
 
mouattsCommented:
Basically you need to execute whatever command(s) that you would need to execute from the command prompt to create the account.


If this is a single command then the simplest way would be to form the command string with any parameters and then execute
the system command (in perl or C).

If there are more commands required then you will need to write the commands to a file as a script and then execute the script using the system command.

Now if you CGI is restricted as it should be then the execution will fail. Therefore you would need to have another program running that monitors for the creation of the file and when it sees it executes it.

The alternative is that the CGI communicates with such a program via pipes to transmit the data to the other program which executes the command(s).

The actual code depends on what language is involved and what commands are needed to create the account. I would suggest that if you can workout the commands to create the account then it wouldn't be too differcult to work the rest of it out.

Steve
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.