Im building a user created content app and I need to conform to the required guide lines. I am implementing a report feature in which I want an email sent to myself that sends the usersID, postID and post content for review. I am able to use the email composer to have the user send an email however, I dont want the user to need to send the email, I want it to automatically send when the button is pressed. Is there any way for me to implement this. This is what I have...
func sendEmail() {
let composeVC = MFMailComposeViewController()
composeVC.mailComposeDelegate = self
composeVC.setToRecipients(["random@gmail.com"])
composeVC.setSubject("Inappropriate Content Report")
if post.imageUrl != nil {
let data: Data!
let url = URL(fileURLWithPath: post.imageUrl!)
do {
try data = Data(contentsOf: url)
composeVC.setMessageBody("Reported Content: \n \n \(post.caption) \n \n Reported User: \(post.userID) \n \n PostID: \(post.postID)", isHTML: false)
composeVC.addAttachmentData(data, mimeType: "image/jpeg", fileName: post.imageUrl!)
} catch let error {
print("CHRIS THERE IS AN ERROR", error)
}
} else {
composeVC.setMessageBody("Reported Content: \n \n \(post.caption) \n \n Reported User: \(post.userID) \n \n PostID: \(post.postID)", isHTML: false)
}
self.present(composeVC, animated: true, completion: nil)
}