Ubuntu – How to i set a default account in Heirloom-mailx

emailmailxUbuntu

How can i set a default account in Heirloom-mailx?

I have defined an account in /etc/nail.rc that is usable via mail -A accountname but i'd like to set this account to be used by default so i can omit the -A parameter.

The man page under http://heirloom.sourceforge.net/mailx/mailx.1.html doesn't seem to include setting defaults.

Best Answer

If you want to maintain multiple accounts but select one by default, add an account command after the accounts are defined to select it

Example rc file:

account myimap {
    set folder=imap://user@host
    set record=+Sent
    set imap-keepalive="5"
}
account local {
    set folder=.local/maildir
    unset record
}
# Now select myimap as default account on startup:
account myimap

Now on invoking mailx, it will connect to myimap, but you can still switch between the two accounts with account local and account myimap (and whatever other accounts you define) in interactive mode, or pick which one using mailx -A myimap or mailx -A local (and whatever other accounts) when invoking from the commandline.

(tested with Heirloom mailx version 12.5 6/20/10)

Related Question