On Sun, 05 Jun 2011, Jostein Berntsen wrote:
> You might try to change this line in mysendmail to:
> tee >(lbdb-fetchaddr -a)|/usr/local/bin/msmtp -a $@
> Rename this file to mymsmpt and set this in .muttrc:
> set sendmail="~/bin/mymsmpt"

Here is what I have did.

$ cat .mutt/muttrc | grep mylbdb
set query_command="~/bin/mylbdbq %s"

$ cat .lbdb/lbdbrc | grep METHODS
METHODS="m_inmail m_muttalias m_passwd m_finger"

$ cat bin/mylbdbq
#!/bin/bash
(lbdbq "$@" | tee >(head -n 1 >&2) 2>/dev/null | grep -v \
          ^lbdbq:.*matches | tac) 2>&1

$ cat .mutt/gmail.muttrc 
###
# gmail specific options
###
color status green default
set from      = "[email protected]"
#set sendmail  = "/usr/bin/msmtp -a gmail"
set sendmail  = "~/bin/mymsmpt.gmail"
set mbox      = "+GMail/archive"
unset record
set postponed = "+GMail/[Gmail].Rascunhos"
macro index E "<change-folder>+GMail/archive<enter><limit>~B " \
    "search everything"
macro index D "<save-message>+GMail/[Gmail].Lixeira<enter>" \
    "move message to the trash"
macro index S "<save-message>+GMail/[Gmail].Spam<enter>" \
    "mark message as spam"

$ cat bin/mymsmpt.gmail 
#!/bin/bash
tee >(lbdb-fetchaddr -a)|/usr/bin/msmtp -a gmail $@

$ cat bin/add.mail.to.lbdb 
#!/bin/bash
find /home/marcelo/Mail/GMail/INBOX -type f -mtime -7 -print0 | \
  xargs -0 -n 1 -r /bin/bash -c 'lbdb-fetchaddr -a < "$1"' \
  lbdb-fetchaddr
find /home/marcelo/Mail/Yahoo/Inbox -type f -mtime -7 -print0 | \
  xargs -0 -n 1 -r /bin/bash -c 'lbdb-fetchaddr -a < "$1"' \
  lbdb-fetchaddr
# remove dups
SORT_OUTPUT=name /usr/lib/lbdb/lbdb-munge

Now, when I send a message the to: address is salved in the lbdb.

I setup crontab like this:

* */2 * * * /home/user/bin/add.mail.to.lbdb

So, each 2 h the script populated lbdb from the mails I receive.

Thank you very much! :-D

Now, I need only to remove from lbdb the system address, like this:

users@localhost
blabla@localhost
foo@localhost
...

Have any ideia to do that?

Thank you again!

-- 
  O___   - Marcelo Luiz de Laia
 c/  /'_ - Diamantina
(*)  \(*)- Minas Gerais
~~~~~~~~~- Brazil
^^^^^^^^^- Linux user number 487797

Reply via email to