How to send an email to a receipent in background in iOS5?

后端 未结 8 537
不知归路
不知归路 2020-12-10 15:41

In an iPhone app,I want to send an email to a person who has forgotten about their passcode . I want to send the mail in background (cant use MFMailComposeViewController for

8条回答
  •  时光说笑
    2020-12-10 15:50

    https://github.com/troyz/MailUtil

    I have used library above to send mail in background, so it works.

    pod "MailUtil", :git => 'https://github.com/troyz/MailUtil.git', :tag => '0.1.0'
    

    Swift code is here:

    import MailUtil
    
    SendEmailOperation.setupConfig(withServer: "smtp.foo.com", withFrom: "foo@mailserver.com", withLogin: "foo@mailserver.com", withPassword: "*********")
    
    let operation = SendEmailOperation(to: "foo@mailserver.com", subject: "Hello", body: "world", path: "/selected/path/for/your/file.pdf")
    
    operation?.completionBlock = {
        debugPrint("Mail sent!")
        DispatchQueue.main.async {
             //showMailSentPopup()
       }
    }
    
    do {
          try SendEmailOperation.sendEmail(operation)
       } catch {
          debugPrint("Mail could not sent or sending result could not handle - \(error)")
       }
    

提交回复
热议问题