Preconfigured SquirrelMail for hMailserver now available

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
Post Reply
polarunion
Normal user
Normal user
Posts: 245
Joined: 2004-04-05 20:21
Location: Ottawa, Canada
Contact:

Preconfigured SquirrelMail for hMailserver now available

Post by polarunion » 2004-06-11 03:46

This is a modded version of the latest Squirrelmail 1.4.3a compiled and configured and ready to go right out of the box. All that is needed to do is to extract and drop the folder into a location on your webserver which is running a properly configured setup of hMailServer, PHP, MySql, Apache and Perl.

Screenshots and more info is available at

http://learn.boxedout.com/

It works great, it's pretty, and there's nothing to set it up! That should save a few hours for people. Let me know what you think.
Last edited by polarunion on 2004-09-28 18:34, edited 1 time in total.

jpeoples
Normal user
Normal user
Posts: 67
Joined: 2004-07-01 05:56
Location: Ft Lauderdale, Fl US of A

Post by jpeoples » 2004-07-01 06:43

I've only been using hmailserver for 10 days and I've only used the new version of squirrelmail, and for a newbie to be able to set it up with no problems, it's great!!!!!

vaggos13
New user
New user
Posts: 1
Joined: 2004-07-07 19:23

Post by vaggos13 » 2004-07-07 19:24

Is there any way to have a new user registration option?


Thanks

polarunion
Normal user
Normal user
Posts: 245
Joined: 2004-04-05 20:21
Location: Ottawa, Canada
Contact:

Post by polarunion » 2004-07-07 19:29

this hasn't been supported yet. it's been posted in the hmailtracker as a wanted feature but this could take time since there's a lot of other features that are taking precidence to this now. However if somebody know's how to somehow get the webadmin for hmailserver to have a customized page that would allow users to create their own accounts from the web, that would be pretty helpful.

User avatar
martin
Developer
Developer
Posts: 6834
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Post by martin » 2004-07-07 20:25

I think I'll implement this for 3.4. I'm thinking about the following:

Support for different level of users:

Server administrator
- Can administer any of the domains

Domain administrator
- Can add & remove accounts & distribution lists & aliases for a domain. And set quota limits for the account.

User
- Can administer his own account (to change vacation message for example)

After that, I'm going to create a small php script that allows users to create account via a webpage. Going to make it very simple though. No flashy extra stuff. :)

Stef Levolger
New user
New user
Posts: 13
Joined: 2004-07-08 00:11

Post by Stef Levolger » 2004-07-08 17:24

polarunion wrote:this hasn't been supported yet. it's been posted in the hmailtracker as a wanted feature but this could take time since there's a lot of other features that are taking precidence to this now. However if somebody know's how to somehow get the webadmin for hmailserver to have a customized page that would allow users to create their own accounts from the web, that would be pretty helpful.
$Accountaddress= $HTTP_GET_POST_VARS['$Username'] " . "@domain.com";
$Password = $HTTP_GET_POST_VARS['$Password'];

$sql = "INSERT INTO `hm_accounts` ( `accountid` , `accountdomainid` , `accountaddress` , `accountpassword` , `accountactive` , `accountisad` , `accountaddomain` , `accountadusername` , `accountreturnconv` , `accountmaxsize` , `accountvacationmessageon` , `accountvacationmessage` , `accountvacationsubject` )
VALUES (
'', '1', '$Accountaddress', '$Password', '1', '0', '', '', '0', '2048000', '0', '', ''
)";
mysql_query($sql);

That would basically do the trick to get an account added where ppl can set a username and password to get it added. I'm busy now with creating this feature on my site when ppl register for an account they automatically get an email adress along with it.

I will place the source for it here as soon as I've finished it, the only thing which will remain for you to do is configure the database connection settings and you would be done for use.

1 thing you should keep in mind. The administration tool is not made for changes like this in the database, if you want to view new accounts in the database, restart the administration tool first, has the bad habit of crashing otherwise.

If you want to try adding an account like this in phpmyadmin or something else, run this sql:
INSERT INTO `hm_accounts` ( `accountid` , `accountdomainid` , `accountaddress` , `accountpassword` , `accountactive` , `accountisad` , `accountaddomain` , `accountadusername` , `accountreturnconv` , `accountmaxsize` , `accountvacationmessageon` , `accountvacationmessage` , `accountvacationsubject` )
VALUES (
'', '1', 'Guest@domain.com', 'Guest', '1', '0', '', '', '0', '2048000', '0', '', ''
);

It will create an account with as adress, Guest@domain.com, password Guest, activated account and storage of 2048kb.

Stef Levolger
New user
New user
Posts: 13
Joined: 2004-07-08 00:11

Post by Stef Levolger » 2004-07-08 18:28

I finished the script. First, create a file called db.php and in it place the following code:

Code: Select all

<? 
/*  Database Information - Required!!  */
/* -- Configure the Variables Below --*/
$dbhost = 'localhost';
$dbusername = 'username';
$dbpasswd = 'password';
$database_name = 'database name';

/* Database Stuff, do not modify below this line */

$connection = mysql_pconnect("$dbhost","$dbusername", "$dbpasswd")
	or die ("Couldn't connect to server.");
	
$db = mysql_select_db("$database_name", $connection)
	or die("Couldn't select database.");
?>
Now just change the host, username, password and database name to whatever you are using and this file is finished.

Second, create a file called webmailsignup.php in the same folder as db.php and in it, put the following code:

Code: Select all

<?
include('db.php');
if ($signup=="true") {
	$Password = $HTTP_POST_VARS['password'];
	$MailAddress = $HTTP_POST_VARS['user'];
	$Accountaddress = $MailAddress . "@domainname.com";

	$sql = mysql_query("Select accountaddress From hm_accounts Where accountaddress='$Accountaddress'");
	$row = mysql_fetch_array($sql);

	if (!$row[accountaddress]) {
	$sql = "INSERT INTO `hm_accounts` ( `accountid` , `accountdomainid` , `accountaddress` , `accountpassword` , `accountactive` , `accountisad` , `accountaddomain` , `accountadusername` , `accountreturnconv` , `accountmaxsize` , `accountvacationmessageon` , `accountvacationmessage` , `accountvacationsubject` )
	VALUES ('', '1', '$Accountaddress', '$Password', '1', '0', '', '', '0', '2048000', '0', '', '')"; 
	mysql_query($sql);


	$res = mysql_affected_rows();

	if($res > 0) {
		echo "succesfully signed up for a webmail account";
	} else {
		echo "failed to sign up for a webmail account";
	} 
} else {
		echo "You have already signed up for an account, if not contact bug support";
	}
} else {
echo "<form name=\"form1\" method=\"post\" action=\"" . $PHP_SELF . "?signup=true\">";

echo "Enter the username and password you wish to sign up with.";

echo "<table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td width=\"20%\" class=\"style3\">&nbsp;Username:</td>
<td><input name=\"user\" type=\"test\" id=\"user\" size=\"8\"></td>
</tr>
<tr>
<td width=\"20%\" class=\"style3\">&nbsp;Password:</td>
<td><input name=\"password\" type=\"password\" id=\"password\" size=\"8\"></td>
</tr>
<tr>
<td width=\"20%\">&nbsp;</td>
<td><div align=\"center\"><span class=\"style3\">
<input type=\"submit\" name=\"Submit\" value=\"Signup\"></span</div></td>
</tr>
</table>
</form>";
}
?>
Here you just have to change @domainname.com in line 6 or 7 or so to whatever you are using as a domain and you're done. Place it on your server and test it. People can use it to sign up for an account.

PS: There is no check on it to see if anything is listed already, kinda surprised to see that the accounts in the database are not set as unique. So to avoid duplicate accounts, either set it as unique in the database or create a check yourself. It's not that hard to do.

Edit: Have now added the check to see if a name is already listed in the database to make it easier for the people which don't know PHP. Feel free to use it for whatever you like :)

User avatar
TimS
Normal user
Normal user
Posts: 45
Joined: 2003-11-30 18:39
Location: Clarkston, MI
Contact:

Stef Levolger's script

Post by TimS » 2004-10-16 07:00

An update to the second part to make it work with hmail 3.3.47: Reflects new database structure

Code: Select all

<? 
include('db.php'); 
if ($_GET[signup]=="true") { 
   $Password = $HTTP_POST_VARS['password']; 
   $MailAddress = $HTTP_POST_VARS['user']; 
   $Accountaddress = $MailAddress . "@yourserver.com";
 


   $sql = mysql_query("Select accountaddress From hm_accounts Where accountaddress='$Accountaddress'"); 
   $row = mysql_fetch_array($sql); 

   if (!$row[accountaddress]) { 
   $sql = "INSERT INTO `hm_accounts` ( `accountid` , `accountdomainid` , `accountaddress` , `accountpassword` , `accountactive` , `accountisad` , `accountaddomain` , `accountadusername`  , `accountmaxsize` , `accountvacationmessageon` , `accountvacationmessage` , `accountvacationsubject` ) 
   VALUES ('', '1', '$Accountaddress', '$Password', '1', '0', '', '',  '2048000', '0', '', '')"; 
  echo "$sql is";
 mysql_query($sql); 


   $res = mysql_affected_rows(); 

   if($res > 0) { 
      echo "succesfully signed up for a webmail account"; 
   } else { 
      echo "failed to sign up for a webmail account"; 
   } 
} else { 
      echo "You have already signed up for an account, if not contact bug support"; 
   } 
} else { 
echo "<form name=\"form1\" method=\"post\" action=\"" . $PHP_SELF . "?signup=true\">"; 

echo "Enter the username and password you wish to sign up with."; 

echo "<table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> 
<tr> 
<td width=\"20%\" class=\"style3\">&nbsp;Username:</td> 
<td><input name=\"user\" type=\"test\" id=\"user\" size=\"8\"></td> 
</tr> 
<tr> 
<td width=\"20%\" class=\"style3\">&nbsp;Password:</td> 
<td><input name=\"password\" type=\"password\" id=\"password\" size=\"8\"></td> 
</tr> 
<tr> 
<td width=\"20%\">&nbsp;</td> 
<td><div align=\"center\"><span class=\"style3\"> 
<input type=\"submit\" name=\"Submit\" value=\"Signup\"></span</div></td> 
</tr> 
</table> 
</form>"; 
} 
?> 
Tim S

User avatar
rabol
Normal user
Normal user
Posts: 63
Joined: 2004-02-06 15:38
Location: Farsoe, Denmark
Contact:

Post by rabol » 2004-10-16 14:39

Hi

Why not save all the DB hazzel ??

Simply use the COM interface and let hMailServer handle it
Something like this:

<?php
if(isset($_REQUEST['signup']))
{
$obBaseApp = new COM("hCOM.BaseApp");
$domainname = (isset($_REQUEST['domainname']) ? $_REQUEST['domainname'] : "");
$user = (isset($_REQUEST['user']) ? $_REQUEST['user'] : "");
$password = (isset($_REQUEST['password']) ? $_REQUEST['password'] : "");

if($user == "")
{
echo "missing user";
exit();
}

if($password == "")
{
echo "missing password";
exit();
}

if($domainname != "")
{
$obDomain = $obBaseApp->Domains->ItemByName($domainname);
$obAccounts = $obDomain->Accounts();

// test that the new account does not exists
$obAccount = @$obAccounts->ItemByAddress($user . "@" . $domainname);
if($obAccount)
{
echo "Sorry, account allready exists";
exit();
}

$obAccount = $obAccounts->Add();
$obAccount->Address = $user . "@" . $domainname;
$obAccount->Password = $password;
$obAccount->Active = true;
$obAccount->Save();

echo "Account created and activated";
exit();

}
else
{
echo "Selected domain name is not valid";
exit();
}

}
else
{
// Build domain select - add some code to remove domains that the user can't signup for
$obBaseApp = new COM("hCOM.BaseApp");
$DomainCount = $obBaseApp->Domains->Count();
$domainselect = "<select name=\"domainname\">";
for ($i = 1; $i <= $DomainCount; $i++)
{
$obDomain = $obBaseApp->Domains[$i-1];
$domainselect .= "<option value=\"" . $obDomain->Name . "\">" . $obDomain->Name . "</option>";
}
$domainselect .= "</select>";
echo "<form name=\"form1\" method=\"post\" action=\"" . $_SERVER['PHP_SELF'] . "?signup=true\">";
echo "Enter the username and password you wish to sign up with.";
echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td width=\"20%\" class=\"style3\">&nbsp;Username:</td>
<td><input name=\"user\" type=\"test\" id=\"user\" size=\"8\">&nbsp;$domainselect</td>
</tr>
<tr>
<td width=\"20%\" class=\"style3\">&nbsp;Password:</td>
<td><input name=\"password\" type=\"password\" id=\"password\" size=\"8\"></td>
</tr>
<tr>
<td width=\"20%\">&nbsp;</td>
<td><div align=\"center\"><span class=\"style3\">
<input type=\"submit\" name=\"Submit\" value=\"Signup\"></span</div></td>
</tr>
</table>
</form>";
}
?>

andyf

Squirrelmail Message filters

Post by andyf » 2004-11-04 20:20

On two different text servers, we have hmailserver 3.2.4 (33) and squirrelmail. One has the preconfigured hmail one above, the other has the default squirrelmail release. Both work fine, but we're having trouble with the message filter plugin that comes with the default squirrelmail build. The pre-configured build for hmailserver does not include this plugin.

When the plugin is added and running on either server, message filters don't work correctly. If you have it set to check all unread messages, and a e-mail comes in with the keyword in the subject - rather than moving just that messages, it moves all unread messages to the specified folder. If you have it set to check all messages for a subject keyword, and it finds one - then all message in the Inbox for example are moved to the subfolder (rather than just the message that should have been moved).

Anyone else have this trouble? We'd really like users to be able to have messages get sent to sorting folders upon their login to Squirrelmail.

Thanks,
Andy

greenman
New user
New user
Posts: 18
Joined: 2004-11-17 17:23

Post by greenman » 2004-11-17 18:42

I have set this up and I can't send messages through it. I can recieve messages but when I send I get this:

Code: Select all

ERROR:
Syntax error; command not recognized
Server replied: 500 Syntax error, command unrecognized.

User avatar
martin
Developer
Developer
Posts: 6834
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Post by martin » 2004-11-17 19:34

Server replied: 500 Syntax error, command unrecognized.
I don't think hMailServer ever says that (not 100% sure..). Are you sure you have entered the correct IMAP server IP address in the configuration.

greenman
New user
New user
Posts: 18
Joined: 2004-11-17 17:23

Post by greenman » 2004-11-17 21:22

I didn't mess with the configuration, it said that it was ready out of the box so I assumed I would just unzip it and go...

I'll go dig through the config files...

Post Reply