0

this code works fine but it pops a window, then have to click send. Can I send it in the background without pops a window? Thank everybody!

import Cocoa

class SendEmail: NSObject {
    static func send() {
        let service = NSSharingService(named: NSSharingServiceNameComposeEmail)!
        service.recipients = ["abc@dom.com"]
        service.subject = "Vea software"
        
        service.performWithItems(["This is an email for auto testing through code."])
    }
}
SendEmail.send()

1 Answers1

1

You can't do that, this would be quite not secure if a dev could sent any email from user's address without even letting him know

In background you can send a http request to your server which will send an email, but it will send it from your developer/organization/etc address, not from user's one ofc.

Phil Dukhov
  • 67,741
  • 15
  • 184
  • 220