· 6 years ago · May 20, 2019, 11:16 AM
1<?php
2
3###############################################################
4# cPanel Email Account Creator 1.3
5###############################################################
6# Visit http://www.zubrag.com/scripts/ for updates
7###############################################################
8# You can pass following parameters in calling URL. They will
9# override those specified below.
10# user - new email user
11# pass - password
12# domain - email domain
13# quota - email quota, Mb
14# Example: cpemail.php?user=newuser&pass=password"a=50
15###############################################################
16
17// Antispam image
18// Show CAPTCHA - true, do not show - false
19// In case you set this to true, you may want to update settings in the antispam.php
20// Also when using this feature, fonts must exist on your system.
21// By default antispam.php is setup to use arial.ttf
22// For details see http://www.zubrag.com/scripts/antispam-image-generator.php
23$antispam = false;
24
25// cPanel info
26$cpuser = 'jracntrj'; // cPanel username
27$cppass = 'Pancake123'; // cPanel password
28$cpdomain = 'cpanel.dankhost.se'; // cPanel domain or IP
29$cpskin = 'x'; // cPanel skin. Mostly x or x2.
30// See following URL to know how to determine your cPanel skin
31// http://www.zubrag.com/articles/determine-cpanel-skin.php
32
33// Default email info for new email accounts
34// These will only be used if not passed via URL
35$epass = 'hispassword'; // email password
36$edomain = 'dankhost.se'; // email domain (usually same as cPanel domain above)
37$equota = 20; // amount of space in megabytes
38
39###############################################################
40# END OF SETTINGS
41###############################################################
42
43function getVar($name, $def = '') {
44 if (isset($_REQUEST[$name]))
45 return $_REQUEST[$name];
46 else
47 return $def;
48}
49
50// check if overrides passed
51$euser = getVar('user', '');
52$epass = getVar('pass', $epass);
53$edomain = getVar('domain', $edomain);
54$equota = getVar('quota', $equota);
55
56$msg = '';
57
58if (!empty($euser))
59while(true) {
60 // Create email account
61 $f = fopen ("http://$cpuser:$cppass@$cpdomain:2082/frontend/$cpskin/mail/doaddpop.html?email=$euser&domain=$edomain&password=$epass"a=$equota", "r");
62 if (!$f) {
63 $msg = 'Cannot create email account. Possible reasons: "fopen" function allowed on your server, PHP is running in SAFE mode';
64 break;
65 }
66
67 $msg = "<h2>Email account {$euser}@{$edomain} created.</h2>";
68
69 // Check result
70 while (!feof ($f)) {
71 $line = fgets ($f, 1024);
72 if (ereg ("already exists", $line, $out)) {
73 $msg = "<h2>Email account {$euser}@{$edomain} already exists.</h2>";
74 break;
75 }
76 }
77 @fclose($f);
78
79 break;
80
81}
82
83?>
84<html>
85<head><title>cPanel Email Account Creator</title></head>
86<body>
87<?php echo '<div style="color:red">'.$msg.'</div>'; ?>
88<h1>cPanel Email Account Creator</h1>
89<form name="frmEmail" method="post">
90<table width="400" border="0">
91<tr><td>Username:</td><td><input name="user" size="20" value="<?php echo htmlentities($euser); ?>" /></td></tr>
92<tr><td>Password:</td><td><input name="pass" size="20" type="password" /></td></tr>
93<tr><td colspan="2" align="center"><hr /><input name="submit" type="submit" value="Create Email Account" /></td></tr>
94</table>
95</form>
96</body>
97</html>