Koozali.org: home of the SME Server

Using Fetchmail to transfer mails from web hotel to SME server?

Offline holck

  • *
  • 322
  • +1/-0
I have a setup where mydomain.dk is hosted by a web hotel. All mails to user@mydomain.dk are then forwarded from the web hotel to user@myprivatedomain.dk, where my SME server hosts myprivatedomain.dk. The reason for this setup is that in situations where my Internet connection is lost, people can still send mails to my users. The web hotel keeps the mails until they again can be forwarded to my server.

The problem I have is that the web hotel doesn't delete the mails they forward, so the mailboxes at the web hotel fill up. I talked to their support and they suggest that I use fetchmail to transfer the mails, instead of asking the web hotel to forward them.

Do anyone have experiences or suggestions that can help me? Is Fetchmail a good solution in this situation?

Best regards
Jesper, Denmark
......

Offline mmccarn

  • *
  • 2,651
  • +10/-0
Re: Using Fetchmail to transfer mails from web hotel to SME server?
« Reply #1 on: March 06, 2010, 03:47:14 PM »
SME uses fetchmail to retrieve emails if you select 'Multidrop' in the server-manager E-mail panel:
http://wiki.contribs.org/SME_Server:Documentation:Administration_Manual:Chapter13#E-mail_Retrieval

There is a fetchmail contrib that allows greater flexibility:
http://wiki.contribs.org/Fetchmail

Dungog has two separate paid packages for fetching external email:
http://www.dungog.net/wiki/Dungog-getmail (mentions but deprecates dungog-multipop)

Fetchmail *will* deliver duplicate emails to users in some situations:
http://catb.org/~esr/fetchmail/fetchmail-FAQ.html#M8

Offline holck

  • *
  • 322
  • +1/-0
Re: Using Fetchmail to transfer mails from web hotel to SME server?
« Reply #2 on: March 09, 2010, 10:26:39 PM »
Thanks for all the info and links. To me, having a server with 20+ users, Dungog's solution seems best, but I have to consider the price... And I still wonder, will the Fetchmail solutions actually remove the mails from the remote server as it collects them?

Jesper, Denmark
......

Offline mmccarn

  • *
  • 2,651
  • +10/-0
Re: Using Fetchmail to transfer mails from web hotel to SME server?
« Reply #3 on: March 09, 2010, 10:31:18 PM »
I know it can be configured to do so...

Of course, you could do the same thing by setting up an email client somewhere that accesses the web hotel mailbox using POP3 and deletes anything over 3 days old (or something like that).

Or, a quick search found a bash script to delete POP3 emails, which could be scheduled via cron:
http://www.cyberciti.biz/tips/remove-or-delete-all-emails-message-from-a-pop3-server.html

Offline janet

  • *****
  • 4,812
  • +0/-0
Re: Using Fetchmail to transfer mails from web hotel to SME server?
« Reply #4 on: March 09, 2010, 11:47:28 PM »
holck

Quote
The reason for this setup is that in situations where my Internet connection is lost, people can still send mails to my users.


How long does your Internet connection "get disconnected" for ?

If it is only for a few hours or even a day or two, other mail servers will keep retrying to send mail to your sme smtp server.
In most cases where there is an erratic Internet connection to your sme server, then configuring your sme server as a smtp mail server (default mode), will work perfectly fine as the sending smtp mail servers will keep retrying to send your mail to your smtp server for up to 7 days, so when your sme server comes back online mail will be redelivered soon after (ie at the next delivery retry).
Please search before asking, an answer may already exist.
The Search & other links to useful information are at top of Forum.

Offline holck

  • *
  • 322
  • +1/-0
Re: Using Fetchmail to transfer mails from web hotel to SME server?
« Reply #5 on: March 10, 2010, 10:17:39 AM »
mmcarn:

Good idea to use a simple script, that is a very easy solution. I'm more familiar with Perl than with shell programming, so I found the Perl module Mail::POP3Client http://search.cpan.org/~sdowd/Mail-POP3Client/POP3Client.pm. Based on that I wrote this small script:
Code: [Select]
#!/usr/bin/perl
 use Mail::POP3Client;
  $pop = new Mail::POP3Client( USER     => "username",
                               PASSWORD => "secret",
                               HOST     => "mail.mydomain.com",
                               USESSL   => true,
                               DEBUG => 0);
  print "Deleting all but 1000 of ", $pop->Count(), " messages for ", $pop->User(), "\n";
 
  for( $i = 1; $i <= ($pop->Count()) - 1000; $i++ ) {
    $pop->Delete($i);
    print "."
  }
  $pop->Close();
  print "\nFinished!\n";
It seems to work - and is more elegant than the shell script, as it listens to the mail server, and not simply waits a second and assumes that everything is OK. It is also much faster.

Mary:

You are completely right, and maybe I'm worrying too much, but I had one experience where my Internet provider simply informed me that my connection would be closed to 2 days because of some technical changes. And at the same time, one of my users were very anxious to receive an important email. So since then I have used the sketched, but in some ways rather clumsy solution.

Thanks for all help :-)
« Last Edit: March 10, 2010, 10:27:32 AM by holck »
......