I want to use swift to implement in-app email. When I click the button, the email window pops up. However, I am unable to send my email. Moreover, after I click cancel-delete dr
In case anyone is looking for a non MFMailCompose option, here's what I did to send using Gmail's SMTP servers.
MyApp-Briding-Header.h
#import "Base64Transcoder.h" #import "HSK_CFUtilities.h" #import "NSData+Base64Additions.h" #import "NSStream+SKPSMTPExtensions.h" #import "SKPSMTPMessage.h"
Objective-C Briding Header
-> Debug
(i.e. MyApp/MyApp-Bridging-Header.h
Select all .m files and click enter. Type -fno-objc-arc
and hit enter.
Use this code to send email:
var mail = SKPSMTPMessage() mail.fromEmail = "fromemail@gmail.com" mail.toEmail = "tomail@gmail.com" mail.requiresAuth = true mail.login = "fromemail@gmail.com" mail.pass = "password" mail.subject = "test subject" mail.wantsSecure = true mail.relayHost = "smtp.gmail.com" mail.relayPorts = [587] var parts: NSDictionary = [ "kSKPSMTPPartContentTypeKey": "text/plain; charset=UTF-8", "kSKPSMTPPartMessageKey": "test message", ] mail.parts = [parts] mail.send()
Hope it helps someone. I didn't want to use the MFMailCompose option because I didn't want to have to prompt the user.