发送电子邮件没有GUI

有没有任何框架可以让我发送电子邮件,而无需通过GUI?

添加这个框架到你的项目,然后使用我的Swift类:

class EmailSender : SKPSMTPMessageDelegate { private init() {} static let sharedInstance = EmailSender(); func sendEmail(email : String, subject : String, message : String) { let EMAIL_FROM = "test@gmail.com"; let EMAIL_PASS = "TestPassword"; let SMTP_SERVER = "smtp.gmail.com"; let EMAIL_TO = email; let emailMessage = SKPSMTPMessage(); emailMessage.delegate = self; emailMessage.fromEmail = EMAIL_FROM; emailMessage.toEmail = EMAIL_TO; emailMessage.relayHost = SMTP_SERVER; emailMessage.requiresAuth = true; emailMessage.login = EMAIL_FROM; emailMessage.pass = EMAIL_PASS; emailMessage.subject = subject; emailMessage.wantsSecure = true; let plainMsg = [ kSKPSMTPPartContentTypeKey : "text/plain", kSKPSMTPPartMessageKey : message, kSKPSMTPPartContentTransferEncodingKey : "8bit" ]; emailMessage.parts = [plainMsg]; emailMessage.send(); } //MARK SKPSMTPMessageDelegate @objc func messageSent(_ message: SKPSMTPMessage!) { } @objc func messageFailed(_ message: SKPSMTPMessage!, error: Error!) { } } 

你需要从iPhone用户邮件应用程序发送的电子邮件? 否则,您可以将操作卸载到服务器上,并让服务器代表用户邮寄,尽pipe您可能有垃圾邮件问题取决于您使用的服务(Mail Chimp等)。