使用 Swift 和 Xcode 6 发送自动电子邮件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29034099/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Sending an automatic Email with Swift and Xcode 6
提问by Noah Barsky
How would you send an automatic email in a swiftios app? I don't want to use MessageUI because it is not automatic. How could you do this?
您将如何在swiftios 应用程序中发送自动电子邮件?我不想使用 MessageUI,因为它不是自动的。你怎么能这样做?
回答by allthethings
If you're looking to programmatically send emails, I would use MailCoreto do this, which can use the SMTP/IMAP protocols. It works on both OSX and iOS too! Here is a great SMTP example in Swift: Sending Mailcore2 Plain Emails in Swift
如果您希望以编程方式发送电子邮件,我会使用MailCore来执行此操作,它可以使用 SMTP/IMAP 协议。它也适用于 OSX 和 iOS!这是 Swift 中一个很棒的 SMTP 示例: Sending Mailcore2 Plain Emails in Swift
回答by LinusGeffarth
The thing is that Apple does not allow you to send e-mails in the background. I came across that problem as well. You'll have to let the user confirm to send it. So create the mail and let it pop up, then the user just needs to press send.
问题是 Apple 不允许您在后台发送电子邮件。我也遇到了这个问题。您必须让用户确认才能发送。所以创建邮件并让它弹出,然后用户只需要按发送。
Thats unfortunately the only way to do it.
不幸的是,这是唯一的方法。
Hope it helps :)
希望能帮助到你 :)
回答by Ayush Dixit
Apple do not allow you to send emails in the background without user's interaction. The only way you can do this with using this blog. http://iosameer.blogspot.in/2013/01/sending-e-mail-in-background-from-ios_25.html. It will surely work for you.
Apple 不允许您在没有用户交互的情况下在后台发送电子邮件。使用此博客可以做到这一点的唯一方法。 http://iosameer.blogspot.in/2013/01/sending-e-mail-in-background-from-ios_25.html。它肯定对你有用。