[Dovecot] Getting the Sender from a Email

Timo Sirainen
2010-11-10T19:37:19Z

On Wed, 2010-11-10 at 17:09 -0200, Alex Baule wrote:

> Using this mail_get_first_header(mail, "From", &header) , i
get the email in
> this format "Name <user at dom>" , in dovecot there is a
way to get only the
> user at dom ?

Use lib-mail/message-address.h parser, something like:

struct message_address *addr;
addr = message_address_parse(pool_datastack_create(), header, strlen(header), 1,
FALSE);
if (addr != NULL) printf("%s@%s", addr->mailbox, addr->domain);