Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > Tips/Tricks/Mods

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 21st March 2013, 17:04
ZeroEnna ZeroEnna is offline
Member
 
Join Date: Aug 2010
Posts: 74
Thanks: 9
Thanked 1 Time in 1 Post
Default Mail Account Migration Script gives errors

Hello everyone,

to help migrating the mail accounts from one server to another, a good friend of mine wrote a script using the Remote API.
First of all, here's the code:

PHP Code:
<?php

#################################
### (c)2013 by Marcel Beriere ###
#################################

function check_login($username$password) {
  
$result false;

  
$authOK   "235 ";
  
$ehloEnd  "250 ";
  
$password base64_encode($password);
  
$username base64_encode($username);

  
$socket fsockopen("85.214.88.184"25$errorNo$errorStr60);
  if (
$socket) {
    
$input fgets($socket);
    
fwrite($socket"EHLO Kibo.FM\n");

    do {
      
$input fgets($socket);
      
$done  = (stripos($input$ehloEnd) !== false);
    } while (!
$done);

    
fwrite($socket"AUTH LOGIN\n");
    
$input fgets($socket);
    
fwrite($socket$username "\n");
    
$input fgets($socket);
    
fwrite($socket$password "\n");
    
$input fgets($socket);

    
$result = (stripos($input$authOK) !== false);

    
fwrite($socket"QUIT\n");
    
fclose($socket);
  } else {
    
$result "Keine Verbindung zum Server";
  }
function 
create_mail($email$emailpass){
  
$username 'webservices';
  
$password 'password';
  
$soap_location 'https://37.221.195.129:8080/remote/index.php';
  
$soap_uri 'https://37.221.195.129:8080/remote/';

  
$client = new SoapClient(null, array('location' => $soap_location,
                                     
'uri'      => $soap_uri,
                                                                         
'trace' => 1,
                                                                         
'exceptions' => 1));


  try {
        if(
$session_id $client->login($username,$password)) {
                
//echo 'Logged successfull. Session ID:'.$session_id.'<br />';
        
}

        
//* Set the function parameters.
        
$client_id 1;
        
$params = array(
                        
'server_id' => 1,
                        
'email' => $email,
        
'login' => $email,
                        
'password' => $emailpass,
                        
'name' => $email,
                        
'uid' => 5000,
                        
'gid' => 5000,
                        
'maildir' => '',
                        
'quota' => 0,
                        
'cc' => '',
                        
'homedir' => '',
                        
'autoresponder' => 'n',
                        
'autoresponder_start_date' => '',
                        
'autoresponder_end_date' => '',
                        
'autoresponder_text' => 'hallo',
                        
'move_junk' => 'n',
                        
'custom_mailfilter' => 'spam',
                        
'postfix' => 'y',
                        
'access' => 'n',
                        
'disableimap' => 'n',
                        
'disablepop3' => 'n',
                        
'disabledeliver' => 'n',
                        
'disablesmtp' => 'n'
                        
);

        
$affected_rows $client->mail_user_add($session_id$client_id$params);

        
//echo "New user: ".$affected_rows."<br>";

        
if($client->logout($session_id)) {
                
//echo 'Logged out.<br />';
        
}


  } catch (
SoapFault $e) {
        
//echo $client->__getLastResponse();
        //die('SOAP Error: '.$e->getMessage());
  
if (isset($affected_rows)) {
    return 
true;
  }else{
    return 
false;
  }
}
$email $_POST['email'];
if(isset(
$_POST['email'], $_POST['passwort'])) {
  if (
check_login($_POST['email'], $_POST['passwort']) == 1) {
    if (
create_mail($_POST['email'], $_POST['passwort'])){
      echo 
"Das E-Mailkonto wurde erfolgreich &uuml;bertragen";
            
$empfaenger "info@webservices-schroeder.de";
            
$absendername "Mail Move Script";
            
$absendermail "info@webservices-schroeder.de";
            
$betreff "Mailpostfach umgezogen";
            
$text "Hallo Sascha,
                     Die E-Mailadresse $email wurde umgezogen."
;
            
mail($empfaenger$betreff$text"From: $absendername <$absendermail>");
        echo 
"<br>";
        echo 
"Falls sie noch weitere Postf&auml;cher umziehen m&ouml;chten, klicken Sie bitte hier:";
        echo 
"<br>";
        echo 
"<a href='mail.html'>Weiteres Postfach umziehen.</a>";
    }else{
      echo 
"Das E-Mailkonto wurde schon &uuml;bertragen";
    }
  }else{
    echo 
"Das angegebene Konto konnte nicht gefunden werden oder die Daten sind nicht korrekt";
  }
}
?>
Now, creating mailboxes with this script gives the following errors on the target server:

Code:
Mar 19 18:12:01 moon dovecot: deliver(wildwolf@kibo.fm): sieve: failed to open logfile (LOGGING TO STDERR): open(/.sieve.log) failed: Permission denied (euid=5000(vmail) egid=5000(vmail))
Mar 19 18:12:01 moon dovecot: deliver(wildwolf@kibo.fm): sieve: failed to open script /.sieve (view logfile /.sieve.log for more information)
Mar 19 18:12:01 moon dovecot: deliver(wildwolf@kibo.fm): file dict commit: file_dotlock_open(/var/vmail/kibo.fm/wildwolf/.quotausage) failed: No such file or directory
Mar 19 18:12:01 moon dovecot: deliver(wildwolf@kibo.fm): dict quota: Quota update failed, it's now desynced
Mar 19 18:21:00 moon dovecot: deliver(manta@kibo.fm): sieve: failed to open logfile (LOGGING TO STDERR): open(/.sieve.log) failed: Permission denied (euid=5000(vmail) egid=5000(vmail))
Mar 19 18:21:00 moon dovecot: deliver(manta@kibo.fm): sieve: failed to open script /.sieve (view logfile /.sieve.log for more information)
Mar 19 18:21:00 moon dovecot: deliver(manta@kibo.fm): file dict commit: file_dotlock_open(/var/vmail/kibo.fm/manta/.quotausage) failed: No such file or directory
Mar 19 18:21:00 moon dovecot: deliver(manta@kibo.fm): dict quota: Quota update failed, it's now desynced
In what way do I have to alter the code? Or is there a general problem?

Kind Regards

ZeroEnna
Reply With Quote
Sponsored Links
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in using : perfect-server-ubuntu-12.10-apache2-bind-dovecot-ispconfig-3, rezabagheri Installation/Configuration 7 30th October 2012 23:55
Postfix/courier/Centos 6 cant send email to external email servers maxtorzito Installation/Configuration 14 7th October 2011 11:56
ISPconfig 3.0.3.2 postfix not relaying outgoing attachments mychoice2009 Installation/Configuration 3 13th April 2011 18:42
dovecot: lda: Fatal: Unknown user dpicella Installation/Configuration 1 22nd August 2010 03:59
Why did Squirrelmail, Dovecot/IMAP & Outbound mail break? websissy Technical 4 29th October 2009 23:39


All times are GMT +2. The time now is 10:41.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.