How to send a simple email using SMTP Kitten:
// Create Mail instance
let mail = Mail(
from: MailUser(name: "My Mailer", email: "[email protected]"),
to: [MailUser(name: "John Doe", email: "[email protected]")],
subject: "Welcome to our app!",
contentType: .plain,
text: "Welcome to our app, you're all set up & stuff."
)
// Connect to the SMTP server
let client = try await SMTPClient.connect(
hostname: "smtp.example.com",
ssl: .startTLS(configuration: .default)
)
// Login using your credentials
try await client.login(user: "[email protected]", password: "pas$w0rd")
// Send out mails ๐
try await client.sendMail(mail)