SMTPKitten

1.0.0-beta.1

Joannis/SMTPKitten

What's New

1.0.0-beta.1

2025-02-24T08:08:52Z

What's Changed

Replaced the old connection with two new types: SMTPConnection and SMTPClient.
SMTPConnection contains a single socket, whereas SMTPClient always keeps one SMTPConnection active and might open more parallel connections. It is recommended to use SMTPClient and add it to your Swift Service Lifecycle.

Contributions

New Contributors

Full Changelog: 0.2.3...1.0.0

To get started, add the SMTPKitten dependency:

.package(url: "https://github.com/joannis/SMTPKitten.git", from: "1.0.0"),

And add it as a dependency of your target:

.product(name: "SMTPKitten", package: "SMTPKitten"),

Create a connection

try await SMTPConnection.withConnection(
    to: "localhost",
    port: 1025,
    ssl: .insecure
) { client in
    // 1. Authenticate
    try await client.login(
        user: "xxxxxx",
        password: "hunter2"
    )
    
    // 2. Send emails
}

Sending Emails

Before sending an email, first contruct a Mail object. Then, call sendMail on the client.

let mail = Mail(
    from: MailUser(name: "My Mailer", email: "noreply@example.com"),
    to: [MailUser(name: "John Doe", email: "john.doe@example.com")],
    subject: "Welcome to our app!",
    content: .plain("Welcome to our app, you're all set up & stuff.")
)

try await client.sendMail(mail)

The Mail.Content type supports various other types of information including HTML, Alternative (HTML with Plaintext fallback) and multipart.

Community

Join our Discord for any questions and friendly banter.

If you need hands-on support on your projects, our team is available at hello@unbeatable.software.

Description

  • Swift Tools 5.10.0
View More Packages from this Author

Dependencies

Last updated: Fri May 30 2025 21:35:59 GMT-0900 (Hawaii-Aleutian Daylight Time)