PHP,MySQL:接收电子邮件,在数据库中自动搜索&根据结果​​发送电子邮件 [英] PHP, MySQL: Receive email, auto search in DB & send email based on the results

查看:137
本文介绍了PHP,MySQL:接收电子邮件,在数据库中自动搜索&根据结果​​发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

访问者可以通过联系表与工作人员联系(访问者也需要提交电子邮件).这将存储在数据库中.现在考虑到工作人员对此消息的答复,工作人员的答复将直接发送到访客电子邮件.假设用户想跟进员工发送的消息,我希望访问者只需点击其电子邮件服务中的回复"按钮即可.给我发送他在同一主题上的问题,但只需将ID保留在主题"行中即可.因此,当访客发送此电子邮件时,我想接收电子邮件&同时,尝试在我的数据库中搜索电子邮件主题中存在的ID是否确实存在于系统中.如果是,则将其发送回先前处理过该响应的同一工作人员,或者将其分配给新的工作人员.

Visitors can contact staff by means of contact form (visitor needs to submit email as well). This will be stored in DB. Now considering that staff responds to this message, the reply from the staff would be sent to the visitors email directly. Say if the user wants to follow up on the message sent by the staff, I would like the visitor to just hit the reply button in his email service & send me his questions on the same topic, but just retain the ID in the Subject line. So when the visitor send this email, I would like to receive the email & at the same time, try to search in my DB if the ID that is present in the email subject, actually exists in the system. If yes, that would be sent back to the same staff member who handled the response previously or it would be assigned to a new staff member.

话虽这么说,我正在思考如何做到这一点.我真正受阻的部分是当工作人员从访客的电子邮件中收到实际的电子邮件时,如何检查数据库?假设我/工作人员正在mydomain@hotmail.com接收电子邮件.当访问者发送回复电子邮件时,它将被发送到mydomain@hotmail.com.如何查看在mydomain@hotmail.com收到的电子邮件的主题行中的ID是否确实存在于我网站的数据库中?这是我真正被困的地方.

That being said, I was thinking of how to do this. The part where I am really held up is when the staff receives the actual email from the visitors email, how can I check the DB? Say I am/staff is receiving emails at mydomain@hotmail.com. When visitor sends reply email, then it would be sent to mydomain@hotmail.com. How can I check to see if the ID in the subject line of the email that I received at mydomain@hotmail.com, actually exists in my DB in my website? This is where I am really stuck.

期待您的答复.谢谢.

推荐答案

有几种方法可用于自动处理电子邮件.您选择哪一个取决于您的特定需求:

There are several approaches that you can use for automatically processing email. Which one you choose is going to depend upon your specific needs:

  1. 配置您的MTA(邮件服务器),使其在给定地址(例如:support@mydomain.com)接收邮件时运行程序.邮件本身将传递给程序进行处理.如果您拥有自己的邮件服务器,并且该方法是响应速度最快的解决方案,则此方法有效,但是配置起来可能非常复杂,通常需要重新启动邮件服务器才能进行更改.

  1. Configure your MTA (mail server) to run a program when it receives mail at a given address (eg: support@mydomain.com). The mail message itself will be passed to the program to handle. This works if you have your own mail server, and is the most responsive solution, but can be quite complex to configure and will usually require restarting the mail server to change.

编写一个程序,该程序定期扫描邮箱(使用POP或IMAP),然后处理每个新消息.在您不控制自己的邮件服务器的情况下(例如,您使用的是Gmail或Yahoo邮件),这种方法效果更好,并且配置起来更加灵活.

Write a program that periodically scans a mailbox (either with POP or IMAP) and then processes each new message. This works better for situations where you don't control your own mail server (eg: you're using Gmail or Yahoo mail) and is more flexible to configure.

为您的MUA(邮件客户端,例如MS Outlook,Thunderbird等)编写扩展名,这要求所有可能收到消息的人都运行相同的客户端软件,并且取决于客户端提供的API扩展.这不适用于仅Web界面,但允许您以交互方式处理消息并与用户进行交互.

Write an extension for your MUA (mail client eg MS Outlook, Thunderbird, etc.) This requires that everyone who could receive a message be running the same client software, and it depends upon the APIs that your client provides for extensions. This won't work with web-only interfaces, but will allow you to process a message interactively and to interact with the user.

尽管我也使用了第二种方法,但我倾向于第一种方法.

I tend to favor the first approach, though I have used the second approach as well.

这篇关于PHP,MySQL:接收电子邮件,在数据库中自动搜索&根据结果​​发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆