Zubrag.com :: Forum

zubrag.com => cPanel Scripts => Topic started by: fabcoe on July 27, 2007, 08:39:03 AM



Title: Cannot create email account. Possible reasons: "fopen" functi.....
Post by: fabcoe on July 27, 2007, 08:39:03 AM
Hi

I keep receiving this error, and my safe mode config is Off.
 :-[
What else could be wrong?


Title: Re: Cannot create email account. Possible reasons: "fopen" functi.....
Post by: zubrag on July 27, 2007, 11:20:02 AM
Lets try working via sockets.
Replace this code:
Code:
  // Create email account
  $f = fopen ("http://$cpuser:$cppass@$cpdomain:2082/frontend/$cpskin/mail/doaddpop.html?email=$euser&domain=$edomain&password=$epass&quota=$equota", "r");
  if (!$f) {
    $msg = 'Cannot create email account. Possible reasons: "fopen" function allowed on your server, PHP is running in SAFE mode';
  }
  else {
    $msg = "<h2>Email account {$euser}@{$edomain} created.</h2>";

  }

with:
Code:
  $sock = fsockopen($cpdomain,2082);
  if(!$sock) {
    print('Socket error');
    exit();
  }

  $request = "/frontend/$cpskin/mail/doaddpop.html?email=$euser&domain=$edomain&password=$epass&quota=$equota";
  $authstr = "$cpuser:$cppass";
  $pass = base64_encode($authstr);
  $in = "GET $request\r\n";
  $in .= "HTTP/1.0\r\n";
  $in .= "Host:$host\r\n";
  $in .= "Authorization: Basic $pass\r\n";
  $in .= "\r\n";

  fputs($sock, $in);
  $result = '';
  while (!feof($sock)) {
    $result .= fgets ($sock,128);
  }
  fclose( $sock );

  // Check result
  if (ereg ("already exist", $result)) {
    $msg = "<h2>Email account {$euser}@{$edomain} already exists.</h2>";
  }
  else {
    $msg = "<h2>Email account {$euser}@{$edomain} created.</h2>";
  }