On 21Jan2019 17:26, Jonathan Gold <[email protected]> wrote:
Hi -- I apologize if I missed the discussion in the archives, but was
wondering if anyone here has suggestions for a single tool that I can
run locally on macos to accomplish the following independent but related
functions?

        - Sync a local mail store, built atop postgres, from its
          authoritative representation in gmail. Sync should rebuild
          efficiently from source in the event that the local copy is
          destroyed.
        
        - Provide a sane and accessible postgres schema for mail so I can
          connect directly via psql or other tools and query mail directly,
          filtering by headers and bodies (attachments not so important)
        
        - Provide an IMAP server on localhost to be mutt's interface to the
          postgres mailstore.

If your mail store has local IMAP then iffline-imap should be able to sync from gmail to the local store.

        - Provide an SMTP server or sendmail-like command line interface for
          mutt to use to send mail

I'd just use the local mail system. For exanmple, my Mac comes with postfix preinstalled; I've just configured it correctly and now I've got a working local email service. My /etc/postfix/main.cf starts thus:

 # Mac is a dumb host - relay to an ISP or local server.
# This one is a choice mediated by a local haproxy, henc the weid # port.
 relayhost = 127.0.0.2:1025
 sender_dependent_relayhost_maps = hash:/etc/postfix/relayhost_map
 smtp_sender_dependent_authentication = yes
 smtp_sasl_password_maps=hash:/etc/postfix/sasl/security
 smtp_sasl_auth_enable=yes
 mydomain = ... personal email domain here ...
 myorigin = ... personal email domain here ...
 mydestination = $mydomain, $myhostname, localhost.$mydomain, localhost
 inet_interfaces = localhost
 mynetworks_style = host
 message_size_limit = 52428800
 biff = no
 mynetworks = 127.0.0.0/8, [::1]/128
smtpd_client_restrictions = permit_mynetworks permit_sasl_authenticated permit
 recipient_delimiter = +
 smtpd_tls_ciphers = medium
 inet_protocols = ipv4
 default_destination_concurrency_limit = 1

The beauty of a local mail system is that I can read and reply to email even offline; it just spools locally and goes out when I'm next online. And pretty much _all_ UNIX or UNIXlike (eg Linux) systems have a local mail system; it just isn't ideally configured.

And that gets you both local SMTP (usually) and a sendmail command, BTW.

I currently use the mbox format, fetchmail, procmail, and msmtp, but it
is a bit unwieldy and doesn't give me the SQL search interface I'd like.

Ben has mentioned notmuch, which is not SQL but does do decent searching. I use it too and have a helper script to "search and pop up a results folder in mutt" if you like. I confess however that I have aggressive filter rules and use the (l)imit mutt command for most of my searching.

Alternatively, put an intercept in your procmail rules to copy every message to some tool which reads it and populates your PostgreSQL db with relevant data. Of course this won't track message deletions or moves/copies.

I realize that in a sense the server/tool I'm looking for has nothing to
do with mutt per se, but I imagine that if anyone is likely to have
built or found something like this, it'd be mutt users.

Heh. We likely have a billion workarounds. And never a single tool :-)

Cheers,
Cameron Simpson <[email protected]>

Reply via email to