Results 1 to 23 of 23
  1. #1
    Join Date
    Mar 2004
    Location
    Toronto
    Posts
    51

    URGENT: merging email from old server with new server

    Hi all,

    Topic pretty much says it all.

    Got a client whose domain we transferred to our new servers, but in the transition there seems to have been mail deposited at the old server.

    CAN I configure our new server to pick up this mail?

    Running RHE, with Exim, Cpanel/WHM.

    Thanks!!!!

    Aaron

  2. #2
    Join Date
    Dec 2003
    Location
    UK
    Posts
    652
    You'd need the client's user / password, you could then perhaps use fetchmail to collect it & deliver to your SMTP server.

    I usually suggest that the transferring client configures their mail client to point to both servers by IP in addition to the normal setup for a few days to allow smooth transfer of mail. I've done this many times over the years and not lost any mail.

  3. #3
    Join Date
    Mar 2004
    Location
    Toronto
    Posts
    51
    Originally posted by monaghan
    You'd need the client's user / password, you could then perhaps use fetchmail to collect it & deliver to your SMTP server.

    I usually suggest that the transferring client configures their mail client to point to both servers by IP in addition to the normal setup for a few days to allow smooth transfer of mail. I've done this many times over the years and not lost any mail.
    Hi there,

    Thanks for your reply.

    I agree on the dual email client setups using the IP, however, problem in this case is client has over 35 email accounts for their company.

    The IT guy won't be happy telling him he needs to create another set of email logins for a few days

    Fetchmail... quick overview of how to set it up? I'm looking at the man page now.

    Thankls!

    A

  4. #4
    Join Date
    Jun 2003
    Posts
    673
    I've used this little script to copy mail from one server to another before. It reads a list of whitespace-separated email addresses and passwords from STDIN, one pair per line.
    Code:
    #!/usr/bin/perl
    
    use Mail::POP3Client;
    use Net::SMTP;
    
    $pop_server = 'a.b.c.d';
    $smtp_server = '127.0.0.1';
    $| = 1;
    
    while (<>) {
      chomp;
      s/^\s//;
      s/\s$//;
      s/#.*//;
      next if (!$_);
    
      my ($address, $password) = split (/\s/, $_);
      my ($user, $domain) = split (/\@/, $address);
    
      my $pop = new Mail::POP3Client (USER => $address, PASSWORD => $password,
                                      HOST => $pop_server, AUTH_MODE => PASS);
    
      $count = $pop->Count();
      if ($count < 0) {
        warn "$address -- authentication failed\n";
        next;
      }
    
      $size = $pop->Size();
      print "$address -- $count messages, $size bytes: ";
    
      for ($i = 1; $i <= $count; $i++) {
        my $smtp = Net::SMTP->new ($smtp_server);
        $smtp->mail ([email protected]');
        $smtp->to ($address);
        $smtp->data ($pop->Head ($i) . $pop->Body ($i));
        print ".";
      }
    
      print " done.\n";
    }

  5. #5
    Join Date
    Mar 2004
    Location
    Toronto
    Posts
    51
    Originally posted by dan_erat
    I've used this little script to copy mail from one server to another before. It reads a list of whitespace-separated email addresses and passwords from STDIN, one pair per line.
    Code:
    #!/usr/bin/perl
    
    use Mail::POP3Client;
    use Net::SMTP;
    
    $pop_server = 'a.b.c.d';
    $smtp_server = '127.0.0.1';
    $| = 1;
    
    while (<>) {
      chomp;
      s/^\s//;
      s/\s$//;
      s/#.*//;
      next if (!$_);
    
      my ($address, $password) = split (/\s/, $_);
      my ($user, $domain) = split (/\@/, $address);
    
      my $pop = new Mail::POP3Client (USER => $address, PASSWORD => $password,
                                      HOST => $pop_server, AUTH_MODE => PASS);
    
      $count = $pop->Count();
      if ($count < 0) {
        warn "$address -- authentication failed\n";
        next;
      }
    
      $size = $pop->Size();
      print "$address -- $count messages, $size bytes: ";
    
      for ($i = 1; $i <= $count; $i++) {
        my $smtp = Net::SMTP->new ($smtp_server);
        $smtp->mail ([email protected]');
        $smtp->to ($address);
        $smtp->data ($pop->Head ($i) . $pop->Body ($i));
        print ".";
      }
    
      print " done.\n";
    }
    Wow!

    Thanks for that!

    One question. Yes, I know I am a dolt

    I have to declare the variables $user and $password, right?

    Thanks!!

    A

  6. #6
    Join Date
    Jun 2003
    Posts
    673
    No, they are read from the file that you pipe into the script. You need to set $pop_server at the top of the file, and the return address that's set on the $smtp->mail() line near the bottom of the file.

  7. #7
    Join Date
    Mar 2004
    Location
    Toronto
    Posts
    51
    Ok.. I think I know what you mean here.

    Do you happen to have a sample of what this other file (structure) would look like?

    I'm a bit confused on the logic structure of the entire thing.

    *shrugs*

    Thanks!

    A

  8. #8
    Join Date
    Jun 2003
    Posts
    673
    ./script.pl <users.txt

    where users.txt looks like this:

    [email protected] password1
    [email protected] password2
    etc.

  9. #9
    Join Date
    Mar 2004
    Location
    Toronto
    Posts
    51
    ok. I twig now!

    Do I have to compile the script.pl file or just make it an executable to pipe into?

    Thanks!

    Sorry for allll the questions.

    A

  10. #10
    Join Date
    Mar 2004
    Location
    Toronto
    Posts
    51
    Actually!

    I just did ./script.pl <file.txt and this is the error I got:

    Can't locate Mail/POP3Client.pm in @INC (@INC contains: /usr/lib/perl5/5.8.1/i686-linux /usr/lib/perl5/5.8.1 /usr/lib/perl5/site_perl/5.8.1/i686-linux /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl .) at ./mailscript.pl line 3.
    BEGIN failed--compilation aborted at ./mailscript.pl line 3.


    ANY clue?

  11. #11
    Join Date
    Jun 2003
    Posts
    673
    You just need to make it executable. You will need to install the modules that are listed at the beginning of the file from CPAN, if you don't have them installed already.

  12. #12
    Join Date
    Mar 2004
    Location
    Toronto
    Posts
    51
    hi and thanks again.

    Quick Q... I did this from the cpan command prompt:

    install POP3Client/


    I get the following:

    Can't access URL ftp://ftp.perl.org/pub/CPAN/authors/id/POP3Client/.

    Please check, if the URLs I found in your configuration file () are valid.
    The urllist can be edited. E.g. with 'o conf urllist push ftp://myurl/'

    Could not fetch authors/id/POP3Client/
    Giving up on '/root/.cpan/sources/authors/id/POP3Client'
    Note: Current database in memory was generated on Fri, 02 Apr 2004 07:51:50 GMT


    HOW do I get this module so I can install it?

    Thanks so much!

    Aaron

  13. #13
    Join Date
    Jun 2003
    Posts
    673
    You could download the tarballs for the modules and install them manually. See http://search.cpan.org/.

  14. #14
    Join Date
    Mar 2004
    Location
    Toronto
    Posts
    51
    Ugh. This Cpan thing looked easy *chuckles*

    Anything I should know before going the tarball route?

    A

  15. #15
    Join Date
    Jun 2003
    Posts
    673
    Yeah, the name of the module is "Mail::POP3Client". It should install if you run
    Code:
    perl -MCPAN -e 'install Mail::POP3Client'

  16. #16
    Join Date
    Mar 2004
    Location
    Toronto
    Posts
    51
    Woot!

    I got it installed using cpan

    Now, quck question anout the script above... what EXACTLY does it do? Does it deliver the mail to an address or something?



    A

  17. #17
    Join Date
    Jun 2003
    Posts
    673
    For each account that you give it, it logs in to the old server via POP3, downloads all of the messages there, and resends them via SMTP to the the same address on the new server. It leaves the messages on the old server after downloading them. I recommend that you run it on a single test account first to make sure that it does what you want.

  18. #18
    Join Date
    Mar 2004
    Location
    Toronto
    Posts
    51

  19. #19
    Join Date
    Mar 2004
    Location
    Toronto
    Posts
    51
    by the way.

    You rock! Seriously!

    I greatly appreciate the time you are offering to help me out.

    A

  20. #20
    Join Date
    Mar 2004
    Location
    Toronto
    Posts
    51
    Ok! I figured out if I changed this:

    $smtp->to ($address);

    TO:

    $smtp->to ([email protected]');


    It will deliver perfectly. Now, here's the problem... how do I get it so that I can put the address in the .txt file and NOT have to specificy it individually for each and every email acocunt at my older/new server?

    That would be time consuming

    Thanks!

    A

  21. #21
    Join Date
    Jun 2003
    Posts
    673
    No problem; it's a slow day at the office. :)

    How about this (completely untested)? It wants input in the format "old_address new_address old_password".
    Code:
    #!/usr/bin/perl
    
    use Mail::POP3Client;
    use Net::SMTP;
    
    $pop_server = 'a.b.c.d';
    $smtp_server = '127.0.0.1';
    $return_address = [email protected]';
    $| = 1;
    
    while (<>) {
      chomp;
      s/^\s//;
      s/\s$//;
      s/#.*//;
      next if (!$_);
    
      my ($old_address, $new_address, $password) = split (/\s/, $_);
    
      my $pop = new Mail::POP3Client (USER => $old_address, PASSWORD => $password,
                                      HOST => $pop_server, AUTH_MODE => PASS);
    
      $count = $pop->Count();
      if ($count < 0) {
        warn "$old_address -- authentication failed\n";
        next;
      }
    
      $size = $pop->Size();
      print "$old_address -- $count messages, $size bytes: ";
    
      for ($i = 1; $i <= $count; $i++) {
        my $smtp = Net::SMTP->new ($smtp_server);
        $smtp->mail ($return_address);
        $smtp->to ($new_address);
        $smtp->data ($pop->Head ($i) . $pop->Body ($i));
        print ".";
      }
    
      print " done.\n";
    }

  22. #22
    Join Date
    May 2004
    Posts
    1
    martekbiz

    were you successful in your attempts?

  23. #23
    Join Date
    Jun 2003
    Posts
    673
    redsquall: The forum software isn't letting me reply to your PM for some reason, so to answer your question about how to make it delete the old messages, you can try adding "$pop->Delete ($i);" on a new line after the line beginning with "$smtp->data". You might also need to add "$pop->Close ();" on a new line after the last print() call in the script. Untested.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •