0

Specifically, I made a quiz in a navigation view. I want to learn how to send my quiz answers (from textfields) to my email.

Thank you in advance

Remy
  • 1

1 Answers1

0

The package: https://github.com/Kitura/Swift-SMTP

Use:

import SwiftSMTP

func sendMail(to receiver: Mail.User) {
    let smtp = SMTP(
        hostname: "smtp.gmail.com",     // SMTP server address
        email: "user@gmail.com",        // username to login
        password: "password"            // password to login
    )
    
    let me = Mail.User(
        name: "User",
        email: "user@gmail.com"
    )
    
    let mail = Mail(
        from: me,
        to: [receiver],
        subject: "Humans and robots living together in harmony and equality.",
        text: "That was my ultimate wish."
    )
    
    smtp.send(mail) { (error) in
        if let error = error {
            print(error)
        } else {
            print("Send email successful")
        }
    }
}
Nhat Nguyen Duc
  • 432
  • 2
  • 10