Discussion:
GNUS and many Mail Accounts
(too old to reply)
Roderick
2018-05-23 07:32:18 UTC
Permalink
It seems, gnus is more an old newsreader than a conventional mail client.

I have many mail accounts. When I start gnus, I do not want a connection
to every account, but to select first to what account to connect for
reading, and similar for writing mail. Just as is the case for
example with alpine.

I there a standard way to do this?

Is there a way to tell gnus what init file to use instead of
always using .gnus? Sure, an elisp program in .gnus could
do it, but is there a standard way?

Thanks!
Michael Kallweitt
2018-05-23 13:43:24 UTC
Permalink
Post by Roderick
It seems, gnus is more an old newsreader than a conventional mail client.
All the Gnus experts are in gnu.emacs.gnus . Better ask your question there.
--
www.wasfuereintheater.com - Neue Theaterprojekte im Ruhrpott
»DAS UNBEKANNTE SCHÖN ZU FINDEN. DEM UNVERSTANDENEN MIT WÄRME ZU BEGEGNEN.
DAS IST WAHRE LIEBE« Barbara Bollwahn, https://www.taz.de/!472086/
Ivan Shmakov
2018-06-29 13:10:51 UTC
Permalink
Post by Roderick
It seems, gnus is more an old newsreader than a conventional mail client.
I have many mail accounts. When I start gnus, I do not want a
connection to every account, but to select first to what account to
connect for reading, and similar for writing mail. Just as is the
case for example with alpine.
Is there a standard way to do this?
I do it by configuring all the mailboxes I need (in *Group*:
G m Box RET nnimap:imap.example.com RET) and then ‘unsubscribing’
from them (u; note that this is /not/ the same as ‘killing’, C-k).

When Gnus gets loaded, L in *Group* shows all the mailboxes
(including unsubscribed ones), which can then be accessed as
needed.

The same actually applies to accessing newsgroups on the news
servers I use; like:

U 35: nntp+news.aioe.org:comp.emacs
U 9: nntp+news.eternal-september.org:rec.humor.oracle
U 17409: nntp+news.gmane.org:gmane.discuss
U 147150: nntp+news.gmane.org:gmane.emacs.bugs
U 78664: nntp+news.povray.org:povray.general

(Basically, the only “groups” I’m “subscribed” to in Gnus are
whatever local ones the host may have. Commonly that means my
‘sent’ and ‘posted’ mailboxes, and also local copies of Debian
and http://debbugs.gnu.org/ bugs.)

Now, sending mail (via an ESMTP(S) mail submission agent – as is
commonly the case) is responsibility of smtpmail (rather than
Gnus proper.) I know of no proper way to handle multiple
accounts there; when necessary, I use commands like the following.

;;; message: Major mode for editing mail and news to be sent
(setq message-send-mail-function 'message-smtpmail-send-it)

;;; smtpmail: Sending mail over SMTP
(setq smtpmail-auth-credentials "~/.smtpauthinfo"
smtpmail-starttls-credentials
'(("msa.example.com" "587" nil nil)))

(defun smtp-mail-localhost ()
"Configure ‘smtpmail-send-it’ to use localhost for outgoing mail."
(setq smtpmail-smtp-server "::1"
smtpmail-smtp-service "25"
smtpmail-stream-type 'plain))

(defun smtp-mail-example ()
"Configure ‘smtpmail-send-it’ to use Example.com smarthost (MSA)."
(setq smtpmail-smtp-server "msa.example.com"
smtpmail-smtp-service "587"
smtpmail-stream-type 'starttls))

;; Select localhost as default mail submission agent.
(smtp-mail-localhost)
Post by Roderick
Is there a way to tell gnus what init file to use instead of always
using .gnus? Sure, an elisp program in .gnus could do it, but is
there a standard way?
I’ve done it for host-specific Emacs configuration as follows.
For Gnus, you may want to check the gnus-init-file variable.

;;; : Load host-local configuration, if any
;; FIXME: hopefully my system-name is never useless-mode.el or something
(when (string-match-p "\\." (system-name))
(with-demoted-errors "Error (ignored): %S"
(let ((load-path (cons (expand-file-name "host-cf" user-emacs-directory)
load-path)))
(load (system-name)))))
--
FSF associate member #7257 http://am-1.org/~ivan/
Ben Bacarisse
2018-06-29 15:01:07 UTC
Permalink
Ivan Shmakov <***@siamics.net> writes:
<snip>
Post by Ivan Shmakov
Now, sending mail (via an ESMTP(S) mail submission agent – as is
commonly the case) is responsibility of smtpmail (rather than
Gnus proper.) I know of no proper way to handle multiple
accounts there; when necessary, I use commands like the
following.
I tell Gnus to use sendmail and then have a local sendmail replacement
do the "routing". I've found masqmail to be both simple and flexible
for this. It can be configured to detect what SMTP servers to use based
on criteria such as how (or if) you are connected to the Internet and
what the From field of the outgoing mail says. The only wrinkle is that
you need the latest version as the one packaged by many distros lacks
this last crucial feature.
--
Ben.
Ivan Shmakov
2018-06-29 17:55:45 UTC
Permalink
Post by Ben Bacarisse
Now, sending mail (via an ESMTP(S) mail submission agent -- as is
commonly the case) is responsibility of smtpmail (rather than Gnus
proper.) I know of no proper way to handle multiple accounts there;
when necessary, I use commands like the following.
I tell Gnus to use sendmail and then have a local sendmail
replacement do the "routing". I've found masqmail to be both simple
and flexible for this. It can be configured to detect what SMTP
servers to use based on criteria such as how (or if) you are
connected to the Internet and what the From field of the outgoing
mail says. The only wrinkle is that you need the latest version as
the one packaged by many distros lacks this last crucial feature.
As I see it, the primary benefit of using smtpmail.el is that
all the relevant functionality resides in Emacs, and thus can be
configured from there.

On the other hand, using a specialized "sendmail" implementation
means that other programs can send mail, too. (Which is,
incidentally, something I don't currently have much use for.)

Regarding masqmail specifically, it seems that it can only be
configured via a system-wide masqmail.conf file, which doesn't
feel all that convenient in multi-user environments. (Whereas
smtpmail.el is fully controlled by the user.)
--
FSF associate member #7257 http://am-1.org/~ivan/
Ben Bacarisse
2018-06-29 19:02:24 UTC
Permalink
Post by Ivan Shmakov
Post by Ben Bacarisse
Now, sending mail (via an ESMTP(S) mail submission agent -- as is
commonly the case) is responsibility of smtpmail (rather than Gnus
proper.) I know of no proper way to handle multiple accounts there;
when necessary, I use commands like the following.
I tell Gnus to use sendmail and then have a local sendmail
replacement do the "routing". I've found masqmail to be both simple
and flexible for this. It can be configured to detect what SMTP
servers to use based on criteria such as how (or if) you are
connected to the Internet and what the From field of the outgoing
mail says. The only wrinkle is that you need the latest version as
the one packaged by many distros lacks this last crucial feature.
As I see it, the primary benefit of using smtpmail.el is that
all the relevant functionality resides in Emacs, and thus can be
configured from there.
True.
Post by Ivan Shmakov
On the other hand, using a specialized "sendmail" implementation
means that other programs can send mail, too. (Which is,
incidentally, something I don't currently have much use for.)
That's my main motivation. I like to read and send mail using various
programs.
Post by Ivan Shmakov
Regarding masqmail specifically, it seems that it can only be
configured via a system-wide masqmail.conf file, which doesn't
feel all that convenient in multi-user environments. (Whereas
smtpmail.el is fully controlled by the user.)
Yes, that's a problem. I had not thought to mention that. Thanks for
pointing it out. I am still looking for the perfect light-weight
sendmail replacement.

I don't know if setting up links to a user-writable file would work (I
doubt it) for masqmail. I've never tried since I'm the admin on the
sole machine I use (though I do use multiple users accounts to organise
my work).
--
Ben.
Ivan Shmakov
2018-07-04 14:05:27 UTC
Permalink
[...]
Post by Ben Bacarisse
Post by Ivan Shmakov
Regarding masqmail specifically, it seems that it can only be
configured via a system-wide masqmail.conf file, which doesn't feel
all that convenient in multi-user environments. (Whereas
smtpmail.el is fully controlled by the user.)
Yes, that's a problem. I had not thought to mention that. Thanks
for pointing it out. I am still looking for the perfect light-weight
sendmail replacement.
I think I've seen half a dozen in the Debian Packages lists,
but so far had little motivation to check any of them out.
(Although I have one specific use case in mind.)
Post by Ben Bacarisse
I don't know if setting up links to a user-writable file would work
(I doubt it) for masqmail. I've never tried since I'm the admin on
the sole machine I use (though I do use multiple users accounts to
organise my work).
Out of curiosity, do you use multiple accounts solely to get
multiple $HOME directories, or do you actually find some use for
separate UIDs?

Personally, I use chroots somewhat extensively (typically, most
of the "payload" software on my systems is installed in chroot
environments, accessible via schroot(1); this tends to simplify
system upgrades in a way), and I do use different "home"
filesystems for different chroots. Hence, I effectively use a
single account (and UID), but several $HOME directories.

FWIW, the chroot environments are arranged semi-hierarchically.
That is, I can access all the chroot home directories from base
system, and from the "primary" ("trusted") chroot, I can access
all the "secondary" chroots' ones.
--
FSF associate member #7257 http://am-1.org/~ivan/
Ben Bacarisse
2018-07-04 16:17:11 UTC
Permalink
Post by Ivan Shmakov
Out of curiosity, do you use multiple accounts solely to get
multiple $HOME directories, or do you actually find some use for
separate UIDs?
Yes, just to organise things with different directories.
Post by Ivan Shmakov
Personally, I use chroots somewhat extensively (typically, most
of the "payload" software on my systems is installed in chroot
environments, accessible via schroot(1); this tends to simplify
system upgrades in a way), and I do use different "home"
filesystems for different chroots. Hence, I effectively use a
single account (and UID), but several $HOME directories.
Sounds interesting but I did not understand anything but the actual
words. It looks like I should read up on this
--
Ben.
Ivan Shmakov
2018-07-04 18:42:33 UTC
Permalink
[Frankly, I'm somewhat at loss as to where this discussion
should continue. The news:comp.os.linux.misc appears to be
a popular choice, yet the subject at hand isn't Linux-specific.
Then, news:comp.unix.misc looks reasonable, except it doesn't
seem to have seen any on-topic traffic in months. Still, I'm
going to cross-post and set Followup-To: there; feel free to
cross-post to a more appropriate group and set Followup-To:
accordingly instead.]
Post by Ben Bacarisse
Post by Ivan Shmakov
Out of curiosity, do you use multiple accounts solely to get
multiple $HOME directories, or do you actually find some use for
separate UIDs?
Yes, just to organise things with different directories.
Well-behaving programs are ought to use whatever directory
specified in $HOME, so it should be possible to use several home
directories without ever switching uids. Such as, e. g.:

$ export HOME=/home/jrh

$ export HOME=/home/jrh/project-codename

or even (provided such a directory has been created by root):

$ export HOME=/home/codename-jrh

(I used to set HOME to a newly created disposable directory to
test whether whatever bug I observe is caused by my ~/
configuration, or also happens with no user customizations
whatsoever. For well-behaving software, this achieves effect
similar to that of $ emacs -q.)

Unfortunately, some software refers to passwd(5) data directly
instead, leaving no way for the user to override the home
directory location. In particular, this was the behavior (IIRC)
of programs based on older Glib versions. And I vaguely recall
that Emacs might have been affected as well. Thankfully, it's
easy to check out; e. g.:

$ HOME=/tmp emacs --batch \
--eval='(print (expand-file-name user-emacs-directory))'
Loading 00debian-vars...
...
"/tmp/.emacs.d/"
$
Post by Ben Bacarisse
Post by Ivan Shmakov
Personally, I use chroots somewhat extensively (typically, most of
the "payload" software on my systems is installed in chroot
environments, accessible via schroot(1); this tends to simplify
system upgrades in a way), and I do use different "home" filesystems
for different chroots. Hence, I effectively use a single account
(and UID), but several $HOME directories.
Sounds interesting but I did not understand anything but the actual
words. It looks like I should read up on this
The idea is simple. An installed system is just a bunch of
programs. Now, we can copy these programs into an arbitrary
directory, and the only issue with running them from there would
be that /otherwhere/bin/foo is built to refer to filenames like
/lib/libfoo.so and /etc/foorc -- which are in fact available as
/otherwhere/lib/libfoo.so and /otherwhere/etc/foorc, respectively.

The chroot(2) syscall replaces the notion of "/" for the process
with an arbitrary directory. Hence, if instead of the usual
fork and exec routine we do fork, chroot ("/otherwhere") and
then exec, the assumptions bin/foo is built under will hold,
and it will be able to refer to the files under their compiled-in
names, such as /etc/foorc (which will then be understood as
/otherwhere/etc/foorc so long as the "base" system is
considered) and /lib/libfoo.so.

Now, there're only two issues to resolve. From the user's
perspective, chroot(2) is privileged. Thus, we need a setuid-root
program that would check if the user is allowed to use a chroot
and perform the syscall for him if so. Debian offers schroot(1)
for this purpose ($ schroot -c mychroot -- [COMMAND]...;
if no COMMAND given, an interactive shell is started.)

Another issue is to get a system installed under a directory.
In Debian, the respective program is debootstrap(8); like:

# debootstrap stable /srv/chroot/mychroot http://http.debian.net/debian/

(This is the same command used by Debian Installer to install
an "ordinary," non-chroot system to the target media.)

This would likely be followed shortly by APT invocations, like:

# chroot /srv/chroot/mychroot apt-get update
...
# chroot /srv/chroot/mychroot apt-get install -- apg file rsync time zip ...

Chroot environments provide a degree of isolation, as processes
with a root directory set to /otherwhere cannot access filenames
outside of said directory. (Although it's still possible for a
chrooted process to inherit or receive a file descriptor from a
non-chrooted process.) Of course, processes running as root are
still fully privileged, and can, for instance, create device
files and thence wreak any kind of havoc on the system as a whole.

Additional syscalls are available to further isolate processes,
which can be used alongside chroot(2). These are the basis for,
e. g., FreeBSD "jails" and Linux "containers" (LXC.)

Chroot environments provide an easy way to run software
belonging to an older or newer version of the system. Moreover,
as upgrades to chroots are (to a degree) independent to the
upgrades of the base system, the breakage of software in any
chroot (which occasionally happens during upgrades) in no way
affects the operation of the base system, or other chroots,
which is how using chroots simplifies system maintenance for me.
--
FSF associate member #7257 np. Piano Sonata No. 8 in C minor,
http://am-1.org/~ivan/ Op. 13 "Pathetique" -- Adagio cantabile
Roderick
2018-08-28 15:17:51 UTC
Permalink
Thanks for this answer to my question from 23. May 2018!

I have just read it, I gave up to get an answer.

I will try it

It is realy not easy to configure gnus as a "normal" mailreader.

And I am not searching for a lightweigth sendmail, but for a
lightweight mailreader able to do todays normal things.

Rodrigo


[...]
Post by Roderick
Is there a standard way to do this?
Ivan Shmakov
2018-09-01 15:15:45 UTC
Permalink
[...]
And I am not searching for a lightweight sendmail,
JFTR, this thread referred to a lightweight /usr/lib/sendmail
command implementation specifically (of which esmtp(1) seem like
a decent choice), /not/ to a lightweight MTA like Sendmail.
but for a lightweight mailreader able to do todays normal things.
I find Mutt a decent mail user agent, although I'm unsure if
it's really lightweight. (Well, at the very least it has no
GUI, thus no dependencies on Pango, Cairo or Qt.)

Its NeoMutt variant also supports NNTP (although hardly
flawlessly, at least in the version I've used.)

One another user agent that I recall as being rather easy to use
(and not particularly heavyweight) is Alpine.

FYI, there're also newsgroups (news:comp.mail.mutt and
news:comp.mail.pine) dedicated to discussions regarding these MUAs.

(Gnus, on the other hand, I wouldn't call "lightweight.")
--
FSF associate member #7257 http://softwarefreedomday.org/ 15 September 2018
Roderick
2018-09-01 19:08:55 UTC
Permalink
On Sat, 1 Sep 2018, Ivan Shmakov wrote:

Thanks for your hints!
Post by Ivan Shmakov
I find Mutt a decent mail user agent, although I'm unsure if
it's really lightweight.
It is more lightweight than alpine (that I use), but alpines imap
support seems to be better: you can read the text of an email
with attachment without downloading the attachment.

But alpine is not so good for dealing with encryption: gnus is
much better.
Post by Ivan Shmakov
(Gnus, on the other hand, I wouldn't call "lightweight.")
But at least more leightweight than those MUA with GUI.

Emacs is unfortunalty inflated, I use it due to the weight of the
years using it.

I do not want internet connections when I do not need the
connection. I have many imap/smtp accounts and want to
easily select the one I want to use and connect to, with a
menu. An for each imap account, I want a menu with all the
mailboxes in it, without having to name and configure each of it
separately. In that sense, alpine is OK, but I do not get Gnus to
do that for more than one account.

Well, I will study your other posting with time.

Till later
Rodrigo

Roderick
2018-08-28 16:26:53 UTC
Permalink
G m Box RET nnimap:imap.example.com RET) and then ‘unsubscribing’
from them (u; note that this is /not/ the same as ‘killing’, C-k).
What do you mean with Box above?

Is it possible to do it by editing .gnus? Perhaps you can see what
is the effect of that commandos?

This is the contents of my .gnus file:

-----------------------------------
(load "/usr/home/userid/share/elisp/mysmtp.el")

(setq
gnus-permanently-visible-groups ""
gnus-use-dribble-file nil
gnus-save-newsrc-file nil
gnus-read-newsrc-file nil
gnus-show-threads nil
)

(setq gnus-select-method
'(nnimap "gmail"
(nnimap-address "imap.gmail.com")
(nnimap-server-port 993)
(nnimap-stream ssl)))
----------------------------------------------

When I do "M-x gnus" in emacs, it *immediately* asks for password,
and after that, it shows all folders in my google acount.

I do not want that it asks for pasword, but for an acount to
login, and then it can ask for pasword.

Thanks
Rodrigo
Ivan Shmakov
2018-09-01 16:07:29 UTC
Permalink
Post by Roderick
I do it by configuring all the mailboxes I need (in *Group*: G m Box
RET nnimap:imap.example.com RET) and then ‘unsubscribing’ from them
(u; note that this is /not/ the same as ‘killing’, C-k).
What do you mean with Box above?
IMAP provides access to an arbitrary number of "mailboxes" per
account; this is the name of one you want to access. With
Gmail, possible choices include "INBOX" and "[Gmail]/Spam".
(Once you have one mailbox configured, you can see all the rest
for that account via RET on the server in the *Server* buffer.)
Post by Roderick
Is it possible to do it by editing .gnus?
Nearly anything that's possible to do with Emacs interactively
is also possible to do from a Emacs Lisp program.

However, as the result of the mailbox ("group") creation commands
is expected to be saved in ~/.newsrc.eld and read from there on
Gnus startup, I see no reason to put these command in ~/.gnus
specifically.
Post by Roderick
Perhaps you can see what is the effect of that commands?
?

[...]
Post by Roderick
gnus-use-dribble-file nil
Curiously, is there any specific reason for this setting?
Post by Roderick
(setq gnus-select-method
'(nnimap "gmail"
(nnimap-address "imap.gmail.com")
(nnimap-server-port 993)
(nnimap-stream ssl)))
When I do "M-x gnus" in emacs, it *immediately* asks for password,
and after that, it shows all folders in my google account.
I do not want that it asks for password, but for an account to login,
and then it can ask for password.
Gnus is ought to remember which messages the user has read, marked,
etc. These messages are remembered as numbers in ~/.newsrc.eld.
As different mailboxes will typically have different numbers even
if the messages themselves are the same, Gnus cannot use the
same "group" -- whether that group comes from gnus-select-method
or ~/.newsrc.eld -- for different accounts.

(Or at the very least, I know of no way to configure it like that.)

Were I to configure, e. g., Mutt to access multiple Gmail accounts,
I'd do it as follows.

mailboxes +. +.sent \
imaps://***@imap.gmail.com/INBOX \
imaps://***@imap.gmail.com/[Gmail]/Spam \
imaps://***@imap.gmail.com/INBOX \
imaps://***@imap.gmail.com/[Gmail]/Spam \
...

With Gnus, that's done via ~/.newsrc.eld, which is expected to
be edited with Gnus commands, such as "G m" in the *Group* buffer.

As for gnus-select-method, I tend to just set it to nnnil, so
that Gnus never tries to access any remote party whatsoever on
startup (hence I can keep "Internet silence" while reading my
archives.)

(setq gnus-select-method
(list 'nnnil (system-name))

Finally, if you indeed desire that any single Gnus session is
dedicated to working with a specific IMAP account (to stress it
out: Gnus is perfectly capable of working with any number of
IMAP mailboxes -- regardless of whether they belong to different
accounts, servers, or whatnot -- at the same time), I suppose you
can use, say, read-from-minibuffer to read the desired account
name in ~/.gnus and set gnus-current-startup-file (and perhaps
other variables, such as smtpmail-smtp-user) accordingly. Then
you will have as many independent ~/.newsrc.eld files as you
have accounts.
--
FSF associate member #7257 http://softwarefreedomday.org/ 15 September 2018
Continue reading on narkive:
Loading...