The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Redirect email services

Discussion in 'E-mail Discussions' started by twin, Aug 22, 2004.

  1. twin

    twin Registered

    Jan 16, 2004
    Likes Received:
    Trophy Points:

    I would like to enable people on my site redirection option: e.g to Can Anybody help me with this? I've made email services using cpanelmail (script I found using google) very simply so maybe it is easy two.

    Here is a code of signup.php to autocreate email accounts:
    	include("config.php");//Change this to point to config.php outside your web root
    		$newemail = "$newuser@$domain";
    		$mpassword = $password2;
    		$link = mysql_connect($dbhost, $dbuser, $dbpass);
    		mysql_select_db($dbname) or die("Could not select database");
    		$query="SELECT username FROM $dbusertbl WHERE((username = '$newuser'))";
    		$result= mysql_query($query,$link);
    		if(mysql_num_rows($result) ==0)
    				$query="INSERT INTO $dbusertbl(name,username,password,email) VALUES ('$name','$newuser','$password1','$replymail');";
    				$socket = fsockopen($host,2082);
    				$authstr = "$cpaneluser:$cpanelpass";
    				$pass = base64_encode($authstr);
    				$in = "GET /frontend/$cpaneltheme/mail/doaddpop.html?email=$newemail&domain=$domain&password=$mpassword&a=$quota\r\n HTTP/1.0\r\nAuthorization: Basic $pass \r\n";
    				fclose( $socket );
    				?> Your account has been setup successfully please login <a href="mail/index.php">here</a>
    		else {
    		echo "Username already in use please try another one.<br><a href=signup.php>Back</a>";
    	else { ?> 
    	<form name="orderform" method="post" action="signup.php">
    	  <table border="0" cellspacing="1" cellpadding="0">
    	      <td>Your full Name:</td>
    	      <td colspan="2"><input name="name" type="text"></td>
    	      <td width="147">Other Email Address:</td>
    	      <td colspan="2"><input name="replymail" type="text">
    	        (In case you forget your password)</td>
    	      <td>Prefered Email Address:</td>
    	      <td colspan="2"><input name="newuser" type="text">
            @<?= $domain ?></td>
    	      <td colspan="2"><input name="password1" type="password"></td>
    	      <td>Retype Password:</td>
    	      <td colspan="2"><input name="password2" type="password"></td>
    	      <td colspan="2">&nbsp;</td>
    	      <td width="344"> <div align="center"> 
    	          <input name="signupbtn" type="button" id="signupbtn" value="Signup" onClick="validateform()">
    	      <td width="163">&nbsp;</td>
    	  <script language="JavaScript1.2">
    	function validateform()
    		if (checkEmailAddress(document.orderform.replymail))
    			if(document.orderform.password1.value == document.orderform.password2.value)
    				alert("The passwords you typed do not appear to match");
    	function checkEmailAddress(field) {
    	var good;
    	var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
    	if (goodEmail){
    	   good = true
    	} else {
    	   alert('Please enter a valid e-mail address.')
    	   good = false
    	   return good;
    	<? }
    AND here is config.php

    	//before this will work you will need to make a mysql user in cpanel and then run setup.php
    	//if you need any help email me at
    	//also once you have made the table you Must add any email addresses that you already have
    	//to the data base using the reserve option otherwise this script can overwrite mailboxes
    	$host = "";//your url
    	$domain = "";//your domain without the www
    	//Cpanel options:
    	$cpaneluser = "username";//your cpanel username
    	$cpanelpass = "password";//your cpanel password
    	$cpaneltheme= "bluelagoon"; //this is the word after frontend/ and the next / when you login to cpanel
    	//Database options:
    	$dbhost="localhost"; //Usually localhost
    	$dbuser="admin";//mysql username
    	$dbpass="";//mysql password
    	$dbname="username_mailusers";//The name of the database for mail
    	$dbusertbl="mailusers";//Name of the table for users
    	$dbadmintbl="mailadmin";//name of the table for admin
    	$quota=4096;//how much space in k you want to give the user
    	$mailurl="mail/index.php";//The url for your web based mail program I use but you can use anything
    	//End of settings! you should not need to change anything below this
    So how to chnage this code to work as a redirector of emails?

    Thx, Tom

Share This Page