summaryrefslogtreecommitdiff
path: root/alpine/send.c
diff options
context:
space:
mode:
Diffstat (limited to 'alpine/send.c')
-rw-r--r--alpine/send.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/alpine/send.c b/alpine/send.c
index b4e2322f..2e6eace4 100644
--- a/alpine/send.c
+++ b/alpine/send.c
@@ -603,6 +603,7 @@ compose_mail(char *given_to, char *fcc_arg, ACTION_S *role_arg,
int impl, template_len = 0;
long rflags = ROLE_COMPOSE;
PAT_STATE dummy;
+ char *hostpart;
/*================= Compose new message ===============*/
body = mail_newbody();
@@ -611,8 +612,6 @@ compose_mail(char *given_to, char *fcc_arg, ACTION_S *role_arg,
if(given_to)
rfc822_parse_adrlist(&outgoing->to, given_to, ps_global->maildomain);
- outgoing->message_id = generate_message_id();
-
/*
* Setup possible role
*/
@@ -646,6 +645,24 @@ compose_mail(char *given_to, char *fcc_arg, ACTION_S *role_arg,
role->nick);
/*
+ * set ps_global->hostname to something sensible, if possible,
+ * for purposes of generating a message id
+ */
+ hostpart = cpystr(ps_global->hostname);
+ fs_give((void **) &ps_global->hostname);
+ if(role && role->from)
+ ps_global->hostname = cpystr(role->from->host ? role->from->host : "huh");
+ else if(ps_global->maildomain) /* as in generate_from() */
+ ps_global->hostname = cpystr(ps_global->maildomain);
+ else
+ ps_global->hostname = cpystr(hostpart); /* all for nothing */
+ outgoing->message_id = generate_message_id();
+ /* undo the changes above */
+ fs_give((void **) &ps_global->hostname);
+ ps_global->hostname = cpystr(hostpart);
+ fs_give((void **) &hostpart);
+
+ /*
* The type of storage object allocated below is vitally
* important. See SIMPLIFYING ASSUMPTION #37
*/