2

The goal is to use Thunderbird on my server as a filter for my mails. So Thunderbird should always run in background after boot, without me logging in.

I have this script below, which I want to put into rc.local. The problem is now that I do not have a display specified and I can not specify one, as I am logged in over ssh without X-forwarding.

me@desktop ~ $ echo $DISPLAY

me@desktop ~ $

But I don't need to specify a display, as I do not plan to interact with the GUI anyway. I suspect however, that I have to specify one.

Trying to start Thunderbird:

#!/bin/bash
su - me -c "/usr/bin/thunderbird" &

How can I get this working?

1 Answer 1

2

You have two requirements that conflict with each other, so the short answer is that you can not achieve your goal with thunderbird without logging in.

Using an interactive GUI client as a background server process to filter mail is not the best solution. Thunderbird does not run without a display. However, if your server logs "you" into a desktop environment after boot up, you can set thunderbird to start automatically. The instructions for this will depend on which desktop you prefer, gnome/kde/etc. Even so, I would not recommend this approach.

Procmail (which your linux distribution might have installed by default) is designed for the purpose of filtering email and does not need a display. You can find a tutorial, simple and straight forward here; http://www.panix.com/~elflord/unix/procmail.html

Examples are provided for setting up the filter, integrating with your MTA, and creating rules to forward, file, or discard messages.

In a nutshell, your MTA should understand .forward files in your $HOME directory. This file holds a command to call procmail. You will also need a ~/.procmail directory to hold the rules and configuration files procmail will use to perform it's duties. And finally a ~/.procmailrc file to define some preferences, defaults, location of your filtering recipes, and your default mail directory.

In your home directory, preparation goes like this...

mkdir ~/.procmail; echo "|IFS=' ' && exec /usr/bin/procmail || exit 75 #your_user_name" >> ~/.forward

The above assumes your procmail executable is located in /usr/bin.

~/.procmailrc (contents copied from the panix.com link above)

VERBOSE=off
MAILDIR=$HOME/mail # elm users might use $HOME/Mail instead
PMDIR=$HOME/.procmail
DEFAULT=/var/spool/mail/elflord
LOGFILE=$PMDIR/log
INCLUDERC=$PMDIR/general.rc
# INCLUDERC=$PMDIR/other.rc
# add as many INCLUDERC's as you like
# end of .procmailrc

Actual filters...

To file mail into a folder named bill for messages from Bill.

:0
* ^From.*bill@example\.com
bill

To save/keep messages in your inbox for users in your same domain.

:0
* ^From.*example\.com
$DEFAULT

To separate your mailing list messages from your inbox, file to a folder called my-lists.

* ^From.*my.*subscribed.*list.*@
my-lists

To forward the message matching the filter to another address.

* ^Subject.*something-or-other
! [email protected]

To combine multiple actions to the same filter, the syntax does not change much. This will keep a copy in your inbox and file into another folder.

:0
* ^Cc.*[email protected]
* ^Cc.*me
{
    :0 c
    $DEFAULT

    :0
    SOME_FOLDER
}

Considering this does not answer your specific question, "how to get this working", it does provide an alternative solution to your underlying requirement, to filter email.

3
  • If the linux documentation project goes away, many of us will be in trouble. From the tutorial perspective, there are many available via good old google searching, and I did not want to plagiarize anything from the one I referenced. Sep 6, 2016 at 18:03
  • So how would I set up procmail to get my mails over imap? I don't run a mail server if you thought that. I just fetch mails from an external provider.
    – doc
    Sep 6, 2016 at 21:30
  • :) That is a new question... The answer is you don't. You get your imap messages with thunderbird. :) Procmail just gets your mail all sorted out before thunderbird sees it. Also, it is possible (I used to do it in the '90s) to configure fetchmail and procmail together, and then retrieve/manage/view that mail with pegasus, eudora, thunderbird, etc. Sep 6, 2016 at 21:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .