Commit e7537ee6 e7537ee62061e0f5d5c6ce4658a13fdc70588069 by Sergey Poznyakoff

Fall back to "Sender:" and "From:" headers (in that order), if the envelope sender is not available.

1 parent 3d2e7c41
...@@ -113,14 +113,23 @@ sieve_get_message_sender (message_t msg, char **ptext) ...@@ -113,14 +113,23 @@ sieve_get_message_sender (message_t msg, char **ptext)
113 return rc; 113 return rc;
114 114
115 rc = envelope_sender (envelope, NULL, 0, &size); 115 rc = envelope_sender (envelope, NULL, 0, &size);
116 if (rc) 116 if (rc == 0)
117 return rc; 117 {
118 if (!(text = malloc (size + 1)))
119 return ENOMEM;
120 envelope_sender (envelope, text, size + 1, NULL);
121 }
122 else
123 {
124 header_t hdr = NULL;
125 message_get_header (msg, &hdr);
126 if (rc = header_aget_value (hdr, MU_HEADER_SENDER, &text))
127 rc = header_aget_value (hdr, MU_HEADER_FROM, &text);
128 }
118 129
119 if (!(text = malloc (size + 1))) 130 if (rc == 0)
120 return ENOMEM; 131 *ptext = text;
121 envelope_sender (envelope, text, size + 1, NULL); 132 return rc;
122 *ptext = text;
123 return 0;
124 } 133 }
125 134
126 static int 135 static int
......