您可以通过 PHP 接收电子邮件吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5162847/
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
Can you receive emails through PHP?
提问by Steven Hammons
I know you can send emails with PHP but, can you receive emails through PHP?
我知道您可以使用 PHP 发送电子邮件,但是,您可以通过 PHP 接收电子邮件吗?
采纳答案by Eran Galperin
You can pipe incoming mails into a PHP script so you can process it directly. Evolt has an article on how to setupsomething like that. This can be useful if you want to activate scripts programmatically by sending Emails to it (like responses to a newsletter mail that unsubscribes the user).
您可以将收到的邮件通过管道传输到 PHP 脚本中,以便您可以直接对其进行处理。Evolt 有一篇关于如何设置类似内容的文章。如果您想通过向脚本发送电子邮件来以编程方式激活脚本(例如对取消订阅用户的时事通讯邮件的回复),这会很有用。
If you just want to read mails using PHP, PHP has native functionsto talk to IMAP, NNTP and POP mailboxes.
如果您只想使用 PHP 阅读邮件,PHP 具有与 IMAP、NNTP 和 POP 邮箱通信的本机函数。
回答by deceze
You couldwrite a mail server in PHP that binds to a port and listens for incoming email.
But PHP is not the language I would recommend for tasks like this, and it would also be a hugely complex undertaking.
您可以用 PHP 编写一个绑定到端口并侦听传入电子邮件的邮件服务器。
但是 PHP 不是我推荐用于此类任务的语言,而且它也将是一项非常复杂的工作。
You can hook into an existing mail server as callback script, or periodically query a mail server via POP or IMAP. The latter option is the most common: run a PHP script that processes an email account via a cron task in intervals. See http://php.net/imap.
您可以挂接到现有的邮件服务器作为回调脚本,或者通过 POP 或 IMAP 定期查询邮件服务器。后一个选项是最常见的:运行一个 PHP 脚本,该脚本通过 cron 任务每隔一段时间处理一个电子邮件帐户。请参阅http://php.net/imap。
回答by Steve Smith
Take a look at http://cloudmailin.comit takes away a lot of the hassle involved with receiving the email and will send it directly to your app via an HTTP Post. We have quite a few php users using the system to receive email.
看看http://cloudmailin.com,它消除了接收电子邮件的许多麻烦,并通过 HTTP Post 将其直接发送到您的应用程序。我们有相当多的 php 用户使用该系统接收电子邮件。
回答by barbushin
There is a great library that is based on IMAP extension: http://code.google.com/p/php-imap
有一个基于 IMAP 扩展的很棒的库:http: //code.google.com/p/php-imap
回答by Alan Haggai Alavi
Only a mail server can receive e-mails. You could read mail box formats (such as mbox or Maildir) to read e-mail using PHP.
只有邮件服务器可以接收电子邮件。您可以阅读邮箱格式(例如 mbox 或 Maildir)以使用 PHP 阅读电子邮件。
PHP scripts functioning as IMAP/POP3 servers can receive e-mail sent to them.
用作 IMAP/POP3 服务器的 PHP 脚本可以接收发送给它们的电子邮件。