7 /* quote local part of mailbox
9 /* #include <verp_sender.h>
11 /* VSTRING *verp_sender(dst, delims, sender, recipient)
13 /* const char *delims;
14 /* const char *sender;
15 /* const RECIPIENT *recipient;
17 /* const char *verp_delims_verify(delims)
18 /* const char *delims;
20 /* verp_sender() encodes the recipient address in the sender
21 /* address, using the specified delimiters. For example,
22 /* with delims +=, sender \fIprefix@origin\fR, and
23 /* recipient \fIuser@domain\fR the result is
24 /* \fIprefix+user=domain@origin\fR.
26 /* verp_delims_verify() determines if the specified VERP delimiters
27 /* have reasonable values. What is reasonable is configured with
28 /* the verp_delimiter_filter configuration parameter. The result
29 /* is null in case of success, a description of the problem in
34 /* The result. The buffer is null terminated.
36 /* VERP formatting characters.
38 /* Sender envelope address.
40 /* Recipient envelope address.
44 /* The Secure Mailer license must be distributed with this software.
47 /* IBM T.J. Watson Research
49 /* Yorktown Heights, NY 10598, USA
57 /* Utility library. */
63 #include <mail_params.h>
64 #include <recipient_list.h>
65 #include <verp_sender.h>
67 /* verp_sender - encode recipient into envelope sender address */
69 VSTRING
*verp_sender(VSTRING
*buf
, const char *delimiters
,
70 const char *sender
, const RECIPIENT
*rcpt_info
)
72 ssize_t send_local_len
;
73 ssize_t rcpt_local_len
;
74 const char *recipient
;
78 * Change prefix@origin into prefix+user=domain@origin.
80 * Fix 20090115: Use the Postfix original recipient, because that is what
81 * the VERP consumer expects.
83 send_local_len
= ((cp
= strrchr(sender
, '@')) != 0 ?
84 cp
- sender
: strlen(sender
));
85 recipient
= (rcpt_info
->orig_addr
[0] ?
86 rcpt_info
->orig_addr
: rcpt_info
->address
);
87 rcpt_local_len
= ((cp
= strrchr(recipient
, '@')) != 0 ?
88 cp
- recipient
: strlen(recipient
));
89 vstring_strncpy(buf
, sender
, send_local_len
);
90 VSTRING_ADDCH(buf
, delimiters
[0] & 0xff);
91 vstring_strncat(buf
, recipient
, rcpt_local_len
);
92 if (recipient
[rcpt_local_len
] && recipient
[rcpt_local_len
+ 1]) {
93 VSTRING_ADDCH(buf
, delimiters
[1] & 0xff);
94 vstring_strcat(buf
, recipient
+ rcpt_local_len
+ 1);
96 if (sender
[send_local_len
] && sender
[send_local_len
+ 1]) {
97 VSTRING_ADDCH(buf
, '@');
98 vstring_strcat(buf
, sender
+ send_local_len
+ 1);
100 VSTRING_TERMINATE(buf
);
104 /* verp_delims_verify - sanitize VERP delimiters */
106 const char *verp_delims_verify(const char *delims
)
108 if (strlen(delims
) != 2)
109 return ("bad VERP delimiter character count");
110 if (strchr(var_verp_filter
, delims
[0]) == 0)
111 return ("bad first VERP delimiter character");
112 if (strchr(var_verp_filter
, delims
[1]) == 0)
113 return ("bad second VERP delimiter character");