mercredi 1 juillet 2015

How do I send an email with Amazon SES in Swift?

I am trying to send an email with Amazon SES. I get no errors when I run this, but nothing happens. I've tried to find documentation, but Amazon is quite bad at this. So, any ideas? EDIT: I've verified the mail that I'm trying to send from in the Amazon SES console as well.

This is what I've got so far:

    let sns = AWSSES.defaultSES()

    var messageBody = AWSSESContent()
    var subject = AWSSESContent()
    var body = AWSSESBody()
    subject.data = "Subject"
    messageBody.data = "Message body"
    body.text = messageBody

    var message = AWSSESMessage()
    message.subject = subject
    message.body = body

    var destination = AWSSESDestination()
    destination.toAddresses = ["emailadress@gmail.com"]

    var send = AWSSESSendEmailRequest()
    send.source = "emailadress@gmail.com"
    send.destination = destination
    send.message = message


    sns.sendEmail(send).continueWithSuccessBlock {(task: BFTask!) -> BFTask! in
        NSLog("Sent mail - success")
        return nil
    }


}




Aucun commentaire:

Enregistrer un commentaire