douzhenchun6782
2015-03-11 23:06
浏览 75
已采纳

解析用PHP发送到地址的电子邮件?

I have for years as a side project wanted to build a nice little PHP library that can allow emails sent to a predefined email address to then be parsed with PHP and saved into a MySQL database.

Many support ticket and help desk have this functionality. You can send an email to an address and based on the email address it is from and content it will create a support ticket for a user. Also reply emails will add ticket replies to the system al from Emails sent.

This whole concept has always fascinated me and at one time I had done enough research to fully know how to do it. It's been years now though and I am not sure the best route to achieve this anymore and I am looking for information on how to do it now.

I would like to build some sort of SugarCRM plugin that uses this capability to be able to assign emails from my clients to there Account and Contact records in my CRM.

My initial search tonight has found this project PHP Mime Mail Parser here https://code.google.com/p/php-mime-mail-parser/ It states: "You will need to download the email to a file first and then pass it to MimeMailParser." So that could be helpful to find a program or method that does that as well...saves the emails to a file where I can access with PHP and then delete them. I just am not sure if that is the best and standard route of doing this?

Also this library which looks the same but on Github and recently worked on (recent to the post date of this question that is) https://github.com/eXorus/php-mime-mail-parser

1) Is there some special email software to run on the server to simplify this process?

2) How can I achieve this? I am not looking for how to read the email and parse the ID and other data in the email content...I just need help with getting the email content passed to my PHP script!

Of course, if some open source library exist that I can study or maybe even use that does this functionality, that would be amazing too but I am not aware of it yet.

Look forward to some info on the subject please?

This is a similar question to How do I parse emails in realtime as they are received however the answer on that question explains how to pipe/forward emails to a PHP script only if you are using CPanel which I am not! It is the desired action I need, just without CPanel's help.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • doushouj966020 2015-03-12 00:37
    最佳回答

    Most MTA's have the ability to pipe incoming mail to a script. Then a script like the on that you reference in How do I parse emails in realtime as they are recieved can process incoming messages as the arrive.

    As far as MTA's go, qmail (http://cr.yp.to/qmail.html) is one of the simpler MTA's to setup and manage. If you decide to go with qmail, I would recommend the site lifewithqmail.org for an excellent guide on how to install it and set it up. Once you have qmail installed and running, do the following to configure incoming messages to be piped to your PHP script:

    Add a line in /var/qmail/control/rcphosts to tell qmail that it should be acting as the MX for your domain.

    In /var/qmail/control/virtualdomains, add a line like so to tell qmail which user account to route mail to for this domain: domain.tld:username

    create a .qmail-default file in user directory, containing a pipe to the script that you want to route the mail to: | /path/to/script

    restart qmail.

    You'll need to grant execute permissions for all on the script.

    At this point, each incoming message should be piped to the PHP script by qmail.

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题