]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: mail-user: Add convenience functions for obtaining postmaster address.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Wed, 5 Sep 2018 19:23:05 +0000 (21:23 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 20 Sep 2018 11:06:24 +0000 (11:06 +0000)
src/lib-lda/mail-send.c
src/lib-storage/mail-user.h

index e9d4e51d48af61c0956e5fc1bdfc755bb3a0a7e7..6a1fc128c06cb9a58d82cbc15fa45812182844e5 100644 (file)
@@ -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;
index 1627e34fe1843ee545db3ba06426ba9d30e8d568..a670f0f14db01c69acdef2298d14bbc541e8f158 100644 (file)
@@ -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