Skip to content

undev4/MongoKitten

 
 

Repository files navigation

Undev4 Modifications: Added more textual detail to errors thrown with case commandFailed

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 SMTPClient.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.

About

Native MongoDB driver for Swift, written in Swift

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 100.0%