I need to send a mail(s) in the background for my app. What is the best way of doing this? I have tried Mailgun, but hav not got it working. Any tips on what the best/easiest way to send mail in background? Here´s the code I was trying for Mailgun:
let parameters = [
"from": "my@mail.com",
"to": "you@mail.com",
"subject": "Test",
"text": "Testing"]
let header : HTTPHeaders = [
"Authorization": "MY-KEY",
"Content-Type" : "application/x-www-form-urlencoded"]
let url = "MY-URL"
AF.request(url,
method: .post,
parameters: parameters,
encoding: URLEncoding.default,
headers: header)
.responseJSON { response in
print("Response: \(response)")
}
This throws the following error:
failure(Alamofire.AFError.responseSerializationFailed(reason: Alamofire.AFError.ResponseSerializationFailureReason.jsonSerializationFailed(error: Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.})))