使用 PHP 脚本处理传入的电子邮件
因此,我试图弄清楚如何将电子邮件发送到某个地址,例如 [email ;protected],而不是将电子邮件发送到那里,而是将其发送或转发到我创建的脚本,以读取电子邮件的内容并将内容存储到数据库中。关于如何在 PHP 中做到这一点有什么建议吗?
谢谢!
So I'm trying to figure out how to send an email to an address for example, [email protected] and instead of the e-mail going to there it would be instead sent or forwarded to a script that I create to read the contents of the email and store the contents into a database. Any suggestions on how to do it in PHP?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用以下代码来开始:
Here's some code you could use to get you going:
有两个选项:
1) 如果您有权访问收件人电子邮件服务器上的 shell,则可以设置一条规则,以便在收到新邮件时触发脚本(例如通过 procmail 等)。
2) 您可以允许电子邮件像平常一样放入邮箱,然后编写 PHP 脚本通过 IMAP 访问邮箱,拉取新邮件,处理它们,然后删除它们。然后每隔几分钟通过 cron 运行一次。
Two options:
1) If you have access to the shell on the recipient email server, you can set up a rule to fire a script (like via procmail or the like) whenever a new message is received.
2) You can allow the email to drop into the mailbox as normal, then write your PHP script to access the mailbox via IMAP, pull the new messages, process them, then delete them. And then run the thing by cron every few minutes.