Commit 8c298bd1 8c298bd1f95c1be34fabb2f2983a37ef5c38ea01 by Sergey Poznyakoff

(mail_from0): If `showto' is set and the

mail comes from the user that invoked the program, show
`To:' address instead of `From:'.
1 parent 2edc1b12
1 /* GNU Mailutils -- a suite of utilities for electronic mail 1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2000, 2001, 2002, 2003,
3 2005 Free Software Foundation, Inc.
3 4
4 GNU Mailutils is free software; you can redistribute it and/or modify 5 GNU Mailutils is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
...@@ -41,7 +42,31 @@ mail_from0 (msgset_t *mspec, message_t msg, void *data) ...@@ -41,7 +42,31 @@ mail_from0 (msgset_t *mspec, message_t msg, void *data)
41 if (address_create (&address, from) == 0) 42 if (address_create (&address, from) == 0)
42 { 43 {
43 char name[128]; 44 char name[128];
44 size_t len = strlen (from) + 1; 45 size_t len;
46 char *email;
47
48 if (address_aget_email (address, 1, &email) == 0)
49 {
50 if (util_getenv (NULL, "showto", Mail_env_boolean, 0) == 0
51 && mail_is_my_name (email))
52 {
53 char *tmp;
54
55 if (header_aget_value_unfold (hdr, MU_HEADER_TO, &tmp) == 0)
56 {
57 address_t addr_to;
58 if (address_create (&addr_to, tmp) == 0)
59 {
60 address_destroy (&address);
61 address = addr_to;
62 }
63 free (tmp);
64 }
65 }
66 free (email);
67 }
68
69 len = strlen (from) + 1;
45 *name = '\0'; 70 *name = '\0';
46 address_get_personal (address, 1, name, sizeof name, NULL); 71 address_get_personal (address, 1, name, sizeof name, NULL);
47 if (*name && len) 72 if (*name && len)
......