Let Users create their own accounts (Upgraded for 4.3)

This section contains scripts that hMailServer has contributed with. hMailServer 4 is needed to use these.
User avatar
linksys7
New user
New user
Posts: 10
Joined: 2008-10-07 12:16

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by linksys7 » 2008-10-08 13:41

I get no Warnings but this doesnt mean it won't for someone elses setup, Im using a windows xp machine to run apache, and mysql database is on another machine running Windows Vista 64bit. I dont think it should be much different though from a linux/apache config or anything simular.
But any how I added some changes to the script by taking the configs in the head of the script and placed them in a seperate folder with an .htaccess for better security. there is a readme file for the reCaptcha section because you need two key codes for it and you can get it for free but its Domain Specific , so I couldn't include my key codes. Plus added a few comments on which file to add the databse info to. Give it a try and see what you think.
See attached........
Attachments
htmail-signup.zip
(3.94 KiB) Downloaded 1264 times
Image

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by ^DooM^ » 2008-10-08 15:19

Nice job. Thanks for sharing.
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

ninostar
New user
New user
Posts: 11
Joined: 2008-09-11 08:35

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by ninostar » 2008-10-30 19:16

First thanks for uploading the script... it's great.

I've tried to upload the file and I've opened the account at recaptcha.net, however I always get error message:
The security words weren't entered correctly. Go back and try it again.(reCAPTCHA said: Incorrect Answer!)

I just can't open email account, because I always get that email message - is something wrong in script?!

;)

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by ^DooM^ » 2008-10-30 22:47

Did you download the keys?
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

ninostar
New user
New user
Posts: 11
Joined: 2008-09-11 08:35

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by ninostar » 2008-10-31 09:56

Yes and I inserted both keys in the file...
^DooM^ wrote:Did you download the keys?

User avatar
linksys7
New user
New user
Posts: 10
Joined: 2008-10-07 12:16

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by linksys7 » 2008-11-02 04:20

ninostar wrote:First thanks for uploading the script... it's great.

I've tried to upload the file and I've opened the account at recaptcha.net, however I always get error message:
The security words weren't entered correctly. Go back and try it again.(reCAPTCHA said: Incorrect Answer!)

I just can't open email account, because I always get that email message - is something wrong in script?!

;)
WoW , I must of been out of it when I posted that , sorry guys... I've fixed it try it now and let me know.
I seemed to have had that problem too, and Im sorry I didnt fix it till afterwards, This will occur if the <form> tags aren't outside of the table. It causes an html error in some browsers with the captcha. Ive fixed the signup and repackaged it here to download. I also added the php API for the reCaptcha in this package since in the previous one I didnt think to put it in the .Zip. I also added a small section of CSS to do themes for the reCaptcha , so it better blends in with your webpages. options are listed in the signup.php file.. It gives you color options for "red" "white""blackglass""clean" and "custom" which allows you to change the way it looks for your website.
Attachments
hmail-signup.zip
(7.63 KiB) Downloaded 1289 times
Image

ninostar
New user
New user
Posts: 11
Joined: 2008-09-11 08:35

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by ninostar » 2008-11-02 17:46

Hi,

I'm sorry to say, but I've uploaded your new files and now I can create accounts with right or with wrong entered recaptcha code... :oops: I've been reading a little bit about recaptcha and I don't hava an idea what could be wrong?! Well, I'm not too much into php, so I feel like Alice in wonderland hehehe

I hope you will be able to fix this... ;)

User avatar
linksys7
New user
New user
Posts: 10
Joined: 2008-10-07 12:16

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by linksys7 » 2008-11-03 05:32

ninostar wrote:Hi,

I'm sorry to say, but I've uploaded your new files and now I can create accounts with right or with wrong entered recaptcha code... :oops: I've been reading a little bit about recaptcha and I don't hava an idea what could be wrong?! Well, I'm not too much into php, so I feel like Alice in wonderland hehehe

I hope you will be able to fix this... ;)
I have double checked the script and found no errors in the code.
I am sorry but this is a reCaptcha flaw, I have researched the problem and it would seem that because they scan books for words and they are digitized they can be off from time to time. I have added a couple of urls here so you or anyone else would like to better understand it.

http://wiki.recaptcha.net/index.php/FAQ ... rect_words
http://groups.google.com/group/recaptch ... 8d75ff9f6#

If I get some time I might look into a different method but not positive on that. reCaptcha is the most secure out there.
Image

User avatar
linksys7
New user
New user
Posts: 10
Joined: 2008-10-07 12:16

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by linksys7 » 2008-11-03 08:48

Ok guess what? Yup I got another one with a different captcha, this one is explicit , you have to have every entry correct or it wont pass. A little different in the design too. Just unzip the files and go to "inc/config.inc.php" and edit the configurations and thats it.
This one does not require you to register for key codes!!

Image


See attached for file:
Attachments
hmail-signupV2.zip
(28.25 KiB) Downloaded 1754 times
Image

desiredforsome
New user
New user
Posts: 7
Joined: 2009-02-06 04:43

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by desiredforsome » 2009-02-06 04:55

This is a script i been looking for ,,,, HOW DO I USE THIS THOUGH?

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by ^DooM^ » 2009-02-06 11:48

Try reading the thread.
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

desiredforsome
New user
New user
Posts: 7
Joined: 2009-02-06 04:43

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by desiredforsome » 2009-02-07 03:59

Let me just say i have never really messed wit IIS and PHP,

How do i get this installed on IIS6 and browse it and make it work Becuase i am unabel to just open the .php file in IE or FIrefox and get it ot work.

Pleae Help

I need dummy instrucitons

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by ^DooM^ » 2009-02-07 11:40

Well unfortunately you will not get dummy instructions here.

Google IIS install then read this for instructions on how to install php

It's really not that hard.
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

desiredforsome
New user
New user
Posts: 7
Joined: 2009-02-06 04:43

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by desiredforsome » 2009-02-07 20:29

I have php installedand IIS, but i need to know where i actualy pu these files do i just put them in the directory and go to http:\\localhost\signup.php

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by ^DooM^ » 2009-02-07 22:14

only if you know your mysql access details.
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

desiredforsome
New user
New user
Posts: 7
Joined: 2009-02-06 04:43

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by desiredforsome » 2009-02-07 22:21

I got it working i used XAMPP it works great however, what do i have to chagne in the PHP file for it to access MYSQL database it says it cannt access the database and to contact administrator, Im not a PHP programmer but i could adjust the settings, or what is it default programmed to.


Thanks

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by ^DooM^ » 2009-02-08 01:14

You need to alter the settings at the top of the php file with a text editor like notepad ( do not use word ) to match your MySQL login details.
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

desiredforsome
New user
New user
Posts: 7
Joined: 2009-02-06 04:43

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by desiredforsome » 2009-02-08 05:08

I have changed the following lines under //connect to database using information from above and below it. IT shows me web mail at the signup page but it says.

"Database error, unable to add account. Please contact your administrator! Field 'accountadminlevel' doesnt have a default value

what do i do?

desiredforsome
New user
New user
Posts: 7
Joined: 2009-02-06 04:43

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by desiredforsome » 2009-02-09 06:09

I belive i have gotton through most of my troubles, I dont understand why i am having so many.


What do i do about this. now

I "nulled" out all errors i was getting about not having fields for them and i have come to the end of this

Incorrect integer value: '' for column 'accountdomainid' at row 1

I have no idea what to do on this What do i change something to?

I so confused thanks in advance.

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by ^DooM^ » 2009-02-09 10:39

If at first you don't succeed, bomb disposal probably isn't for you! ヅ

tucubogdan
New user
New user
Posts: 8
Joined: 2009-03-10 09:04

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by tucubogdan » 2009-03-10 09:07

I am having trouble with the script. i tried al 3 that were posted on this topic.
But when i try to register a test account and see if it works i get this

Database error, unable to add account. Please contact your administrator!
Field 'accountadminlevel' doesn't have a default value

I tried MyRoundCube as well, the same error.
Can someone help me please

thanks

edit, forgot to tell you that i am using external mysql databese. version 5.1

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by ^DooM^ » 2009-03-10 10:41

Sounds like you have Strict mode enabled in MySQL. These scripts are not strict mode compliant.
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

tucubogdan
New user
New user
Posts: 8
Joined: 2009-03-10 09:04

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by tucubogdan » 2009-03-10 10:43

^DooM^ wrote:Sounds like you have Strict mode enabled in MySQL. These scripts are not strict mode compliant.
i've red about that, where exactly do i turn it off

thanks for the fast reply

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by ^DooM^ » 2009-03-10 10:54

Disclaimer: I have never tried any of these methods so on your own head be it ;)

p.s. Google is your friend!!!

Method 1:
Dump the database, uninstall MySQL and re-install making sure to un-tick the strict mode check box on install, then import the database.

Method 2:
Open the "my.ini" file within the MySQL installation directory and look for something like...
# Set the SQL mode to strict
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

Replace with:
# Set the SQL mode to strict
sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

Restart MySQL Service.

Method 3:
You may be able to run an SQL query within your database management tool such as phpMyAdmin which can normally be found from your web hosting control panel:

SET @@global.sql_mode= '';

Restart MySQL Service.
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

tucubogdan
New user
New user
Posts: 8
Joined: 2009-03-10 09:04

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by tucubogdan » 2009-03-10 17:26

method #2 did the trick, thank you very much. i appreciate it

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by ^DooM^ » 2009-03-10 18:48

Glad you got it sorted :)
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

User avatar
(:Pro:)
New user
New user
Posts: 15
Joined: 2009-10-14 14:36
Location: Moscow
Contact:

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by (:Pro:) » 2009-10-14 16:34

Code: Select all

Database error, unable to add account. Please contact your administrator!
Field 'accountadminlevel' doesn't have a default value
=( help.
Suffer, I use online a translator =)

tucubogdan
New user
New user
Posts: 8
Joined: 2009-03-10 09:04

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by tucubogdan » 2009-10-14 16:38

(:Pro:) wrote:

Code: Select all

Database error, unable to add account. Please contact your administrator!
Field 'accountadminlevel' doesn't have a default value
=( help.
try step #2, that worked for me, it should work for you too

User avatar
(:Pro:)
New user
New user
Posts: 15
Joined: 2009-10-14 14:36
Location: Moscow
Contact:

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by (:Pro:) » 2009-10-14 16:45

tucubogdan wrote:
(:Pro:) wrote:

Code: Select all

Database error, unable to add account. Please contact your administrator!
Field 'accountadminlevel' doesn't have a default value
=( help.
try step #2, that worked for me, it should work for you too
o_O that? mmm may be because I use version 5.2.1 = (I the fool...
Suffer, I use online a translator =)

tucubogdan
New user
New user
Posts: 8
Joined: 2009-03-10 09:04

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by tucubogdan » 2009-10-14 17:08

i still use 5.1.2 and i had the same problem, don't you read the posts that have been made?

User avatar
(:Pro:)
New user
New user
Posts: 15
Joined: 2009-10-14 14:36
Location: Moscow
Contact:

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by (:Pro:) » 2009-10-14 19:32

As to solve this problem?
Suffer, I use online a translator =)

tucubogdan
New user
New user
Posts: 8
Joined: 2009-03-10 09:04

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by tucubogdan » 2009-10-14 20:25

(:Pro:) wrote:As to solve this problem?
dude, just take 10 minutes of your busy schedule and read a few post up, you will see the solution to this

User avatar
(:Pro:)
New user
New user
Posts: 15
Joined: 2009-10-14 14:36
Location: Moscow
Contact:

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by (:Pro:) » 2009-10-14 21:52

:oops: sorry. I will tray it.
Suffer, I use online a translator =)

User avatar
(:Pro:)
New user
New user
Posts: 15
Joined: 2009-10-14 14:36
Location: Moscow
Contact:

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by (:Pro:) » 2009-10-14 22:32

:P It`s working!!!
Suffer, I use online a translator =)

tucubogdan
New user
New user
Posts: 8
Joined: 2009-03-10 09:04

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by tucubogdan » 2009-10-14 23:34

(:Pro:) wrote::P It`s working!!!
was it hard to read a little?

User avatar
(:Pro:)
New user
New user
Posts: 15
Joined: 2009-10-14 14:36
Location: Moscow
Contact:

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by (:Pro:) » 2009-10-15 09:19

tucubogdan wrote:
(:Pro:) wrote::P It`s working!!!
was it hard to read a little?
Yes, it`s hard, i am from Russia :P
Suffer, I use online a translator =)

tucubogdan
New user
New user
Posts: 8
Joined: 2009-03-10 09:04

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by tucubogdan » 2009-10-15 18:15

sorry

User avatar
travelback
New user
New user
Posts: 11
Joined: 2010-04-17 13:53
Contact:

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by travelback » 2010-04-19 00:03

Is there an option for those of us running MSSQL? or would it be easier just to switch back to MySQL? It almost seems pretty straight forward to change the signup.php code to make it work.

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by ^DooM^ » 2010-04-19 00:53

If you are using this with V5 it won't work unless you also add an IMAP inbox line, that's why this script is in the V4 section.
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

User avatar
travelback
New user
New user
Posts: 11
Joined: 2010-04-17 13:53
Contact:

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by travelback » 2010-04-19 01:30

I thought I had read someone got it to work with 5.1 or something. I figured I could use the script as a basis and build from that what I needed... or head over to scriptlance.com if I ran into issues. Eventually I'd like to have it integrated into a website and the whole deal - just don't have the time.

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by ^DooM^ » 2010-04-19 02:01

If at first you don't succeed, bomb disposal probably isn't for you! ヅ

user100
New user
New user
Posts: 7
Joined: 2010-08-06 14:36

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by user100 » 2010-09-02 14:21

I know this topic is kinda old but since I was following it and tried it I got an error.

"Error while selecting data: Table 'hmailserver.hm_domains' doesn't exist".

Can someone help me solve it?


Thanks.

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by ^DooM^ » 2010-09-02 14:48

looks like either a permissions issue on the SQL server or you are connecting to the wrong SQL server or the database is not called hmailserver.
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

user100
New user
New user
Posts: 7
Joined: 2010-08-06 14:36

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by user100 » 2010-09-02 15:45

Thanks. I tried it again, unfortunately I deleted my old hmail database when I tried out the "Database setup" but I made a new one and it worked. Only I get a new error/warning:

Code: Select all

Warning: mail() [function.mail]: SMTP server response: 530 SMTP authentication is required. in C:\directory\mail\hmail\signup.php  on line 84

Warning: mail() [function.mail]: SMTP server response: 530 SMTP authentication is required. in C:\directory\mail\hmail\signup.php on line 97
Checking the file it says something to do with:

Code: Select all

84: mail("{$_POST['user']}@$strDomain", "$subject", "$message", "From: $admin_email"); //Send welcome message 
97: mail($admin_email, "$admin_mail_subject", "$admin_mail_message", "From: $admin_email"); 
But it can create accounts now so that is good. :)

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by ^DooM^ » 2010-09-02 18:04

that script does not authenticate, so you need to allow those mails through without authentication or if you dont want the script to send out emails just comment out those 2 lines. If you do want the emails let me know if the script is on the same server as hmail or not.
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

user100
New user
New user
Posts: 7
Joined: 2010-08-06 14:36

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by user100 » 2010-09-03 02:25

Yes the script is on the same server as hmail. And yes I would like to use it. I would like to know which account subscribed and signed up. If there is any other way to do it, like into a text file or some sort of statistics than that would be fine too.

Also I would like to remove the Captcha, how can I do that?

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by ^DooM^ » 2010-09-03 11:08

Goto the admin and select IP ranges
click on MyComputer
Change the priority to 30
Untick Require auth for all

Captcha was added later, check out the earlier scripts in the thread that do not have captcha.

I would suggest however that you leave captcha in if you are allowing the public to signup to stop spammers abusing your server.
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

user100
New user
New user
Posts: 7
Joined: 2010-08-06 14:36

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by user100 » 2010-09-03 12:20

Ok I did that but I still get the error.

The captcha is barely readable though, especially now when I am testing.
I tried the other script but got some more errors so I quickly swapped back. It nearly broke it.

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by ^DooM^ » 2010-09-03 12:47

if you still have the error then you are attempting to send from an account that doesn't exist on hmail.
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

user100
New user
New user
Posts: 7
Joined: 2010-08-06 14:36

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by user100 » 2010-09-03 14:33

Alright I just deleted the notification for the admin and blanked out line 84 and now it works.

Not exactly as I wanted but it will do.

Thanks.

Extremist
Normal user
Normal user
Posts: 39
Joined: 2010-10-10 13:49
Location: Russian Federation
Contact:

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by Extremist » 2010-10-25 19:24

use this code

Code: Select all

<?php 

//SINGLE DOMAIN SIGNUP
//---------------------------------------

//MySQL Information:
$mysql_host = "localhost"; //Host Name
$mysql_user = "***"; //Username
$mysql_pass = "***"; //Password
$mysql_db = "hmail"; //Database

//General Configuration:
$form_title = "signup"; //Name for this form
$account_max = "10000000";  //Maximum size per account (1000000 = 1MB -> Do not uses spaces or commas!)

$admin_notify = 1; //1 = yes & 0 = no
$admin_email = "admin@oldgamer.org"; //Administrators email to send notifications)
$admin_default_activate = 1; //1 = yes & 0 = no -> If no, the administrator has to authorise the account
$encryption = 2; //Password encryption level

$url = $_SERVER["HTTP_HOST"];
$domain = $_SERVER["HTTP_HOST"];

if (substr($domain,0,4) == "www.")
        {
                $domain = strstr($domain, ".");
                $domain = substr($domain, 1);
        }

// Protect the Database and MD5 the password. 
$strName    = addslashes( $_POST['name'] ); 
$strUser    = addslashes( $_POST['user'] ); 
$strDomain  = addslashes( $_POST['domain'] ); 
$strPass1   = addslashes( $_POST['pass1'] ); 
$strMD5Pass = md5( $strPass1 ); 

error_reporting(E_ALL ^ E_NOTICE); 
//Next two lines connect to database using information from above. 
$open = mysql_connect($mysql_host, $mysql_user, $mysql_pass); 
$select = mysql_select_db($mysql_db); 

IF (!$open || !$select) 
{ 
    echo "Unable to open database, contact your administrator!"; 
} 
ELSE 
{ 
    echo "<font size=\"+2\">$form_title</font><br><br>"; //Display form title from above 
    //Decide On What Path To Take 
    SWITCH ($_GET['mode']) 
    { 
    CASE "do": 
        //#### PAGE IF FORM FILLED OUT ####// 
        $q=mysql_query("SELECT * FROM `hm_domains` WHERE `domainid` = '{$strDomain}' LIMIT 1"); //Load Domain Into memory (internal use) 
        WHILE ($v=mysql_fetch_array($q)) 
        { 
            $temp_domain = $v['1']; 
        
        } //Apply information 

        $q2=mysql_query("SELECT * FROM `hm_accounts` WHERE `accountaddress` = '{$strUser}@$temp_domain' LIMIT 1"); //Check if account exists 
        $v2=mysql_num_rows($q2); //Gets number of accounts that exist with that profile (should be less than or equal to one) 
        
        IF ($v2 == 1) 
        { 
            echo "A user with this username already exists! <a href=\"javascript:history.go(-1)\">Go Back</a>"; 
        } 
        ELSE 
        { 
            IF (!$_POST['pass1'] || !$_POST['pass2']) 
            { 
                echo "You did not enter both passwords! <a href=\"javascript:history.go(-1)\">Go Back</a>"; 
            } 
            ELSEIF ($_POST['pass1'] <> $_POST['pass2']) 
            { 
                echo "Your passwords do not match! <a href=\"javascript:history.go(-1)\">Go Back</a>"; 
            } 
            ELSE 
            { 
                $q3=mysql_query("INSERT INTO `hm_accounts` (`accountdomainid`,`accountaddress`,`accountpassword`,`accountactive`,`accountisad`,`accountmaxsize`,`accountpwencryption`) VALUES ('$strDomain','$strUser@$temp_domain','$strMD5Pass','$admin_default_activate','0','$account_max','$encryption')") or die(mysql_error()); 
            } 
        } 
        
        IF ($q3) 
        { 
            IF ($admin_default_activate == 0) 
            { 
                echo "Your account has been created <b>however requires administrator activation.</b> You should receive a message soon regarding this."; 
            } 
            ELSE 
            { 
                echo "Your account has been created and is ready for use!<br><br>Username: $strUser@$temp_domain<br><br>Webmail: <a href=\"$serv_webmail/mail\">www.$temp_domain/mail</a><br>POP3: mail.$temp_domain<br>IMAP: mail.$temp_domain<br><br>SMTP: mail.$temp_domain"; 
                $subject = "Welcome To MYWEBSITE!";
                $message = "This is confirmation that your account has been created."; 

                mail("{$_POST['user']}@$temp_domain", $subject, $message); //Send welcome message 
            } 
        } 
        ELSE 
        { 
            echo "Database error, unable to add account. Please contact your administrator!"; 
        } 

        IF ($admin_default_activate == 0 && $admin_notify == 0) 
        { 
            $admin_mail_subject = "Account Requires Activation!"; 
            $admin_mail_message = "{$_POST['user']}@$temp_domain has been created by {$_POST['name']} and needs to be activated!"; 
            mail($admin_email, $admin_mail_subject, $admin_mail_message); 
        } 
        ELSEIF ($admin_default_activate == 1 && $admin_notify == 1) 
        { 
            $admin_mail_subject = "New Account Created!"; 
            $admin_mail_message = "{$_POST['user']}@$temp_domain has been created by {$_POST['name']}!"; 
            mail($admin_email, $admin_mail_subject, $admin_mail_message); 
        } 
        ELSEIF ($admin_default_activate == 1 && $admin_notify == 1) 
        { 
            $admin_mail_subject = "New Account Created!"; 
            $admin_mail_message = "{$_POST['user']}@$temp_domain has been created by {$_POST['name']}!"; 
            mail($admin_email, $admin_mail_subject, $admin_mail_message); 
        } 
        ELSEIF ($admin_default_activate == 0 && $admin_notify == 1) 
        { 
            $admin_mail_subject = "New Account Created!"; 
            $admin_mail_message = "{$_POST['user']}@$temp_domain has been created by {$_POST['name']}!"; 
            mail($admin_email, $admin_mail_subject, $admin_mail_message); 
        } 
        break; 
    
    DEFAULT: 
    } 
} 

//#### MAIN PAGE IF FORM NOT FILLED OUT ####// 
echo " 
<form action=\"?mode=do\" method=\"POST\">
Your Name: <input type=\"text\" name=\"name\" size=\"21\"><br> 
E-Mail: <input type=\"text\" name=\"user\" size=\"21\"> @ <select name=\"domain\"> 
"; 

$q2=mysql_query("SELECT * FROM `hm_domains` WHERE `domainactive` = '1' ORDER BY `domainname` DESC"); //Load avaliable domains into memory 
WHILE ($v2=mysql_fetch_array($q2)) //Display avaliable domains 
{ 
    echo "<option value=\"{$v2['0']}\">$domain</option>";
} 

echo " 
</select><br> 
Password: <input type=\"password\" name=\"pass1\" size=\"21\"><br> 
Password: <input type=\"password\" name=\"pass2\" size=\"21\"> (For Confirmation)<br><br> 

<input type=\"submit\" value=\"Create Account\"> 
</form>
"; 
?>
after successful creating account, user logging to the mail and AfterLogic WebMail Pro interface popup this message

Code: Select all

Wrong email/login and/or password. Authentication failed.
But despite this message the new user to be in mail, somebody faced it?

Has asked a question at a forum of developers WebMail Pro, I look forward to hearing

Sovetryne
New user
New user
Posts: 19
Joined: 2011-07-11 08:38

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by Sovetryne » 2011-07-14 17:31

Sorry for resurrecting this old thread, but I just tried to change the database (via phpmyadmin), to give all users a subfolder called "spam". Adding this folder to everyone from within the database is a piece of cake, but I found out, that the folders are being recognized by hMailserver after it has been restarted.
I haven't had the time yet to test this script, but how's that with hMailserver, are the users being added "on the fly", or does hMailserver wait until the service has been restarted? Or does in "prune" all accounts, just like e.g. mDaemon does?

Albert

Bill48105
Developer
Developer
Posts: 6192
Joined: 2010-04-24 23:16
Location: Michigan, USA

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by Bill48105 » 2011-07-14 17:47

Sovetryne wrote:Sorry for resurrecting this old thread, but I just tried to change the database (via phpmyadmin), to give all users a subfolder called "spam". Adding this folder to everyone from within the database is a piece of cake, but I found out, that the folders are being recognized by hMailserver after it has been restarted.
I haven't had the time yet to test this script, but how's that with hMailserver, are the users being added "on the fly", or does hMailserver wait until the service has been restarted? Or does in "prune" all accounts, just like e.g. mDaemon does?

Albert
These scripts are for hmailserver 4.x.. Granted some might work but unless you are using 4.x odds are you are in the wrong place. :D
In terms of your question, odds are the better (proper) way to do it is via hmail's COM interface so hmail handles the database etc.
Bill
hMailServer build LIVE on my servers: 5.4-B2014050402
#hmailserver on FreeNode IRC https://webchat.freenode.net/?channels=#hmailserver
*** ABSENT FROM hMail! Those in IRC know how to find me if urgent. ***

Sovetryne
New user
New user
Posts: 19
Joined: 2011-07-11 08:38

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by Sovetryne » 2011-07-14 18:30

Bill48105 wrote:These scripts are for hmailserver 4.x.. Granted some might work but unless you are using 4.x odds are you are in the wrong place. :D
In terms of your question, odds are the better (proper) way to do it is via hmail's COM interface so hmail handles the database etc.
Bill
I have no idea if it's because English isn't my mother tongue, or that you are speaking in terms that I don't know (yet), but I am not sure what you mean with "odds".
I might try it do use hMailserver's COM interface, but how do I do that from within a PHP script?
I am running hMailserver 4.x by the way. The latest stable release, I found on the webpage :)

Albert

Bill48105
Developer
Developer
Posts: 6192
Joined: 2010-04-24 23:16
Location: Michigan, USA

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by Bill48105 » 2011-07-14 19:16

Sovetryne wrote:I have no idea if it's because English isn't my mother tongue, or that you are speaking in terms that I don't know (yet), but I am not sure what you mean with "odds".
I might try it do use hMailserver's COM interface, but how do I do that from within a PHP script?
I am running hMailserver 4.x by the way. The latest stable release, I found on the webpage :)

Albert
Ahh ok.

For COM check out the manual at:
http://www.hmailserver.com/documentatio ... om_objects
Or look at the PHPWebAdmin that comes with hmailserver which uses a lot of COM. (In hmailserver folder)

4.x is VERY VERY old. 5.3.3 is latest release, 5.3.4 is latest beta & 5.4 is latest alpha.
hMailServer build LIVE on my servers: 5.4-B2014050402
#hmailserver on FreeNode IRC https://webchat.freenode.net/?channels=#hmailserver
*** ABSENT FROM hMail! Those in IRC know how to find me if urgent. ***

User avatar
mattg
Moderator
Moderator
Posts: 22437
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by mattg » 2011-07-15 04:24

Sovetryne wrote:Sorry for resurrecting this old thread, but I just tried to change the database (via phpmyadmin), to give all users a subfolder called "spam". Adding this folder to everyone from within the database is a piece of cake, but I found out, that the folders are being recognized by hMailserver after it has been restarted.
I haven't had the time yet to test this script, but how's that with hMailserver, are the users being added "on the fly", or does hMailserver wait until the service has been restarted? Or does in "prune" all accounts, just like e.g. mDaemon does?
Some things are cached and a service restart will re-load those things.
What is cached has changed over the versions. Ver 5.0 was almost a re-write from ver 4.4 - lots of things changed
I think that accounts are not (were not) cached, but that folders were.

As bill says, using the COM API is best. That fixes cache issues too.
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

User avatar
yon
Normal user
Normal user
Posts: 129
Joined: 2009-11-06 10:44

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by yon » 2012-01-03 19:14

it is no work for hmail v5.4


Database error, unable to add account. Please contact your administrator!
Field 'accountadminlevel' doesn't have a default value
IPv6 Email Public Service www.ipv6china.com World's first

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by ^DooM^ » 2012-01-06 02:37

That's why it's in the hMail V4 section and not the V5 one
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

xpunac
Normal user
Normal user
Posts: 52
Joined: 2012-11-02 09:45

Re: Let Users create their own accounts (Upgraded for 4.3)

Post by xpunac » 2014-01-02 15:36

Can someone who knows PHP, see this code and tell whether it can be executed without errors?
The idea is to put in the database "INBOX" value in table "hm_imapfolders"
Thanks in advance!

Code: Select all

<?php

//MySQL Information:
$mysql_host = "localhost"; //Host Name
$mysql_user = ""; //Username
$mysql_pass = ""; //Password
$mysql_db = "hmailserver"; //Database

//General Configuration:
$form_title = "signup"; //Name for this form
$account_max = "10000000"; //Maximum size per account (1000000 = 1MB -> Do not uses spaces or commas!)

$admin_notify = 1; //1 = yes & 0 = no
$admin_email = ""; //Administrators email to send notifications)
$admin_default_activate = 1; //1 = yes & 0 = no -> If no, the administrator has to authorise the account
$encryption = 2; //Password encryption level

//DO NOT EDIT BELOW!//

// Protect the Database and MD5 the password.
$strName    = addslashes( $_POST['name'] );
$strUser    = addslashes( $_POST['user'] );
$strDomain  = addslashes( $_POST['domain'] );
$strPass1   = addslashes( $_POST['pass1'] );
$strMD5Pass = md5( $strPass1 );
$folderid=$use_number = ++$sequence_number . str_pad();
$folderaccountid=$strDomain;
$folderparentid="-1";
$foldername="INBOX";
$folderissubscribed="1";
$foldercreationtime=time();
$foldercurrentuid=rand();

error_reporting(E_ALL ^ E_NOTICE);
//Next two lines connect to database using information from above.
$open = mysql_connect($mysql_host, $mysql_user, $mysql_pass);
$select = mysql_select_db($mysql_db);

IF (!$open || !$select)
{
    echo "Unable to open database, contact your administrator!";
}
ELSE
{
    echo "<font size=\"+2\">$form_title</font><br><br>"; //Display form title from above
    //Decide On What Path To Take
    SWITCH ($_GET['mode'])
    {
    CASE "do":
        //#### PAGE IF FORM FILLED OUT ####//
        $q=mysql_query("SELECT * FROM `hm_domains` WHERE `domainid` = '{$strDomain}' LIMIT 1"); //Load Domain Into memory (internal use)
        WHILE ($v=mysql_fetch_array($q))
        {
            $temp_domain = $v['1'];
       
        } //Apply information

        $q2=mysql_query("SELECT * FROM `hm_accounts` WHERE `accountaddress` = '{$strUser}@$temp_domain' LIMIT 1"); //Check if account exists
        $v2=mysql_num_rows($q2); //Gets number of accounts that exist with that profile (should be less than or equal to one)
       
        IF ($v2 == 1)
        {
            echo "A user with this username already exists! <a href=\"javascript:history.go(-1)\">Go Back</a>";
        }
        ELSE
        {
            IF (!$_POST['pass1'] || !$_POST['pass2'])
            {
                echo "You did not enter both passwords! <a href=\"javascript:history.go(-1)\">Go Back</a>";
            }
            ELSEIF ($_POST['pass1'] <> $_POST['pass2'])
            {
                echo "Your passwords do not match! <a href=\"javascript:history.go(-1)\">Go Back</a>";
            }
            ELSE
            {
                $q3=mysql_query("INSERT INTO `hm_accounts` (`accountdomainid`,`accountaddress`,`accountpassword`,`accountactive`,`accountisad`,`accountmaxsize`,`accountpwencryption`) VALUES ('$strDomain','$strUser@$temp_domain','$strMD5Pass','$admin_default_activate','0','$account_max','$encryption')") or die(mysql_error());
				$q4=mysql_query("INSERT INTO `hm_imapfolders` (`folderid`,`folderaccountid`,`folderparentid`,`foldername`,`folderissubscribed`,`foldercreationtime`,`foldercurrentuid`) VALUES ('$folderid','$folderaccountid','$folderparentid','$foldername','$folderissubscribed','$foldercreationtime,'$foldercurrentuid')") or die(mysql_error());
            }
        }
       
        IF ($q3)&($q4)
        {
            IF ($admin_default_activate == 0)
            {
                echo "Your account has been created <b>however requires administrator activation.</b> You should receive a message soon regarding this.";
            }
            ELSE
            {
                echo "Your account has been created and is ready for use!<br><br>Username: $strUser@$temp_domain<br><br>Webmail: <a href=\"$serv_webmail/webmail\">www.$temp_domain/webmail</a><br>POP3: mail.$temp_domain<br>IMAP: mail.$temp_domain<br><br>SMTP: mail.$temp_domain";
                $subject = "Welcome To MYWEBSITE!";
                $message = "This is confirmation that your account has been created.";

                mail("{$_POST['user']}@$temp_domain", $subject, $message); //Send welcome message
            }
        }
        ELSE
        {
            echo "Database error, unable to add account. Please contact your administrator!";
        }

        IF ($admin_default_activate == 0 && $admin_notify == 0)
        {
            $admin_mail_subject = "Account Requires Activation!";
            $admin_mail_message = "{$_POST['user']}@$temp_domain has been created by {$_POST['name']} and needs to be activated!";
            mail($admin_email, $admin_mail_subject, $admin_mail_message);
        }
        ELSEIF ($admin_default_activate == 1 && $admin_notify == 1)
        {
            $admin_mail_subject = "New Account Created!";
            $admin_mail_message = "{$_POST['user']}@$temp_domain has been created by {$_POST['name']}!";
            mail($admin_email, $admin_mail_subject, $admin_mail_message);
        }
         ELSEIF ($admin_default_activate == 0 && $admin_notify == 1)
        {
            $admin_mail_subject = "New Account Created!";
            $admin_mail_message = "{$_POST['user']}@$temp_domain has been created by {$_POST['name']}!";
            mail($admin_email, $admin_mail_subject, $admin_mail_message);
        }
        break;
   
    DEFAULT:
    }
}

//#### MAIN PAGE IF FORM NOT FILLED OUT ####//
echo "
<form action=\"?mode=do\" method=\"POST\">
Your Name: <input type=\"text\" name=\"name\" size=\"21\"><br>
E-Mail: <input type=\"text\" name=\"user\" size=\"21\"> @ <select name=\"domain\">
";

$q2=mysql_query("SELECT * FROM `hm_domains` WHERE `domainactive` = '1' ORDER BY `domainname` DESC"); //Load avaliable domains into memory
WHILE ($v2=mysql_fetch_array($q2)) //Display avaliable domains
{
    echo "<option value=\"{$v2['0']}\">{$v2['1']}</option>";
}

echo "
</select><br>
Password: <input type=\"password\" name=\"pass1\" size=\"21\"><br>
Password: <input type=\"password\" name=\"pass2\" size=\"21\"> (For Confirmation)<br><br>

<input type=\"submit\" value=\"Create Account\">
</form>
";
?>

Post Reply