Hello, That is great solution, I suggest that such feature is implemented in frm or from, to receive text from standard input. Then shell scripts can easily be used to relate emails to other factors.
Thank you much. I do parse it in Lisp or Scheme, now is even better for scripts. For example I have 1,300 candidates who tells me about their skills for employment, I can then make a macro in mutt, I click let us say F5, then something I can assign skills to people based on their email address and database ID, or mark them as prospective client, or subscribe them quickly to some mailing list. Jean Louis On Sat, Aug 12, 2017 at 10:48:20PM +0300, Sergey Poznyakoff wrote: > Hi Jean, > > > What would be best way by using the mailutils to > > get only the email address from the From: header > > by using pipe and not a file? > > Please find attached the source file ef.c and makefile ef.mk. > To build: make -f ef.mk > Usage: (something) | ef > or: ef < INPUT > > Regards, > Sergey > > #include <mailutils/mailutils.h> > > int > main (int argc, char **argv) > { > int rc; > mu_message_t msg; > mu_header_t hdr; > struct mu_address hint; > mu_address_t addr; > char *val; > char const *email; > > mu_stdstream_setup (MU_STDSTREAM_RESET_NONE); > MU_ASSERT (mu_stdio_stream_create (&mu_strin, MU_STDIN_FD, > MU_STREAM_READ|MU_STREAM_SEEK)); > mu_set_program_name (argv[0]); > mu_registrar_record (mu_mbox_record); > > MU_ASSERT (mu_stream_to_message (mu_strin, &msg)); > MU_ASSERT (mu_message_get_header (msg, &hdr)); > rc = mu_header_aget_value_unfold (hdr, MU_HEADER_FROM, &val); > if (rc == MU_ERR_NOENT) > return 1; > memset (&hint, 0, sizeof hint); > rc = mu_address_create_hint (&addr, val, &hint, MU_ADDR_HINT_DOMAIN); > if (rc) > { > mu_error ("can't parse address %s: %s", val, mu_strerror (rc)); > return 1; > } > MU_ASSERT (mu_address_sget_email (addr, 1, &email)); > mu_printf ("%s\n", email); > return 0; > } > > > > > CPPFLAGS=`mailutils cflags` > LIBS=`mailutils ldflags mbox` > ef: ef.c > cc $(CPPFLAGS) $(CFLAGS) -oef ef.c $(LDFLAGS) $(LIBS) > _______________________________________________ Bug-mailutils mailing list Bug-mailutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-mailutils