SwiftSMTP broken: Error ioOnClosedChannel on latest macOS

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

Answered by GreatOm in 859893022

There is a problem with the SMTP-Server which must be resolved.Sorry for the noise.Unfortunately I cannot delete the post.

Accepted Answer

There is a problem with the SMTP-Server which must be resolved.Sorry for the noise.Unfortunately I cannot delete the post.

Unfortunately I cannot delete the post.

That’s not a problem. See tip 12 in Quinn’s Top Ten DevForums Tips.

Also, if you have questions about SwiftNIO in the future, you might want to avail yourself of the Swift Forums, and specifically the SwiftNIO topic area. That’s where the experts in this technology hang out.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

SwiftSMTP broken: Error ioOnClosedChannel on latest macOS
 
 
Q