I don't think it's possible to do this in the app, probably because of a privacy and spam reduction policy. Imagine if any app could randomly just post emails with your data in without your knowledge. The mail sheet appears so you know that you're about to send an email.
However, you can do this if you have your own server. I'm guessing your Dad has a website for his business? You can write a script that sits on the server, and receives data that your app sends, then sends the email itself using the server's mail app. Something like this:
@IBAction func sendConsultationRequest(_ sender: AnyObject) {
DispatchQueue.main.async {
// Disable the UI, show an activity spinner
self.activitySpinner.isHidden = false
self.activitySpinner.startAnimating()
}
// Craft the url to call
let url: URL = URL(string: "https://www.website.com/app/sendmessage.php")!
let request: NSMutableURLRequest = NSMutableURLRequest(url: url)
request.httpMethod = "POST"
// Craft the parameters that are going to be sent to the server script
let params = ["message": messageField.text!, "customerName": customerName.text!, "customerEmail": customerEmail.text!] as Dictionary<String, String>
request.httpBody = try! JSONSerialization.data(withJSONObject: params, options: [])
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("application/json", forHTTPHeaderField: "Accept")
// Call the script, and then re-enable the UI, stop the activity spinner etc.
URLSession.shared.dataTask(with: request as URLRequest) {data, response, err in
DispatchQueue.main.async {
self.activitySpinner.stopAnimating()
self.dismiss(animated: true) { () -> Void in }
}
}.resume()
}
And the script on the server should be something like this (PHP):
<?php
$handle = fopen('php://input','r');
$jsonInput = fgets($handle);
$decoded = json_decode($jsonInput, true);
$to = 'dad@website.com';
$subject = 'Consultation request';
$body = 'From: ' . $decoded['customerName'] . "\r\n" .
'Email: ' . $decoded['customerEmail'] . "\r\n" .
'Message: ' . $decoded['message'];
$headers = 'From: app@website.com' . "\r\n" .
'Reply-To: app@website.com' . "\r\n" . // You can change this to the customer's email if you want your Dad to be able to reply directly to them
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $body, $headers);
?>