Koozali.org: home of the SME Server

fetchmail (multifetch)

bryan stalcup

fetchmail (multifetch)
« on: April 03, 2001, 03:12:50 AM »
PLEASE, PLEASE, add a web interface to configure fetchmail to retrieve pop3 email on a user-by-user basis! somebody!

for whatever reason, the following doesn't work, i don't understand why:

type commands as root:
cd
vi .fetchmailrc

insert a line:
poll mail.earthlink.net protocol pop3 username "someuser" password "somepassword" is "someotheruser" here

save file and exit
command: chmod 0600 .fetchmailrc

command: crontab -e

insert a line: 0 * * * * fetchmail -f /root/.fetchmailrc > /dev/null 2>&1

save file and exit

it fetches the mail, but it never appears in the user's inbox. it just disappears into a black void. where is it going? help!

bryan

Michael Maxwell

Re: fetchmail (multifetch)
« Reply #1 on: April 06, 2001, 07:55:30 AM »
Try this

poll mail.earthlink.net with proto POP3

user "someuser" there with password "somepassword" is "someotheruser" here options
flush fetchall
smtphost "mail.yourdomain.com"  


If you need the fetchmail to poll every say 10 minutes just add

set daemon 600


Michael Maxwell


bryan stalcup wrote:
>
> PLEASE, PLEASE, add a web interface to configure fetchmail to
> retrieve pop3 email on a user-by-user basis! somebody!
>
> for whatever reason, the following doesn't work, i don't
> understand why:
>
> type commands as root:
> cd
> vi .fetchmailrc
>
> insert a line:
> poll mail.earthlink.net protocol pop3 username "someuser"
> password "somepassword" is "someotheruser" here
>
> save file and exit
> command: chmod 0600 .fetchmailrc
>
> command: crontab -e
>
> insert a line: 0 * * * * fetchmail -f /root/.fetchmailrc >
> /dev/null 2>&1
>
> save file and exit
>
> it fetches the mail, but it never appears in the user's
> inbox. it just disappears into a black void. where is it
> going? help!
>
> bryan

Gary Williams

Re: fetchmail (multifetch)
« Reply #2 on: April 07, 2001, 10:56:41 AM »
Brian,



I haven't checkout why, but a year or so ago, when I first tried playing with the fetchmail.rc, I did exactly the same thing... it fetched the mail perfectly, but delivery failed silently on my server (I guessed this was a "bounce going nowhere" problem, so failure was completely silent).

Another problem I think I had (which sounds silly in hindsight), one of the users I had created (without using the nice interface) didn't have a home directory and so couldn't recieve mail. It wasn't until I had a good look at the failure reported by my email client that I realised what I had done. I now have fetchmail pulling mail from several ISPs, and dot-forwarding to several users, so each has their own copy. The main reason for this is so that each person doesn't have to leave mail on server for others to get a copy, which slows things down once the queue gets big.

What I did to solve my fetchmail dilema, was to use the web interface to get fetchmail retrieving mail from one ISP perfectly. E-smith creates a script called "fetchmail" in the etc directory. At first I went into this script with vi and copied their lines for all other mail I wanted to collect. Once I got it right, I then hacked this into their templates, so that it would stay there (be re-written) when ever I changed other settings (nothing so frustrating as hacking the files in the etc directory and then having them over-written if you change something else with the console or web interface).

The bottom line is that I never got the fetchmail.rc to work. I guess it means the system is running fetchmail, rather than whoever you set the cron job to run as (maybe there is more to it than this, but I got it to work without a minute to spare)!!

As ever, with no intention to insult, always to a check with your email client set to "leave mail on server" before you play with fetchmail. This is for anyone else reading this, because you, Brian have experienced the wrath of silent delivery failure this can cause. I lost some important email because of this, even when I was playing with other parts of the server, like the mail server, because fetchmail just keeps on fetching, whether it can deliver locally or not! Another thing that should be obvious... (but I've forgotten to do sometimes)... Always comment out your fetchmail script before you stop your mail server!

If you want any more help, give me a yell, although I can't promise to jump right to replying that day... but I'll try to help if I can. I haven't copied my file here to public display, but if you email me, I'll edit it down a bit, and send you an example of the fetchmail script (I should also try to remember which template I hacked as well if you want me to).


Gary Williams

bryan stalcup

Re: fetchmail (multifetch)
« Reply #3 on: April 09, 2001, 07:44:33 PM »
same deal. nothing is delivered. does any one have a WORKING multifetch
setup? if so, attaching WORKING files would be wonderful!

thanks!

bryan

Gary Williams

Re: fetchmail (multifetch)
« Reply #4 on: April 09, 2001, 08:16:25 PM »
Brian,

if you send me an email at eamcp@ozemail.com.au, I'll send you some
examples... I tore out some hair along the way too! I'm just not prepared to
broadcast to much of my settings nowadays, just in case I leave a "giveaway"
in there. (I'm just recovering from a breakin, so I'm still a little
security sensitive).


Gary Williams

Dan Brown

Re: fetchmail (multifetch)
« Reply #5 on: April 10, 2001, 04:08:16 AM »
Well, here's what I use for /root/.fetchmailrc:

set daemon 300 # Poll at 5-minute intervals

defaults
keep
# don't delete the messages after retrieving them
# I do this because I still want to use my normal client to get mail; I
# use the e-smith
# box as a webmail system.
# If you don't want to keep mail on the server, replace "keep" with "nokeep".

# Repeat the following three lines as necessary
poll mail.earthlink.net protocol POP3:
user earthlinkuser is localuser@mydomain.com
password earthlinkpassword;


    Now, this isn't set to run as a cron job; I need to log in as root and run fetchmail whenever the machine's been rebooted.  Once it's been started, though, it runs every five minutes.

    Probably a better solution would be for each user to have a ~/.fetchmailrc file, which would control mail retrieval for that user.  As I am both the admin and the only user of my e-smith box, I haven't bothered with this.

Togan Muftuoglu

Re: fetchmail (multifetch)
« Reply #6 on: April 11, 2001, 12:27:47 AM »
Hi,

I did a setup today and I figured that by playing with the /etc fetchmail setup I could get all the mails needed from various isp accounts and deleted to the appropriate local users. rather then creating the /root/.fetchmailrc I found this more effective. Most probably with an update this will be changed but till then I have a working setup.

bryan stalcup

Re: fetchmail (multifetch)
« Reply #7 on: April 12, 2001, 07:57:18 AM »
Togan,

would you post your config files? i still haven't gotten anything working.

thanks!
bryan

Togan Muftuoglu

Re: fetchmail (multifetch)
« Reply #8 on: April 26, 2001, 12:37:19 AM »
Sorry for a late reply

Here is what I did from I copied the template files of fetchmail to custom-templates directory edited 50multi-drop and then expand the custom template

 
{
    use esmith::config;
    use esmith::db;

    $OUT = '';

    local %services = (fetchmail => $fetchmail);

    my $status = db_get_prop(\%services, "fetchmail", "status")
                                                        || 'disabled';
    my $method = db_get_prop(\%services, "fetchmail", "Method")
                                                        || 'standard';

    if ($status eq "enabled" && $method eq 'multidrop')
    {
        # Write a fetchmail command which connects to a POP
        # server, retrieves all mail from a single account,
        # and feeds it to the local SMTP server.

        my $envelopeSpec =
            db_get_prop(\%services, "fetchmail", "SecondaryMailEnvelope");
        my $SecondaryMailServer =
            db_get_prop(\%services, "fetchmail", "SecondaryMailServer");
        my $SecondaryMailAccount =
            db_get_prop(\%services, "fetchmail", "SecondaryMailAccount");
        my $SecondaryMailPassword =
            db_get_prop(\%services, "fetchmail", "SecondaryMailPassword");
        $envelopeSpec = defined $envelopeSpec ?
                "envelope \"$envelopeSpec\"\n" : "";

        my $verbosity = db_get_prop(\%services, "fetchmail", "Verbosity")
                    || "";

        local %domains;
        tie %domains, 'esmith::config', '/home/e-smith/domains';

        my $locals = join(' ',
                            ("$DomainName",
                                grep
                                    {db_get_type(\%domains, $_) eq 'domain'}
                                        keys %domains));

        $OUT .= "# multi-drop configuration; fetchmail ";
        $OUT .= "retrieves all mail from a remote POP mailbox:\n";
        $OUT .= "\n";
        $OUT .= "/usr/bin/fetchmail --syslog $verbosity ";
        $OUT .= "--fetchmailrc - <        $OUT .= "\n";
        $OUT .= "set postmaster \"postmaster\"\n";
        $OUT .= "set bouncemail\n";
        $OUT .= "set properties \"\"\n";
        $OUT .= "\n";
        $OUT .= "poll $SecondaryMailServer\n";
        $OUT .= $envelopeSpec;
        $OUT .= "    protocol POP3\n";
        $OUT .= "    localdomains $locals\n";
        $OUT .= "       username $SecondaryMailAccount ";
        $OUT .= "password $SecondaryMailPassword to * here\n";
        $OUT .= "           smtphost localhost\n";
        $OUT .= "           smtpaddress $DomainName\n";
        $OUT .= "           fetchall\n";
        $OUT .= "           forcecr\n";
        $OUT .= "\n";
        $OUT .= "poll mail.firstisp.net\n";
        $OUT .= $envelopeSpec;
        $OUT .= "    protocol POP3\n";
        $OUT .= "    localdomains $locals\n";
        $OUT .= "       username user1 ";
        $OUT .= "password xyz to user3 here\n";
        $OUT .= "           smtphost localhost\n";
        $OUT .= "           smtpaddress $DomainName\n";
        $OUT .= "           fetchall\n";
        $OUT .= "           forcecr\n";
        $OUT .= "\n";
        $OUT .= "poll mail.secondisp.net\n";
        $OUT .= $envelopeSpec;
        $OUT .= "    protocol POP3\n";
        $OUT .= "    localdomains $locals\n";
        $OUT .= "       username user2 ";
        $OUT .= "password abcd to user16 here\n";
        $OUT .= "           smtphost localhost\n";
        $OUT .= "           smtpaddress $DomainName\n";
        $OUT .= "           fetchall\n";
        $OUT .= "           forcecr\n";
        $OUT .= "\n";
        $OUT .= "EOF";

    }
}