Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var smtpSession = MCOSMTPSession()
- smtpSession.hostname = ""
- smtpSession.username = ""
- smtpSession.password = ""
- smtpSession.timeout = 5
- smtpSession.port = UInt32(port!)!
- smtpSession.authType = MCOAuthType.saslPlain
- smtpSession.connectionType = MCOConnectionType.startTLS
- smtpSession.connectionLogger = {(connectionID, type, data) in
- if data != nil {
- if let string = NSString(data: data!, encoding: String.Encoding.utf8.rawValue){
- NSLog("Connectionlogger: \(string)")
- }
- }
- }
- var builder = MCOMessageBuilder()
- builder.header.to = [MCOAddress(displayName: "Some Receiver Name", mailbox: "receiver@abc.com")]
- builder.header.from = MCOAddress(displayName: "Some Sender Name", mailbox: "sender@abc.com")
- builder.header.subject = "Some Heading"
- builder.htmlBody = "<h1>heading</h1>"
- builder.textBody = "Some Text"
- let rfc822Data = builder.data()
- let sendOperation = smtpSession.sendOperation(with: rfc822Data)
- sendOperation?.start { (error) -> Void in
- if (error != nil) {
- print("Error sending email: \(error)")
- } else {
- print("Mail Sent")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement