Using Qmail as backup "push" email server with some POP accounts

I can’t think of a way to do this, but wanted to see if anyone had any ideas.

I know I can setup my Iworx server to provide a backup mail server by just adding the domain to the rcpthosts…basically allowing the backup server to be a valid relay for the primary server. The email comes in, get stuck in the qmail queue and keeps trying to deliver to the primary server until it gets delivered or times out.

What I wanted to do is keep this system in place, but also allow some users to have access to the email on the backup server directly so that they are never down.

I tried setting up a domain as a full vpopmail domain and then adding to .qmail-default (where 111.111.111.111 is the primary mail server)

|qmail-remote '[111.111.111.111]' "$SENDER" "$EXT@$HOST"

I then create .qmail-someuser for the user that get pop boxes with the default delivery code.

This kind of worked, but using the qmail-remote on command line directly tried to send email one time. When it fails (because the primary server is down) the email is just lost…no bounce, not put into queue.

I have a feeling without doing a bunch of custom stuff there isn’t a good way to do this.

Just an update on this. I went a different route and created a system run PHP script that scans the normal directories for emails. I then read in the emails and parse out the TO: FROM: SUBJECT: and then the mail using qmail-remote.

Hi Justin,

I was wondering if you could elaborate on what you did. We’re currently in need of a solution just like what you mentioned.

Thanks,
Brian

Kind of late, but basically I scanned all the Maildir directories using PHP (just simple dir listing and reading files). Then I used mimeDecode.php (believe this is a PEAR library) to extract the From: address header from the email.

Then I use qmail-remote command line and loop through all the email files:

 exec("cat " . $mailDir . $mailbox . "/Maildir/$maildirDirectory/" . $emails . " | /var/qmail/bin/qmail-remote '$mailHost' '$fromAddress' '$mailTo'", $output);

You can then read the $output variable to read in the status, to see if it went through or had an error. I then write this info to a log file.

qmail-remote works pretty well, but I have one client that for some reason I get a lot of temporary failures before emails from the backup server get pushed through. I’m not sure why though, because I’ve done a manual telnet test to their SMTP server from the backup server and it works fine.