Hi!
I wrote an internal used backup command line tool which is in use since several years.
Today I got an error while sending an email: “Failed: ioOnClosedChannel”.
I assume that the latest macOS updates did break my app. On the server I use macOS 15.7 and on my development machine macOS 26.
Here is the related code:
private func sendMail() {
var a : [Email.Attachment] = []
if self.imageData != nil {
switch self.imageType {
case .tiff:
a.append(Email.Attachment(name: "Statistics.tif", contentType: #"image/tiff"#, contents: ByteBuffer(bytes: self.imageData!)))
case .pdf:
a.append(Email.Attachment(name: "Statistics.pdf", contentType: #"application/pdf"#, contents: ByteBuffer(bytes: self.imageData!)))
case .unknown:
fatalError("Unimplemented attachment type!")
}
}
mailHtml = mailHtml.replacingOccurrences(of: "<br>", with: "<br>\n")
let email = Email(sender: .init(name: "Backup", emailAddress: "SENDER@MYDOMAIN"),
replyTo: nil,
recipients: recipients,
cc: [],
bcc: [],
subject: self.subject,
body: .universal(plain: self.mailText, html: mailHtml),
attachments: a)
let evg = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount)
let mailer = Mailer(group: evg,
configuration: smtpConfig,
transmissionLogger: nil)
do {
print("Sending mail... ", terminator: "")
try mailer.send(email: email).wait() // <-- ERROR HERE Failed: ioOnClosedChannel
print("done.")
} catch {
print("Failed: \(error)")
}
do {
try evg.syncShutdownGracefully()
} catch {
print("Failed shutdown: \(error)")
}
}
I use https://github.com/sersoft-gmbh/swift-smtp.
Any clue about the reason of this error?
TIA,
GreatOm