Send an email from my app without using MFMailComposeViewController

前端 未结 3 1835
孤独总比滥情好
孤独总比滥情好 2020-12-06 22:43

Is it possible to send an automatically generated email using my own email address to another email address of mine by clicking a button?

I tried to use MFMail

相关标签:
3条回答
  • 2020-12-06 23:10

    You can do it only by creating own server-side mailer. On button clicking you have to send request with all needed data (email address, body, subject, etc) and server will send mail.

    If You want send directly from app - MFMailComposeViewController is the only LEGAL way

    0 讨论(0)
  • 2020-12-06 23:12

    Yes there is a way using Swift-SMTP.

    Send email Create a Mail object and use your SMTP handle to send it. To set the sender and receiver of an email, use the User struct:

    let drLight = Mail.User(name: "Dr. Light", email: "drlight@gmail.com")
    let megaman = Mail.User(name: "Megaman", email: "megaman@gmail.com")
    
    let mail = Mail(
        from: drLight,
        to: [megaman],
        subject: "Humans and robots living together in harmony and equality.",
        text: "That was my ultimate wish."
    )
    
    smtp.send(mail) { (error) in
        if let error = error {
            print(error)
        }
    }
    
    0 讨论(0)
  • 2020-12-06 23:13

    By default in iOS you can only use the MFMailComposeViewController, which uses the user's mail account. Therefore you cannot send fully automated mail messages (the user allways has to confirm/cancel).

    libMailCore is a great iOS framework which allows you to generate and send mails without any user interferance. In that case you'll be using your own server/credentials (thus not the user mail account). There are apps in the App Store using mailcore, so i would guess it's legit.

    0 讨论(0)
提交回复
热议问题