Swift framework for using SendGrid v3.
pod 'SendGrid-Swift'
import SendGrid_Swift
func sendMail() {
let sendGrid = SendGrid(withAPIKey: "USE YOUR SENDGRID API KEY HERE")
let content = SGContent(type: .plain, value: "Now is the time for all good men to come to the aid of their country.")
let from = SGAddress(email: "sender@example.com")
let personalization = SGPersonalization(to: [ SGAddress(email: "recipient@example.com") ])
let subject = "Hello, world!"
let email = SendGridEmail(personalizations: [personalization], from: from, subject: subject, content: [content])
sendGrid.send(email: email) { (response, error) in
if let error = error {
log.error("Error sending email: \(error.localizedDescription)")
}
}
}