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

5

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.

kioopi

Posted 2014-08-12T12:48:40.560

Reputation: 173

Answers

2

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)

John O'M.

Posted 2014-08-12T12:48:40.560

Reputation: 281

6

Just get rid of the account wrapper you put around the settings.

nail.rc

Instead of:

# other mail config
...

account gmail {
  set smtp-use-starttls
  set smtp-auth=login
  set smtp=smtp://smtp.gmail.com:587
  set smtp-auth-user=username@gmail.com
  set smtp-auth-password="blahblah"
}

Use:

# other mail config
...

set smtp-use-starttls
set smtp-auth=login
set smtp=smtp://smtp.gmail.com:587
set smtp-auth-user=username@gmail.com
set smtp-auth-password="blahblah"

It will use those as the default settings.

Thien

Posted 2014-08-12T12:48:40.560

Reputation: 176

Thanks a lot. Will check when i get back to this project and accept the answer then. – kioopi – 2014-10-25T14:59:43.277