Page 1 of 3 123 LastLast
Results 1 to 15 of 44

Thread: Automatic Email Signup

  1. #1
    Registered User
    Join Date
    Mar 2003
    Location
    Sandy, Utah, USA
    Posts
    4

    Default Automatic Email Signup

    Hi All,

    I found one thread in this forum on automatic email signups through cpanel, but that thread led to a dead-end. Does anyone know where I can find such a script?

  2. #2
    Member
    Join Date
    Feb 2002
    Posts
    8

    Smile mail creation scripts

    Here is some scripts that I copied from previous posts on this forum re creating mail accts from php scripts.
    you would need to find which works and modify to suit.
    hope this helps :-)

    $host = "www.domain.com";
    $socket = fsockopen($host,2082);
    $user = "cpaneluser";
    $password = "cpanelpass";
    $authstr = "$user:$password";
    $pass = base64_encode($authstr);
    $in = "GET /frontend/default/mail/doaddpop.html?email=emailaddress&domain=domain.com&password=emailpassword&quota=10 HTTP/1.0\r\nAuthorization: Basic $pass \r\n";

    fputs($socket,$in);
    fclose( $socket );

    it may be a little slow but it definitely works, and I suppose this means that you can use it do any command really,

    ================
    <?
    if ($submit){
    $host = "www.1337ster.com";
    $domain = "1337ster.com";
    $socket = fsockopen($host,2082);
    $user = "jimmyc";
    $password = "859780barryw";
    $authstr = "$user:$password";
    $pass = base64_encode($authstr);
    $in = "GET /frontend/default/mail/doaddpop.html?email=$email&domain=$domain&password=$password&quota=$quota HTTP/1.0\r\nAuthorization: Basic $pass \r\n";

    fputs($socket,$in);
    fclose( $socket );
    }
    else {
    ?>
    <form method=post>
    Username:<input type=text name=email><br>
    Password:<input type=password name=password><br>
    Quota:<input type=text name=quota>
    <input type=submit name=submit value=submit>
    <?
    }
    ?>

    =====
    set REMOTE_USER to your username and run

    use /usr/local/cpanel/cpanel-email

    # /usr/local/cpanel/cpanel-email
    cpanel-email: usage addpop <popuser> <password> <quota> <domain> delpop <popuser> 0 <domain>
    =========

    $in = "GET /frontend/USER_THEME/mail/dopasswdpop.html?email=$email&domain=$domain&password=$password1"a=$quota HTTP/1.0\r\nAuthorization: Basic $pass \r\n";

    Make sure your form's input names match the email, password and quota variables on this line.

    Replace the USER_THEME with bluelagoon, default, iconic or whatever the theme for the account is and leave all the rest in the script as is.

    ==========
    header("Location: index.php"); /* Redirect browser */
    exit; /* Make sure that code below does
    not get executed when we redirect. */

    make the index.php file whereever you want to redirect too.


    ===============
    For thoes of your that used Jim Carters neomail create script.

    There is an error in that after you create the email account the user will not beable to login to neomail the reason for this is the cpanel password and user name conflict with the form that is made with it to fix it do this.


    Original:


    <?
    if ($submit){
    $host = "www.domain.com";
    $domain = "domain.com";
    $socket = fsockopen($host,2082);
    $user = "cpaneluser";
    $password = "cpanelpass";
    $authstr = "$user:$password";
    $pass = base64_encode($authstr);
    $in = "GET /frontend/default/mail/doaddpop.html?email=$email&domain=$domain&password=$password&quota=$quota HTTP/1.0\r\nAuthorization: Basic $pass \r\n";

    fputs($socket,$in);
    fclose( $socket );
    }
    else {
    ?>
    <form method=post>
    Username:<input type=text name=email><br>
    Password:<input type=password name=password><br>
    Quota:<input type=text name=quota>
    <input type=submit name=submit>
    <?
    }
    ?>

    Fixed version:

    <?
    if ($submit){
    $host = "www.domain.com";
    $domain = "domain.com";
    $socket = fsockopen($host,2082);

    // these lines are changed
    $cpaneluser = "cpaneluser";
    $cpanelpass = "cpanelpass";
    $authstr = "$cpaneluser:$cpanelpass";
    //****************************

    $pass = base64_encode($authstr);
    $in = "GET /frontend/default/mail/doaddpop.html?email=$email&domain=$domain&password=$password&quota=$quota HTTP/1.0\r\nAuthorization: Basic $pass \r\n";

    fputs($socket,$in);
    fclose( $socket );
    }
    else {
    ?>
    <form method=post>
    Username:<input type=text name=email><br>
    Password:<input type=password name=password><br>
    Quota:<input type=text name=quota>
    <input type=submit name=submit>
    <?
    }
    ?>


    ================

    I have been trying to utilise the signup script that is used on http://www.warwithboredom.com which allows users to signup for email acounts via a html form, however i cant seem to get the file to work.

    If posts the username and password to the sql but isnt setting up the pop account.

    The program consists of two files and a sql

    the files are: config.php

    <?
    //before this will work you will need to make a database and then run signup.sql in phpmyadmin
    //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 manually otherwise this script can overwrite mailboxes


    $host = "www.yourdomain.com";//your url
    $domain = "yourdomain.com";//your domain without the www
    $cpaneluser = "username";//your cpanel username
    $cpanelpass = "password";//your cpanel password
    $cpaneltheme= "cpanelxp_hg"; //this is the word after frontend/ and the next / when you login to cpanel
    $dbhost="localhost"; //Usually localhost
    $dbuser="user";//mysql username
    $dbtable="users";//only change this if you have access to only one database
    $dbpass="";//mysql password
    $dbname="users";//The name of the database
    $quota=4000;//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/Script.../Email_Systems

    //End of settings! you should not need to change anything below this

    ?>



    and


    signup.php

    <?php
    $pathtoconfig="config.php";
    include("theme.php";
    doheader();
    if(isset($newuser))
    {
    include($pathtoconfig);

    $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 $dbtable WHERE((username = '$username'))";
    $result= mysql_query($query,$link);
    if(mysql_num_rows($result) ==0)
    {
    $query="INSERT INTO $dbtable(name,username,password,email) VALUES ('$name','$newuser','$pass2','$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">
    @WarWithBoredom.com</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>
    <? }
    dofooter();
    ?>

    the sql file is:

    CREATE TABLE `users` (
    `name` char(50) NOT NULL default '',
    `username` char(50) NOT NULL default '',
    `password` char(20) NOT NULL default '',
    `id` int(11) NOT NULL auto_increment,
    `email` char(50) NOT NULL default '',
    PRIMARY KEY (`id`)
    ) TYPE=MyISAM;

    Now im trying to use this but cant seem to get it to work.

    My mail is horde which is available via :2095/horde/index.php and my cpanel theme is "cpanel"

    anyone have any ideas what may be wrong with this code?

    Ps ive had to cut this into two replies, as limit on 1000 words

  3. #3
    Member
    Join Date
    Feb 2002
    Posts
    8

    Smile mail scripts Part 2

    PART 2 :-)

    ====================
    A fix...
    [mail.php]
    // follow the instuctions given before...
    // the config file is the same
    <?
    $pathtoconfig="config.php";
    error_reporting(0);
    if (!include($pathtoconfig)){echo"Cannot include config file.<br />Please alert admin.\n";die;}

    if(isset($newuser)) {

    $newemail = "$newuser@$domain";

    $link = mysql_connect($dbhost, $dbuser, $dbpass);
    mysql_select_db($dbname) or die("Could not select database");
    $query="SELECT username FROM $dbtable WHERE((username = '$username'))";
    $result= mysql_query($query,$link);
    if(mysql_num_rows($result)==0) {
    $query="INSERT INTO $dbtable (name,username,password,email)
    VALUES ('$name','$newuser','$password2','$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=$password2&quota=$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="<?echo $mailurl;?>">here</a>. Use your full email address (<?echo $newemail;?>) as the username.<?
    }
    else {echo mysql_error();echo"<br />Username already in use please try another one.<br /><a href=\"".$_SERVER['PHP_SELF']."\">Back</a>";}
    mysql_close($link);
    }

    else { ?>
    <form name="orderform" method="post" action="<?echo$_SERVER['PHP_SELF'];?>">
    <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" />@<?echo $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">
    <input name="signupbtn" type="button" id="signupbtn" value="Signup" onclick="validateform();" />
    </td>
    <td width="163">&nbsp;</td>
    </tr>
    </table>
    </form>

    <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=1}
    else {
    alert('Please enter a valid e-mail address.');
    field.focus();
    field.select();
    good=0;
    }
    return good;
    }
    </script>
    <?}?>

    [/mail.php]



    ==============







    <?
    if ($submit){


    //Username, root directory NO TRAILING SLASH
    $home_directory = "/home/username";

    // Mailbox path
    $mail_path = "$home_directory/mail";

    $p_directory = "$home_directory/etc";

    $newuser = "$formusername";
    $usrPassword = "$formpass";


    chmod ("$p_directory/passwd", 0755);
    chmod ("$p_directory/shadow", 0755);
    chmod ("$p_directory/quota", 0755);


    if (is_dir("$mail_path/$newuser")){ echo "username taken, please try again"; die; }
    mkdir ("$mail_path/$newuser",0770);
    mkdir ("$mail_path/$newuser/uploads",0770);
    mkdir ("$mail_path/$newuser/addressbook",0770);


    $mailfile = fopen("$p_directory/passwd",'a');
    $shadowfile = fopen("$p_directory/shadow",'a');
    $quotafile = fopen("$p_directory/quota",'a');



    $mail = "$newuser:x:xxxxx:xxx::$home_directory:/bin/bash\n";

    $shadow = "$newuser:" . crypt($usrPassword, $usrPassword) . ":::::::\n";
    // convert quota to bytes, If you dont want them to set there own quota you can delete the $formquota variable, and put in a figure, ie. 5 and then remove the form compontent, allowing you to add quota.
    $formquot = $formquota * 1048576;


    $quota = "$newuser:$formquot";

    fputs($mailfile, $mail);
    fputs($shadowfile, $shadow);
    fputs($quotafile, $quota);
    fclose($quotafile);
    fclose($mailfile);
    fclose($shadowfile);
    echo "Account Created Successfully!";
    }
    else
    {
    ?>
    <html>
    <center><h4>Create New Mail User</h4><p>
    <form method=post>
    Username: <input type=text name=formusername><br>
    Password: <input type=password name=formpass><br>
    Quota in MB: <input type=text name=formquota><br>
    <input type=submit name=submit value=Submit>
    <?
    }
    ?>

  4. #4
    Registered User
    Join Date
    Mar 2003
    Location
    Sandy, Utah, USA
    Posts
    4

    Default

    Hey thanks, wozza!

    The first little snippet works just great. Just what I needed.

    ~FrontDoorGuy

  5. #5
    Member
    Join Date
    Oct 2003
    Posts
    6

    Unhappy

    Have followed the examples, can get the scripts to execute with no errors, but also get no results as far as mail accounts created.. any ideas?

  6. #6
    Registered User
    Join Date
    Mar 2003
    Location
    Sandy, Utah, USA
    Posts
    4

    Default

    Hello,

    My script quit working when my host upgraded the server and all the cPanel skins (or themes) went back to default. I use bluelagoon. Check the line that looks like this:

    $in = "GET /frontend/default/mail/doaddpop.html?email=$email&domain=$domain&password=$password"a=$quota HTTP/1.0\r\nAuthorization: Basic $pass \r\n";

    "default" is the directory of the default skin, so mine says "bluelagoon" instead of "default." Check to make sure your GET string has the proper directory. If that doesn't help, let me know and I'll help you get it working. Good luck!

    FrontDoorGuy

  7. #7
    Member
    Join Date
    Oct 2003
    Posts
    6

    Default

    Originally posted by frontdoorguy

    $in = "GET /frontend/default/mail/doaddpop.html?email=$email&domain=$domain&password=$password"a=$quota HTTP/1.0\r\nAuthorization: Basic $pass \r\n";
    I've got the right theme configured, just double checked. but I can see another strange thing in your GET line. You have $password"a=... I have $password&a=... I thought maybe... so I tried it, and got an error...

  8. #8
    Registered User
    Join Date
    Mar 2003
    Location
    Sandy, Utah, USA
    Posts
    4

    Default

    Woops!

    I just snipped that code from one of the lines above. Here is what I actually use:

    $authstr = "$user:$domainpass";
    $psswd = base64_encode($authstr);
    $host = "www.$domainname";
    $socket = fsockopen($host,2082);
    $in = "GET /frontend/bluelagoon/mail/doaddpop.html?email=$usrname&domain=$domainname&password=$pwd&quota=10 HTTP/1.0\r\nAuthorization: Basic $psswd \r\n";
    fputs($socket,$in);
    fclose( $socket );

    I use this on an Apache server with Red Hat Linux 7.2, PHP 4+ and the latest cPanel. What is your setup?

    FrontDoorGuy

  9. #9
    Registered User
    Join Date
    Jul 2003
    Posts
    4

    Default Help please

    Hi,

    I've been trying to work with this code:

    <?
    $sAuth = base64_encode("cpaneluser:cpanelpass");
    $sHTTP = "GET /frontend/x/mail/doaddpop.html?email=test&domain=mydomain.com&password=test&quota=10\r\n HTTP/1.0\r\nAuthorization: Basic $sAuth\r\n";
    $hSocket = fsockopen("mydomain.com", 2082);
    fputs($hSocket, $sHTTP);
    fclose($hSocket);
    ?>

    It worked for a few hours and then just quit working. No errors, just fails silently. Can someone help me find a solution to this?

    I haven't changed my skin, port 2082 is correct. The issue is that the authorisation part of the code is not working.

    Thanks

  10. #10
    Registered User
    Join Date
    Jul 2003
    Posts
    4

    Default

    In the above thread it is not pasting correctly in the Get request. After password=test& should read quota=10.

    In case this doesn't copy right either it is:

    quote equals 10

  11. #11
    Member BeNE.WS's Avatar
    Join Date
    May 2003
    Location
    Belgium
    Posts
    49

    Default

    I had installed this script a couple of months ago.
    It was working fine t'ill today.

    TYODAY I changed all the themes to the X theme so that all the accounts on the server have the same theme.

    My script for the cration of emails does not work anymore since than.

    I have changed the map to my theme.
    $in = "GET /frontend/x/mail/doaddpop.html?email=....

    I have installed: WHM 8.5.4 cPanel 8.5.4-R7

    What can be wrong ?
    Regards,


    Steven Depuydt
    www.BeNe.WS

  12. #12
    Member
    Join Date
    Oct 2003
    Posts
    6

    Default

    Originally posted by frontdoorguy
    Woops!

    I just snipped that code from one of the lines above. Here is what I actually use:

    $authstr = "$user:$domainpass";
    $psswd = base64_encode($authstr);
    $host = "www.$domainname";
    $socket = fsockopen($host,2082);
    $in = "GET /frontend/bluelagoon/mail/doaddpop.html?email=$usrname&domain=$domainname&password=$pwd&quota=10 HTTP/1.0\r\nAuthorization: Basic $psswd \r\n";
    fputs($socket,$in);
    fclose( $socket );

    I use this on an Apache server with Red Hat Linux 7.2, PHP 4+ and the latest cPanel. What is your setup?

    FrontDoorGuy

    Here is the code I'm using currently
    <?
    if ($submit){
    $host = "www.domain.com";
    $domain = "domain.com";
    $socket = fsockopen($host,2082);

    // these lines are changed
    $cpaneluser = "myuser";
    $cpanelpass = "mypass";
    $authstr = "$cpaneluser:$cpanelpass";
    //****************************

    $pass = base64_encode($authstr);
    $in = "GET /frontend/xcontroller/mail/doaddpop.html?email=$email&domain=$domain&password=$password& quota=$quota HTTP/1.0\r\nAuthorization: Basic $pass \r\n";

    fputs($socket,$in);
    fclose( $socket );
    }
    else {
    ?>
    <form method=post>
    Username:<input type=text name=email><br>
    Password:<input type=password name=password><br>
    Quota:<input type=text name=quota>
    <input type=submit name=submit>
    <?
    }
    ?>

    inserted a space to prevent &quota from becoming "a
    WHM 8.5.1 cPanel 8.5.3-S3 on Redhat 7.3 with apache

  13. #13
    Member BeNE.WS's Avatar
    Join Date
    May 2003
    Location
    Belgium
    Posts
    49

    Default

    I have used the same script. But it is not working.

    BEFORE I changed the theme into X it WAS WORKING.

    but I don't have /fontend/xcontroller
    $in = "GET /frontend/xcontroller/mail/doaddpop.html

    I use
    $in = "GET /frontend/x/mail/doaddpop.html?email=$newuser&domain=bene.ws&password=$password&quota=25\r\nHTTP/1.0\r\nAuthorization: Basic $sAuth\r\n";



    I don't have a 'xcontroller' in my '/usr/local/cpanel/base/frontend' map


    There is x, x2 and xmail.
    Regards,


    Steven Depuydt
    www.BeNe.WS

  14. #14
    Member
    Join Date
    Oct 2003
    Posts
    6

    Default

    doaddpop.html doesn't exist and the normal email add form doesn't post to it, uses <form method="POST" action="popadded.html">

  15. #15
    Member BeNE.WS's Avatar
    Join Date
    May 2003
    Location
    Belgium
    Posts
    49

    Default

    Originally posted by mbedwell
    doaddpop.html doesn't exist and the normal email add form doesn't post to it, uses <form method="POST" action="popadded.html">
    doaddpop.html DOES exist.

    I tried both POST & GET, still NOTHING

    Other suggestions ?

    Thanks.
    Regards,


    Steven Depuydt
    www.BeNe.WS

Page 1 of 3 123 LastLast

Similar Threads

  1. Create automatic signup script
    By thehanif in forum cPanel & WHM Discussions
    Replies: 2
    Last Post: 02-24-2011, 08:17 AM
  2. Create automatic signup script
    By thehanif in forum cPanel Developers
    Replies: 2
    Last Post: 02-24-2011, 08:17 AM
  3. Automatic Signup Sheet?
    By Parahosting in forum cPanel & WHM Discussions
    Replies: 0
    Last Post: 04-07-2007, 11:13 AM
  4. Automatic Signup and Billing Software
    By n_kruse in forum cPanel & WHM Discussions
    Replies: 9
    Last Post: 05-28-2003, 06:11 PM
  5. Automatic accoutn signup
    By theghostofbob in forum cPanel & WHM Discussions
    Replies: 2
    Last Post: 10-04-2002, 03:58 AM