PHP / MySQL query response - save email response in database?

I am creating a basic support request system in which the client can log in and ask a question, and the administrator can log in and answer, and he will set the status to “Answer” and the client will email them to let them know someone answered.

My question is: I have a section "comments", which is a log of interaction between the administrator and the client. If I send an initial reply from the administrator to the client by email, then I had the feeling that they would simply hit “Reply” from their email and start communicating through it, and the logs would not be saved.

I could either send the client’s email, or say “Log in to view the answer,” or maybe if the client really answers, I can somehow track it and insert it into the comment table, as it did from the site. If possible?

Just wondering if there is a standard way to do this and any suggestions you might have.

Thanks!

+7
source share
3 answers

When sending email to a user, you can send it from the email address created for this particular ticket. Something that can identify it with your email system to help you redirect it back to the php ticketing system.

support (ticketnumber) @domain

support12345@mydomain.com

Then it depends on your mail server how to go from there. There are some helpful tips on this subject that may help or get started.

How to get emails and their attachments from PHP

+7
source

If you want their response to be automatically inserted into the database, you will be assigned a cron job on your server to run the php script to determine if there is a response from the client (you need a list of email tables and client names.

Each time a client uses the ticket system, their email and name are in this table).

You also need to connect to the Inbox using imap or SMTP, and for this there are scripts (phpmailer, swiftmailer, etc.) and "walk" through each email and see if the sender's mail address matches your clients table. Then do an INSERT in the comment table.

The easiest way to read emails is every time the comment page loads, but this will make the page load longer. However, data will always be larger in real time compared to cron jobs.

+1
source

You can use the mail pipeline (if your server supports it).

In the subject, you will have a unique identifier that contains the ticket identifier or something unique to the ticket. Example: “How do I eat food [Question: No. 1234]”, where 1234 is the ticket identifier.

In the control panel, you must configure the mail forwarder to your script mail pipeline.

This tutorial provides the basics for creating email messages, and I used it as a base for my pipeline script: http://www.damnsemicolon.com/php/parse-emails-in-php-with-email-piping-part -one

+1
source

All Articles