From: Stephan Bosch Date: Wed, 5 Sep 2018 19:23:05 +0000 (+0200) Subject: lib-storage: mail-user: Add convenience functions for obtaining postmaster address. X-Git-Tag: 2.3.4~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0ed00c242cec8a5fe77141b50e1a59b56b2abe58;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: mail-user: Add convenience functions for obtaining postmaster address. --- diff --git a/src/lib-lda/mail-send.c b/src/lib-lda/mail-send.c index 6de9f2e006..05d5d82200 100644 --- a/src/lib-lda/mail-send.c +++ b/src/lib-lda/mail-send.c @@ -82,8 +82,7 @@ int mail_send_rejection(struct mail_deliver_context *ctx, return 0; } - if (!mail_user_set_get_postmaster_address(user->set, &postmaster_addr, - &error)) { + if (!mail_user_get_postmaster_address(user, &postmaster_addr, &error)) { i_error("msgid=%s: Invalid postmaster_address - can't send rejection: %s", orig_msgid == NULL ? "" : str_sanitize(orig_msgid, 80), error); return -1; diff --git a/src/lib-storage/mail-user.h b/src/lib-storage/mail-user.h index 1627e34fe1..a670f0f14d 100644 --- a/src/lib-storage/mail-user.h +++ b/src/lib-storage/mail-user.h @@ -215,4 +215,28 @@ void mail_user_stats_fill(struct mail_user *user, struct stats *stats); with ENOENT. This way it avoids unnecessary disk IO to the home. */ int mail_user_home_mkdir(struct mail_user *user); +/* Obtain the postmaster address to be used for this user as an RFC 5322 (IMF) + address. Returns false if the configured postmaster address is invalid in + which case error_r contains the error message. */ +static inline bool +mail_user_get_postmaster_address(struct mail_user *user, + const struct message_address **address_r, + const char **error_r) +{ + return mail_user_set_get_postmaster_address(user->set, address_r, + error_r); +} + +/* Obtain the postmaster address to be used for this user as an RFC 5321 (SMTP) + address. Returns false if the configured postmaster address is invalid in + which case error_r contains the error message. */ +static inline bool +mail_user_get_postmaster_smtp(struct mail_user *user, + const struct smtp_address **address_r, + const char **error_r) +{ + return mail_user_set_get_postmaster_smtp(user->set, address_r, + error_r); +} + #endif