HDFilmMaker2112 Posted April 6, 2012 Share Posted April 6, 2012 How would I go about creating a new user email account that can be accessed via my cpanel mail scripts (RoundCube, SquirrelMail, etc.), in PHP. Quote Link to comment https://forums.phpfreaks.com/topic/260427-imap-php-create-new-user-account/ Share on other sites More sharing options...
chriscloyd Posted April 6, 2012 Share Posted April 6, 2012 here i found this awhile back and i used it and it worked <?php // Domain Logon Details $username=""; $password=""; // Domain details $domain="www.xxxxx.com"; $theme="xxxxx";//eg "fantastico_bluelagoon"; // Parameters to parse $eEmail=""; $eDomain="xxxxx.com"; $ePassword=""; $eQuota=""; // eg"10"; // Put post fields variable together $postfields = "email=$eEmail&domain=$eDomain&password=$ePassword"a=$eQuota"; // initialise Curl $popPost = curl_init(); // Set Curl Option: URL $url="http://$domain:2082/frontend/$theme/mail/doaddpop.html"; curl_setopt($popPost, CURLOPT_URL, $url); // Set Curl Option: Username:Password curl_setopt($popPost, CURLOPT_USERPWD, "$username:$password"); // Set Curl Option: Post style request = true curl_setopt($popPost, CURLOPT_POST, 1); // Set Curl Option: Collect result from script curl_setopt($popPost, CURLOPT_RETURNTRANSFER, 1); // Set Curl Option: Set timeout to 15 seconds curl_setopt($popPost, CURLOPT_TIMEOUT, 15); // Set Curl Option: Post data curl_setopt($popPost, CURLOPT_POSTFIELDS, $postfields); // Execute Request, and store result in $tb_post $popPost_result = curl_exec ($popPost); // Close Curl curl_close ($popPost); //output results $start = strpos($popPost_result, '<b>Account'); $end = strpos($popPost_result, 'created.'); $subset = substr($popPost_result, $start, $end+8-$start); $subset = str_replace('login ', "login<br>", $subset); //for neatness //$subset=str_replace("<!",'<-',$subset); //see the comments if (preg_match ('/Sorry/i', "$subset")) { print "<br><b> Sorry that account already exists.</b><br><br>"; //print ($subset); } elseif(preg_match ('/You must specify/i', "$subset")) { print "<br><b>You must specify a password.</b><br><br>"; } else { print ($subset); print "<br><br>You may now use <b>mail.$domain</b> as your POP3 setting in your mail client or access <b>WebMail</b> by selecting <a href=http://$domain/webmail>Here</a>. <center> <br><a href=javascript:history.go(-1)>Go Back</a> </center>"; } ?> [/code[ Quote Link to comment https://forums.phpfreaks.com/topic/260427-imap-php-create-new-user-account/#findComment-1334847 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.