我可以在 iPhone 应用程序中以编程方式发送电子邮件吗?

发布于 2024-10-01 18:03:17 字数 357 浏览 6 评论 0原文

我需要能够从 iPhone 应用程序内以编程方式发送预先格式化的电子邮件或短信。这可以做到吗?我看过苹果的 MFMailComposeViewController 类,但是它“提供了一个管理编辑和发送电子邮件的标准接口”,并且 MFMessageComposeViewController 类也有它自己的“用于编写 SMS 文本消息的标准系统接口”。这些允许您向用户呈现一个界面,他们必须在其中填写所有数据,然后明确地按下发送按钮。

我无法使用此样板功能。

我需要能够发送消息而不向用户呈现任何界面。我知道这听起来很邪恶,但实际上它适用于商业应用程序,当现场用户在现场执行特定操作时,需要与中央办公室的用户组进行通信。

有没有人找到解决这个问题的方法?

I need to be able to send a pre-formatted email or SMS text message programmatically from within an iphone app. Can this be done? I have looked at apple's MFMailComposeViewController class, but this "provides a standard interface that manages the editing and sending an email message" and the MFMessageComposeViewController class also has it's own "standard system interface for composing SMS text messages". These allow you to present an interface to the user where they have to fill in all the data and then explicitly press a send button.

I cannot use this boilerplate functionality.

I need to be able to send a message without presenting any interface to the user. I know this sounds evil, but actually it is for a commercial application which needs to communicate to a user group in a central office when users in the field have performed specific actions out in the field.

Has anyone found a solution to this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

温柔女人霸气范 2024-10-08 18:03:17

经过大量调查后,我发现在没有用户干预的情况下,从 iPhone 应用程序以编程方式发送电子邮件无法使用任何 Apple 框架来实现。

After much investigation, I have found that sending emails programmatically, without user intervention, from an iphone application, cannot be implemented using any of the apple frameworks.

孤寂小茶 2024-10-08 18:03:17

设置可使用 HTTP 请求发布到的 Web 服务。如果您只向一个地址发帖,那么这种方法可以很好地发挥作用,尽管您可能希望让用户输入他们的回邮地址。

否则,只有标准对话框可用(这依赖于使用他们在设备上设置的任何帐户)。

Set up a web service you can post to using an HTTP request. If you are posting to only one address this can work very well, although you may want to get the user to input their return mail address.

Otherwise only the standard dialog is available (this relies on using whatever account they've setup on the device).

老街孤人 2024-10-08 18:03:17

以下是一些适用于 OS X 的 SMTP API。它们也可能适用于 iOS。

  • 哑剧
  • MailCore
  • EdMessage

Here are a few SMTP API's that work on OS X. They might work on iOS as well.

  • Pantomime
  • MailCore
  • EdMessage
哭了丶谁疼 2024-10-08 18:03:17

只能通过 Web 界面进行,您不能隐藏界面,这是根据苹果开发者指南和文档

Only Possible via Web Interface, you can not hide the Interface , this is as per apple Guidlines to Developer and as per documentation

忆依然 2024-10-08 18:03:17

在寻找此类问题的解决方案时,我在这里发现了一些有趣的东西:如何从 iPhone 应用程序发送邮件而不显示 MFMailComposeViewController?

我希望这会有用!

Looking for a solution to such a problem, I found something interesting here: How to send mail from iphone app without showing MFMailComposeViewController?

I hope this will be useful!

孤星 2024-10-08 18:03:17

这是标准不可能的。如果您无法使用标准对话框,则需要使用 SMTP。

SMS 也是一样,使用基于网络的 SMS 服务的对话框(其中大多数需要花费一些钱)。

This is standard not possible. If you can't use the standard dialog you need to use SMTP.

SMS is the same, use the dialog of use a webbased sms service (most of these cost some money).

茶底世界 2024-10-08 18:03:17

我没有使用 iOS 的经验,但我对电子邮件协议有足够的经验,如果客户端应用程序可以在不访问服务器的情况下发送电子邮件,我会感到非常惊讶。电子邮件很可能将使用 SMTP 协议发送,因此必须使用 SMTP 服务器发送。选择如何连接到该服务器是您唯一的选择。您可以连接到服务器端脚本(例如 php)来生成并发送电子邮件,或者您也可以创建一个套接字并直接连接到 SMTP 服务器上的端口 25,并且仍然从客户端应用程序生成电子邮件。

查看:

I have no experience with iOS, but I have enough experience with email protocols to say I'd be very surprised if a client application could send email without accessing a server. More than likely, the email will be sent using the SMTP protocol and therefore must be sent using an SMTP server. Choosing how you connect to that server is about the only option you have. You could connect to a server-side script (such as php) to generate and send the email, or you may be able to create a socket and connect directly to port 25 on the SMTP server and still generate the email from you client application.

Check out:

回眸一笑 2024-10-08 18:03:17

您始终可以使用 SMTP 协议对已知邮件服务器进行低级 telnet 来发送消息。我不知道苹果是否会拒绝该应用程序,但 SMTP 非常简单。

You could always do a low level telnet using SMTP protocol to a known mail server to send a message. I don't know if Apple will reject the app, but SMTP is damned simple.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文