I'm trying to send an mail from my app using a Node.js server. I would want to send the 'from' 'to' and 'content' of the email to the server and he would then send the email to the person.
I have found Nodemailer to use for sending emails, but how can I send the data (from,to,content) from my app to the server? I'm writing my app in Swift.
EDIT:
Here is my code for the app:
func post(params: Dictionary<String,String>, url:String) {
var request = NSMutableURLRequest(URL: NSURL(string: url)!)
var session = NSURLSession.sharedSession()
request.HTTPMethod = "POST"
var err:NSError?
var jsonObject = NSJSONSerialization.dataWithJSONObject(params, options: .PrettyPrinted, error: &err)
request.HTTPBody = jsonObject
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("application/json", forHTTPHeaderField: "Accept")
var task = session.dataTaskWithRequest(request, completionHandler: { (data,response,error)-> Void in
println(response)
})
task.resume()
}
I call this function with parameters like Email, From, To, and Content and send them to the Nodejs server. What would be the correct code for the server to handle the JSON object (send the email) and return 'Success' or 'Fail'? How can I use the JSON object in the server code?