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

    Joined:
    Jan 16, 2004
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Hi,

    I would like to enable people on my site redirection option: e.g tom@dod.pl to tom@wortal.org 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:
    Code:
    <?php 
    	include("config.php");//Change this to point to config.php outside your web root
    
    	if(isset($newuser))
    	{
    		$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');";
    				mysql_query($query,$link);
    				$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";
    				fputs($socket,$in);
    				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>";
    		}
    		mysql_close($link);
    	} 
    	
    	else { ?> 
    	<form name="orderform" method="post" action="signup.php">
    	  <table border="0" cellspacing="1" cellpadding="0">
    	    <tr> 
    	      <td>Your full Name:</td>
    	      <td colspan="2"><input name="name" type="text"></td>
    	    </tr>
    	    <tr> 
    	      <td width="147">Other Email Address:</td>
    	      <td colspan="2"><input name="replymail" type="text">
    	        (In case you forget your password)</td>
    	    </tr>
    	    <tr> 
    	      <td>Prefered Email Address:</td>
    	      <td colspan="2"><input name="newuser" type="text">
            @<?= $domain ?></td>
    	    </tr>
    	    <tr> 
    	      <td>Password:</td>
    	      <td colspan="2"><input name="password1" type="password"></td>
    	    </tr>
    	    <tr> 
    	      <td>Retype Password:</td>
    	      <td colspan="2"><input name="password2" type="password"></td>
    	    </tr>
    	    <tr> 
    	      <td>&nbsp;</td>
    	      <td colspan="2">&nbsp;</td>
    	    </tr>
    	    <tr> 
    	      <td>&nbsp;</td>
    	      <td width="344"> <div align="center"> 
    	          <input name="signupbtn" type="button" id="signupbtn" value="Signup" onClick="validateform()">
    	        </div></td>
    	      <td width="163">&nbsp;</td>
    	    </tr>
    	  </table>
    	  <script language="JavaScript1.2">
    	
    	
    	function validateform()
    	{
    		if (checkEmailAddress(document.orderform.replymail))
    		{
    			if(document.orderform.password1.value == document.orderform.password2.value)
    			{
    				document.orderform.submit();
    			}
    			else 
    			{
    				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.')
    	   field.focus()
    	   field.select()
    	   good = false
    	   }
    	   return good;
    	}
    	
    	
    	</script>
    	</form>
    	<? }
    
    ?>
    AND here is config.php

    Code:
    <?
    	//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 support@warwithboredom.com
    	//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 = "www.jargonless.com";//your url
    	$domain = "jargonless.com";//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 http://uebimiau.sourceforge.net but you can use anything
    	//see http://www.hotscripts.com/PHP/Scripts_and_Programs/Email_Systems
    	
    	//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
     
Loading...

Share This Page