mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
feat(ses): publish SNS notifications to identity feedback topics (#1540)
Wire SetIdentityNotificationTopic into the send path so a verified identity (or its parent domain) with a Bounce/Complaint/Delivery topic receives an Amazon SNS notification when a matching event occurs, independently of any configuration set. Previously the topic ARN was stored and only echoed back by GetIdentityNotificationAttributes. The notification uses the legacy notificationType payload format, which shares the mail/bounce/complaint/delivery blocks with event publishing but differs in three spec-mandated ways: the top-level discriminator is named notificationType instead of eventType; the mail object omits the tags field; and the original headers (headers/commonHeaders/ headersTruncated) are included only when the identity has headers-in-notifications enabled for the notification type. The sending identity is resolved from the bare email address (so a display-name Source yields a valid identity/<email> ARN), and SendRawEmail falls back to the MIME From header when Source is omitted, using that effective source consistently for the stored message, SMTP relay, and event publishing. RawMessageHeaders now parses the From address. Docs: documented the behavior in docs/services/ses.md.
This commit is contained in:
1 parent
ad785f95f6
commit
e24566c47b
6 files changed
+640
-93
No files matched your search
@@ -40,11 +40,56 @@ final class SesEventPayload {
|
||||
List<String> suppressionComplaintRecipients,
|
||||
String configurationSetName, List<MessageTag> emailTags,
|
||||
List<MessageHeader> additionalHeaders, Instant timestamp) {
|
||||
return buildRoot(mapper, "eventType", eventType, messageId, source, sourceArn,
|
||||
sendingAccountId, subject, toAddresses, ccAddresses, bccAddresses,
|
||||
envelopeDestinations, suppressionBounceRecipients, suppressionComplaintRecipients,
|
||||
configurationSetName, emailTags, additionalHeaders, timestamp, true, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the legacy Amazon SNS notification JSON delivered to the per-identity feedback
|
||||
* topics configured through {@code SetIdentityNotificationTopic}, matching the format at
|
||||
* https://docs.aws.amazon.com/ses/latest/dg/notification-contents.html. It shares the
|
||||
* {@code mail}/{@code bounce}/{@code complaint}/{@code delivery} blocks with the
|
||||
* event-publishing payload from {@link #build} but differs in three spec-mandated ways:
|
||||
* the top-level discriminator is named {@code notificationType} rather than {@code eventType};
|
||||
* the {@code mail} object never carries a {@code tags} field; and the original headers
|
||||
* ({@code headers}/{@code commonHeaders}/{@code headersTruncated}) appear only when the
|
||||
* identity has headers-in-notifications enabled for the type ({@code includeHeaders}). Only
|
||||
* the {@code BOUNCE}, {@code COMPLAINT}, and {@code DELIVERY} event types are ever published
|
||||
* through this path.
|
||||
*/
|
||||
static ObjectNode buildIdentityNotification(ObjectMapper mapper, String eventType,
|
||||
String messageId, String source, String sourceArn,
|
||||
String sendingAccountId, String subject,
|
||||
List<String> toAddresses, List<String> ccAddresses,
|
||||
List<String> bccAddresses, List<String> envelopeDestinations,
|
||||
List<String> suppressionBounceRecipients,
|
||||
List<String> suppressionComplaintRecipients,
|
||||
List<MessageHeader> additionalHeaders, Instant timestamp,
|
||||
boolean includeHeaders) {
|
||||
return buildRoot(mapper, "notificationType", eventType, messageId, source, sourceArn,
|
||||
sendingAccountId, subject, toAddresses, ccAddresses, bccAddresses,
|
||||
envelopeDestinations, suppressionBounceRecipients, suppressionComplaintRecipients,
|
||||
null, null, additionalHeaders, timestamp, includeHeaders, false);
|
||||
}
|
||||
|
||||
private static ObjectNode buildRoot(ObjectMapper mapper, String typeField, String eventType,
|
||||
String messageId, String source, String sourceArn,
|
||||
String sendingAccountId, String subject,
|
||||
List<String> toAddresses, List<String> ccAddresses,
|
||||
List<String> bccAddresses, List<String> envelopeDestinations,
|
||||
List<String> suppressionBounceRecipients,
|
||||
List<String> suppressionComplaintRecipients,
|
||||
String configurationSetName, List<MessageTag> emailTags,
|
||||
List<MessageHeader> additionalHeaders, Instant timestamp,
|
||||
boolean includeHeaders, boolean includeTags) {
|
||||
ObjectNode root = mapper.createObjectNode();
|
||||
root.put("eventType", eventTypeLabel(eventType));
|
||||
root.put(typeField, eventTypeLabel(eventType));
|
||||
root.set("mail", buildMail(mapper, messageId, source, sourceArn, sendingAccountId,
|
||||
subject, toAddresses, ccAddresses, bccAddresses, envelopeDestinations,
|
||||
configurationSetName, emailTags, additionalHeaders, timestamp));
|
||||
configurationSetName, emailTags, additionalHeaders, timestamp,
|
||||
includeHeaders, includeTags));
|
||||
root.set(blockName(eventType),
|
||||
buildEventBlock(mapper, eventType, messageId, envelopeDestinations,
|
||||
suppressionBounceRecipients, suppressionComplaintRecipients, timestamp));
|
||||
@@ -58,7 +103,8 @@ final class SesEventPayload {
|
||||
List<String> envelopeDestinations,
|
||||
String configurationSetName, List<MessageTag> emailTags,
|
||||
List<MessageHeader> additionalHeaders,
|
||||
Instant timestamp) {
|
||||
Instant timestamp, boolean includeHeaders,
|
||||
boolean includeTags) {
|
||||
ObjectNode mail = mapper.createObjectNode();
|
||||
mail.put("timestamp", ISO_MILLIS.format(timestamp));
|
||||
if (source != null && !source.isBlank()) {
|
||||
@@ -73,70 +119,74 @@ final class SesEventPayload {
|
||||
for (String d : envelopeDestinations) {
|
||||
dest.add(d);
|
||||
}
|
||||
mail.put("headersTruncated", false);
|
||||
ArrayNode headers = mail.putArray("headers");
|
||||
if (source != null && !source.isBlank()) {
|
||||
addHeader(headers, mapper, "From", source);
|
||||
}
|
||||
if (toAddresses != null && !toAddresses.isEmpty()) {
|
||||
addHeader(headers, mapper, "To", String.join(", ", toAddresses));
|
||||
}
|
||||
if (ccAddresses != null && !ccAddresses.isEmpty()) {
|
||||
addHeader(headers, mapper, "Cc", String.join(", ", ccAddresses));
|
||||
}
|
||||
if (subject != null && !subject.isEmpty()) {
|
||||
addHeader(headers, mapper, "Subject", subject);
|
||||
}
|
||||
if (additionalHeaders != null) {
|
||||
for (MessageHeader h : additionalHeaders) {
|
||||
if (h == null || h.name() == null || h.name().isBlank()) {
|
||||
continue;
|
||||
if (includeHeaders) {
|
||||
mail.put("headersTruncated", false);
|
||||
ArrayNode headers = mail.putArray("headers");
|
||||
if (source != null && !source.isBlank()) {
|
||||
addHeader(headers, mapper, "From", source);
|
||||
}
|
||||
if (toAddresses != null && !toAddresses.isEmpty()) {
|
||||
addHeader(headers, mapper, "To", String.join(", ", toAddresses));
|
||||
}
|
||||
if (ccAddresses != null && !ccAddresses.isEmpty()) {
|
||||
addHeader(headers, mapper, "Cc", String.join(", ", ccAddresses));
|
||||
}
|
||||
if (subject != null && !subject.isEmpty()) {
|
||||
addHeader(headers, mapper, "Subject", subject);
|
||||
}
|
||||
if (additionalHeaders != null) {
|
||||
for (MessageHeader h : additionalHeaders) {
|
||||
if (h == null || h.name() == null || h.name().isBlank()) {
|
||||
continue;
|
||||
}
|
||||
addHeader(headers, mapper, h.name(), h.value() == null ? "" : h.value());
|
||||
}
|
||||
addHeader(headers, mapper, h.name(), h.value() == null ? "" : h.value());
|
||||
}
|
||||
}
|
||||
ObjectNode common = mail.putObject("commonHeaders");
|
||||
common.put("messageId", messageId);
|
||||
common.put("date", RFC_5322_DATE.format(timestamp));
|
||||
ArrayNode fromArr = common.putArray("from");
|
||||
if (source != null && !source.isBlank()) {
|
||||
fromArr.add(source);
|
||||
}
|
||||
ArrayNode toArr = common.putArray("to");
|
||||
if (toAddresses != null) {
|
||||
for (String a : toAddresses) {
|
||||
toArr.add(a);
|
||||
ObjectNode common = mail.putObject("commonHeaders");
|
||||
common.put("messageId", messageId);
|
||||
common.put("date", RFC_5322_DATE.format(timestamp));
|
||||
ArrayNode fromArr = common.putArray("from");
|
||||
if (source != null && !source.isBlank()) {
|
||||
fromArr.add(source);
|
||||
}
|
||||
}
|
||||
if (ccAddresses != null && !ccAddresses.isEmpty()) {
|
||||
ArrayNode ccArr = common.putArray("cc");
|
||||
for (String a : ccAddresses) {
|
||||
ccArr.add(a);
|
||||
}
|
||||
}
|
||||
if (bccAddresses != null && !bccAddresses.isEmpty()) {
|
||||
ArrayNode bccArr = common.putArray("bcc");
|
||||
for (String a : bccAddresses) {
|
||||
bccArr.add(a);
|
||||
}
|
||||
}
|
||||
if (subject != null && !subject.isEmpty()) {
|
||||
common.put("subject", subject);
|
||||
}
|
||||
ObjectNode tags = mail.putObject("tags");
|
||||
if (configurationSetName != null) {
|
||||
ArrayNode csTag = tags.putArray("ses:configuration-set");
|
||||
csTag.add(configurationSetName);
|
||||
}
|
||||
if (emailTags != null) {
|
||||
for (MessageTag t : emailTags) {
|
||||
if (t == null || t.name() == null) {
|
||||
continue;
|
||||
ArrayNode toArr = common.putArray("to");
|
||||
if (toAddresses != null) {
|
||||
for (String a : toAddresses) {
|
||||
toArr.add(a);
|
||||
}
|
||||
}
|
||||
if (ccAddresses != null && !ccAddresses.isEmpty()) {
|
||||
ArrayNode ccArr = common.putArray("cc");
|
||||
for (String a : ccAddresses) {
|
||||
ccArr.add(a);
|
||||
}
|
||||
}
|
||||
if (bccAddresses != null && !bccAddresses.isEmpty()) {
|
||||
ArrayNode bccArr = common.putArray("bcc");
|
||||
for (String a : bccAddresses) {
|
||||
bccArr.add(a);
|
||||
}
|
||||
}
|
||||
if (subject != null && !subject.isEmpty()) {
|
||||
common.put("subject", subject);
|
||||
}
|
||||
}
|
||||
if (includeTags) {
|
||||
ObjectNode tags = mail.putObject("tags");
|
||||
if (configurationSetName != null) {
|
||||
ArrayNode csTag = tags.putArray("ses:configuration-set");
|
||||
csTag.add(configurationSetName);
|
||||
}
|
||||
if (emailTags != null) {
|
||||
for (MessageTag t : emailTags) {
|
||||
if (t == null || t.name() == null) {
|
||||
continue;
|
||||
}
|
||||
ArrayNode arr = tags.has(t.name())
|
||||
? (ArrayNode) tags.get(t.name())
|
||||
: tags.putArray(t.name());
|
||||
arr.add(t.value() == null ? "" : t.value());
|
||||
}
|
||||
ArrayNode arr = tags.has(t.name())
|
||||
? (ArrayNode) tags.get(t.name())
|
||||
: tags.putArray(t.name());
|
||||
arr.add(t.value() == null ? "" : t.value());
|
||||
}
|
||||
}
|
||||
return mail;
|
||||
|
||||
@@ -96,6 +96,33 @@ public class SesEventPublisher {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Publishes a legacy Amazon SNS feedback notification to a single topic configured for an
|
||||
* identity through {@code SetIdentityNotificationTopic}. Unlike {@link #publish}, this path
|
||||
* is independent of any {@link ConfigurationSet} event destination: a verified identity with
|
||||
* a Bounce/Complaint/Delivery topic receives notifications even when the send carries no
|
||||
* configuration set. The payload uses the legacy {@code notificationType} discriminator, omits
|
||||
* {@code mail.tags}, and includes the original headers only when {@code includeHeaders} is set
|
||||
* (i.e. the identity has headers-in-notifications enabled for the type).
|
||||
*/
|
||||
public void publishIdentityNotification(String topicArn, boolean includeHeaders, String eventType,
|
||||
String messageId, String source, String sourceArn, String sendingAccountId,
|
||||
String subject, List<String> toAddresses, List<String> ccAddresses,
|
||||
List<String> bccAddresses, List<String> envelopeDestinations,
|
||||
List<String> suppressionBounceRecipients,
|
||||
List<String> suppressionComplaintRecipients,
|
||||
List<MessageHeader> additionalHeaders, Instant timestamp, String defaultRegion) {
|
||||
if (topicArn == null || topicArn.isBlank()) {
|
||||
return;
|
||||
}
|
||||
ObjectNode payload = SesEventPayload.buildIdentityNotification(objectMapper, eventType,
|
||||
messageId, source, sourceArn, sendingAccountId, subject,
|
||||
toAddresses, ccAddresses, bccAddresses, envelopeDestinations,
|
||||
suppressionBounceRecipients, suppressionComplaintRecipients,
|
||||
additionalHeaders, timestamp, includeHeaders);
|
||||
publishSns(topicArn, payload.toString(), defaultRegion);
|
||||
}
|
||||
|
||||
private void dispatch(EventDestination ed, String eventType, String payloadJson,
|
||||
String sourceArn, String configurationSetName,
|
||||
List<MessageTag> emailTags, List<MessageHeader> additionalHeaders,
|
||||
|
||||
@@ -245,10 +245,15 @@ public class SesService {
|
||||
}
|
||||
validateConfigurationSet(configurationSetName, region);
|
||||
boolean hasExplicitDestinations = destinations != null && !destinations.isEmpty();
|
||||
boolean willPublishEvents = configurationSetName != null && !configurationSetName.isBlank();
|
||||
SmtpRelay.RawMessageHeaders headers = (hasExplicitDestinations && !willPublishEvents)
|
||||
boolean sourceOmitted = source == null || source.isBlank();
|
||||
boolean willPublishEvents = (configurationSetName != null && !configurationSetName.isBlank())
|
||||
|| !resolveIdentityNotificationTargets(source, region).isEmpty();
|
||||
SmtpRelay.RawMessageHeaders headers = (hasExplicitDestinations && !willPublishEvents && !sourceOmitted)
|
||||
? null
|
||||
: SmtpRelay.parseRawHeaders(rawMessage);
|
||||
String effectiveSource = sourceOmitted && headers != null && !headers.from().isBlank()
|
||||
? headers.from()
|
||||
: source;
|
||||
List<String> effectiveDestinations = hasExplicitDestinations
|
||||
? destinations
|
||||
: allRecipients(headers.to(), headers.cc(), headers.bcc());
|
||||
@@ -257,21 +262,21 @@ public class SesService {
|
||||
"At least one destination address is required.", 400);
|
||||
}
|
||||
String messageId = UUID.randomUUID().toString();
|
||||
SentEmail email = new SentEmail(messageId, region, source, effectiveDestinations, rawMessage);
|
||||
SentEmail email = new SentEmail(messageId, region, effectiveSource, effectiveDestinations, rawMessage);
|
||||
emailStore.put("email::" + region + "::" + messageId, email);
|
||||
|
||||
Map<String, String> suppressedReasons = collectSuppressedReasons(effectiveDestinations, configurationSetName, region);
|
||||
|
||||
List<String> relayedDestinations = filterUnsuppressed(effectiveDestinations, suppressedReasons);
|
||||
if (!relayedDestinations.isEmpty()) {
|
||||
smtpRelay.relayRaw(source, relayedDestinations, rawMessage);
|
||||
smtpRelay.relayRaw(effectiveSource, relayedDestinations, rawMessage);
|
||||
} else {
|
||||
LOG.infov("SES raw email accepted but not relayed (all recipients suppressed): messageId={0}",
|
||||
messageId);
|
||||
}
|
||||
|
||||
LOG.infov("SES raw email sent: from={0}, messageId={1}", source, messageId);
|
||||
publishSendEvents(configurationSetName, messageId, source,
|
||||
LOG.infov("SES raw email sent: from={0}, messageId={1}", effectiveSource, messageId);
|
||||
publishSendEvents(configurationSetName, messageId, effectiveSource,
|
||||
headers != null ? headers.subject() : "",
|
||||
headers != null ? headers.to() : List.of(),
|
||||
headers != null ? headers.cc() : List.of(),
|
||||
@@ -330,19 +335,22 @@ public class SesService {
|
||||
Map<String, String> suppressedReasons,
|
||||
List<MessageTag> emailTags,
|
||||
List<MessageHeader> additionalHeaders, String region) {
|
||||
if (eventPublisher == null) {
|
||||
if (eventPublisher == null || messageId == null) {
|
||||
return;
|
||||
}
|
||||
if (configurationSetName == null || configurationSetName.isBlank() || messageId == null) {
|
||||
return;
|
||||
ConfigurationSet cs = null;
|
||||
if (configurationSetName != null && !configurationSetName.isBlank()) {
|
||||
cs = configSetStore.get(configSetKey(region, configurationSetName)).orElse(null);
|
||||
if (cs == null) {
|
||||
LOG.warnv("SES send references unknown ConfigurationSet <{0}>; configuration-set "
|
||||
+ "events not published (identity notifications, if any, still apply).",
|
||||
configurationSetName);
|
||||
}
|
||||
}
|
||||
ConfigurationSet cs = configSetStore.get(configSetKey(region, configurationSetName)).orElse(null);
|
||||
if (cs == null) {
|
||||
LOG.warnv("SES send references unknown ConfigurationSet <{0}>; events not published.",
|
||||
configurationSetName);
|
||||
return;
|
||||
}
|
||||
if (cs.getEventDestinations().isEmpty()) {
|
||||
boolean configSetActive = cs != null && !cs.getEventDestinations().isEmpty();
|
||||
Map<String, IdentityNotificationTarget> identityTargets =
|
||||
resolveIdentityNotificationTargets(source, region);
|
||||
if (!configSetActive && identityTargets.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -352,7 +360,8 @@ public class SesService {
|
||||
String sendingAccountId = defaultAccountId;
|
||||
String sourceArn = (source == null || source.isBlank())
|
||||
? null
|
||||
: AwsArnUtils.Arn.of("ses", region, sendingAccountId, "identity/" + source).toString();
|
||||
: AwsArnUtils.Arn.of("ses", region, sendingAccountId,
|
||||
"identity/" + extractEmailAddress(source)).toString();
|
||||
|
||||
List<String> suppressionBounceRecipients = new ArrayList<>();
|
||||
List<String> suppressionComplaintRecipients = new ArrayList<>();
|
||||
@@ -366,13 +375,83 @@ public class SesService {
|
||||
|
||||
for (String eventType : determineSendEventTypes(envelope,
|
||||
suppressionBounceRecipients, suppressionComplaintRecipients)) {
|
||||
eventPublisher.publish(cs, eventType, messageId, source, sourceArn, sendingAccountId,
|
||||
subject, toAddresses, ccAddresses, bccAddresses, envelope,
|
||||
suppressionBounceRecipients, suppressionComplaintRecipients,
|
||||
emailTags, additionalHeaders, timestamp, region);
|
||||
if (configSetActive) {
|
||||
eventPublisher.publish(cs, eventType, messageId, source, sourceArn, sendingAccountId,
|
||||
subject, toAddresses, ccAddresses, bccAddresses, envelope,
|
||||
suppressionBounceRecipients, suppressionComplaintRecipients,
|
||||
emailTags, additionalHeaders, timestamp, region);
|
||||
}
|
||||
IdentityNotificationTarget target = identityTargets.get(eventType);
|
||||
if (target != null) {
|
||||
eventPublisher.publishIdentityNotification(target.topicArn(), target.includeHeaders(),
|
||||
eventType, messageId, source, sourceArn, sendingAccountId, subject,
|
||||
toAddresses, ccAddresses, bccAddresses, envelope, suppressionBounceRecipients,
|
||||
suppressionComplaintRecipients, additionalHeaders, timestamp, region);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the SNS feedback notification target configured via {@code SetIdentityNotificationTopic}
|
||||
* for the sending identity. The email-address identity's topic takes precedence over its parent
|
||||
* domain identity's topic, per notification type; the headers-in-notifications flag is read from
|
||||
* whichever identity supplied the topic. Returns a map keyed by the {@code SEND}-style event name
|
||||
* ({@code BOUNCE}/{@code COMPLAINT}/{@code DELIVERY}) so it can be looked up directly against
|
||||
* {@link #determineSendEventTypes}.
|
||||
*/
|
||||
private Map<String, IdentityNotificationTarget> resolveIdentityNotificationTargets(String source,
|
||||
String region) {
|
||||
Map<String, IdentityNotificationTarget> targets = new LinkedHashMap<>();
|
||||
if (source == null || source.isBlank()) {
|
||||
return targets;
|
||||
}
|
||||
String email = extractEmailAddress(source);
|
||||
if (email.isBlank()) {
|
||||
return targets;
|
||||
}
|
||||
Identity emailIdentity = identityStore.get(identityKey(region, email)).orElse(null);
|
||||
Identity domainIdentity = null;
|
||||
int at = email.indexOf('@');
|
||||
if (at >= 0 && at < email.length() - 1) {
|
||||
domainIdentity = identityStore.get(identityKey(region, email.substring(at + 1))).orElse(null);
|
||||
}
|
||||
for (String type : NOTIFICATION_TYPES) {
|
||||
String topic = notificationTopicFor(emailIdentity, type);
|
||||
Identity owner = emailIdentity;
|
||||
if (topic == null) {
|
||||
topic = notificationTopicFor(domainIdentity, type);
|
||||
owner = domainIdentity;
|
||||
}
|
||||
if (topic == null) {
|
||||
continue;
|
||||
}
|
||||
boolean includeHeaders = Boolean.TRUE.equals(
|
||||
owner.getHeadersInNotificationsEnabled().get(type));
|
||||
targets.put(type.toUpperCase(Locale.ROOT),
|
||||
new IdentityNotificationTarget(topic, includeHeaders));
|
||||
}
|
||||
return targets;
|
||||
}
|
||||
|
||||
private static String notificationTopicFor(Identity identity, String type) {
|
||||
if (identity == null) {
|
||||
return null;
|
||||
}
|
||||
String topic = identity.getNotificationAttributes().get(type + "Topic");
|
||||
return topic != null && !topic.isBlank() ? topic : null;
|
||||
}
|
||||
|
||||
private record IdentityNotificationTarget(String topicArn, boolean includeHeaders) {}
|
||||
|
||||
private static String extractEmailAddress(String source) {
|
||||
int open = source.indexOf('<');
|
||||
int close = source.indexOf('>', open + 1);
|
||||
if (open >= 0 && close > open) {
|
||||
return source.substring(open + 1, close).trim();
|
||||
}
|
||||
return source.trim();
|
||||
}
|
||||
|
||||
private static List<String> determineSendEventTypes(List<String> destinations,
|
||||
List<String> suppressionBounceRecipients,
|
||||
List<String> suppressionComplaintRecipients) {
|
||||
|
||||
@@ -279,13 +279,14 @@ public class SmtpRelay {
|
||||
}
|
||||
|
||||
/**
|
||||
* Structured headers extracted from a raw RFC 5322 MIME message:
|
||||
* subject and separate To / Cc / Bcc address lists. Empty fields when the
|
||||
* corresponding header is missing.
|
||||
* Structured headers extracted from a raw RFC 5322 MIME message: the From
|
||||
* address, subject, and separate To / Cc / Bcc address lists. Empty fields
|
||||
* when the corresponding header is missing.
|
||||
*/
|
||||
public record RawMessageHeaders(String subject, List<String> to, List<String> cc, List<String> bcc) {
|
||||
public record RawMessageHeaders(String from, String subject,
|
||||
List<String> to, List<String> cc, List<String> bcc) {
|
||||
public static RawMessageHeaders empty() {
|
||||
return new RawMessageHeaders("", List.of(), List.of(), List.of());
|
||||
return new RawMessageHeaders("", "", List.of(), List.of(), List.of());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,13 +304,15 @@ public class SmtpRelay {
|
||||
var builder = new DefaultMessageBuilder();
|
||||
var message = builder.parseMessage(new ByteArrayInputStream(mimeBytes));
|
||||
String subject = message.getSubject() != null ? message.getSubject() : "";
|
||||
List<String> from = message.getFrom() != null
|
||||
? toMailboxAddresses(message.getFrom()) : List.of();
|
||||
List<String> to = message.getTo() != null
|
||||
? toMailboxAddresses(message.getTo().flatten()) : List.of();
|
||||
List<String> cc = message.getCc() != null
|
||||
? toMailboxAddresses(message.getCc().flatten()) : List.of();
|
||||
List<String> bcc = message.getBcc() != null
|
||||
? toMailboxAddresses(message.getBcc().flatten()) : List.of();
|
||||
return new RawMessageHeaders(subject, to, cc, bcc);
|
||||
return new RawMessageHeaders(from.isEmpty() ? "" : from.get(0), subject, to, cc, bcc);
|
||||
} catch (Exception e) {
|
||||
return RawMessageHeaders.empty();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user