|
1 | 1 | // SPDX-License-Identifier: GPL-2.0-only WITH linking exception |
2 | | -// SPDX-FileCopyrightText: 2021-2024 grommunio GmbH |
| 2 | +// SPDX-FileCopyrightText: 2021–2025 grommunio GmbH |
3 | 3 | // This file is part of Gromox. |
4 | 4 | #include <ctime> |
5 | 5 | #include <string> |
|
12 | 12 | #include <vmime/dateTime.hpp> |
13 | 13 | #include <vmime/mailbox.hpp> |
14 | 14 | #include <vmime/stringContentHandler.hpp> |
| 15 | +#include <vmime/utility/outputStreamAdapter.hpp> |
15 | 16 | #include <gromox/bounce_gen.hpp> |
16 | 17 | #include <gromox/element_data.hpp> |
17 | 18 | #include <gromox/rop_util.hpp> |
@@ -133,19 +134,24 @@ bool exch_bouncer_make(buff_t gudn, meta_t meta, |
133 | 134 | pmail->getBody()->appendPart(std::move(part1)); |
134 | 135 |
|
135 | 136 | auto part2 = vmime::make_shared<vmime::bodyPart>(); |
136 | | - auto dsn = part2->getHeader(); |
137 | | - dsn->getField("Final-Recipient")->setValue("rfc822;"s + username); |
| 137 | + vmime::header dsn; |
| 138 | + dsn.getField("Final-Recipient")->setValue("rfc822;"s + username); |
138 | 139 | if (strcmp(bounce_type, "BOUNCE_NOTIFY_READ") == 0) |
139 | | - dsn->getField("Disposition")->setValue("automatic-action/MDN-sent-automatically; displayed"); |
| 140 | + dsn.getField("Disposition")->setValue("automatic-action/MDN-sent-automatically; displayed"); |
140 | 141 | else if (strcmp(bounce_type, "BOUNCE_NOTIFY_NON_READ") == 0) |
141 | | - dsn->getField("Disposition")->setValue("manual-action/MDN-sent-automatically; deleted"); |
| 142 | + dsn.getField("Disposition")->setValue("manual-action/MDN-sent-automatically; deleted"); |
142 | 143 | str = pbrief->proplist.get<char>(PR_INTERNET_MESSAGE_ID); |
143 | 144 | if (str != nullptr) |
144 | | - dsn->getField("Original-Message-ID")->setValue(str); |
| 145 | + dsn.getField("Original-Message-ID")->setValue(str); |
145 | 146 | bv = pbrief->proplist.get<BINARY>(PR_PARENT_KEY); |
146 | 147 | if (bv != nullptr) |
147 | | - dsn->getField("X-MSExch-Correlation-Key")->setValue(base64_encode({bv->pc, bv->cb})); |
148 | | - dsn->getField("X-Display-Name")->setValue(expeditor); |
| 148 | + dsn.getField("X-MSExch-Correlation-Key")->setValue(base64_encode({bv->pc, bv->cb})); |
| 149 | + dsn.getField("X-Display-Name")->setValue(expeditor); |
| 150 | + |
| 151 | + std::ostringstream oss; |
| 152 | + vmime::utility::outputStreamAdapter vos(oss); |
| 153 | + dsn.generate(vos); |
| 154 | + part2->getBody()->setContents(vmime::make_shared<vmime::stringContentHandler>(oss.str())); |
149 | 155 | part2->getBody()->setContentType(vmime::mediaType(vmime::mediaTypes::MESSAGE, vmime::mediaTypes::MESSAGE_DISPOSITION_NOTIFICATION)); |
150 | 156 | pmail->getBody()->appendPart(std::move(part2)); |
151 | 157 | return true; |
|
0 commit comments