}
}
+static void lmtp_address_translate(struct client *client, const char **address)
+{
+ const char *transpos = client->lmtp_set->lmtp_address_translate;
+ const char *p, *nextstr, *addrpos = *address;
+ unsigned int len;
+ string_t *username, *domain, *dest = NULL;
+
+ if (*transpos == '\0')
+ return;
+
+ username = t_str_new(64);
+ domain = t_str_new(64);
+
+ /* check that string matches up to the first '%' */
+ p = strchr(transpos, '%');
+ if (p == NULL)
+ len = strlen(transpos);
+ else
+ len = p-transpos;
+ if (strncmp(transpos, addrpos, len) != 0)
+ return;
+ transpos += len;
+ addrpos += len;
+
+ while (*transpos != '\0') {
+ switch (transpos[1]) {
+ case 'n':
+ case 'u':
+ dest = username;
+ break;
+ case 'd':
+ dest = domain;
+ break;
+ default:
+ return;
+ }
+ transpos += 2;
+
+ /* find where the next string starts */
+ if (*transpos == '\0') {
+ str_append(dest, addrpos);
+ break;
+ }
+ p = strchr(transpos, '%');
+ if (p == NULL)
+ nextstr = transpos;
+ else
+ nextstr = t_strdup_until(transpos, p);
+ p = strstr(addrpos, nextstr);
+ if (p == NULL)
+ return;
+ str_append_n(dest, addrpos, p-addrpos);
+
+ len = strlen(nextstr);
+ transpos += len;
+ addrpos = p + len;
+ }
+ str_append_c(username, '@');
+ if (domain != NULL)
+ str_append_str(username, domain);
+ *address = str_c(username);
+}
+
int cmd_rcpt(struct client *client, const char *args)
{
struct mail_recipient rcpt;
return 0;
}
+ lmtp_address_translate(client, &address);
+
rcpt.address = p_strdup(client->state_pool, address);
rcpt.detail = p_strdup(client->state_pool, detail);
array_append(&client->state.rcpt_to, &rcpt, 1);
DEF(SET_BOOL, lmtp_proxy),
DEF(SET_BOOL, lmtp_save_to_detail_mailbox),
DEF(SET_STR_VARS, login_greeting),
+ DEF(SET_STR, lmtp_address_translate),
SETTING_DEFINE_LIST_END
};
static const struct lmtp_settings lmtp_default_settings = {
.lmtp_proxy = FALSE,
.lmtp_save_to_detail_mailbox = FALSE,
- .login_greeting = PACKAGE_NAME" ready."
+ .login_greeting = PACKAGE_NAME" ready.",
+ .lmtp_address_translate = ""
};
static const struct setting_parser_info *lmtp_setting_dependencies[] = {