PHP / MySQL Ticket Response - Store E-mail repsonse in database?
Asked Answered
G

3

7

I am building a basic support request system where the customer can log in and ask a question and an admin can go in and reply and it will set the status to "Responded" and e-mail the customer to let them know someone has responded.

My question is.. I have a "comments" section which is a log of the interaction between the admin and the customer. If I e-mail the customer the initial response from the admin, then I have a feeling they will just hit "Reply" from their email and start communicating through there, and the logs won't be stored.

I could either e-mail the customer and say "Log in to view the response", or maybe if the customer does hit reply I can somehow track it and insert that in the comments table like they did it from the website. If that is even possible?

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

Thanks!

Griselgriselda answered 6/1, 2012 at 14:15 Comment(1)
Don't use 'real' email addresses. Use virtual ones that route the emails through your ticket system so they can be logged.Estes
M
8

When sending the email to the user you can have it sent from an email address created for that specific ticket. Something that can identify it with your email system to help you route it back to the php ticketing system.

support(ticketnumber)@domain

[email protected]

Then it depends on your email server how to go from there. There are several useful tips at this question that may help or get your started.

How to get email and their attachments from PHP

Mastership answered 6/1, 2012 at 14:33 Comment(0)
N
1

If you want their reply to be automatically inserted into the DB, you'll have a assign a cron job in your server to run a php script to detect whether there's a reply from a customer (you need a table listing the customers' email and names.

Each time a customer uses the ticket system their email and name goes into this table).

You'll need to connect to your Inbox too via imap or SMTP, and there are scripts to do this (phpmailer, swiftmailer, etc) and "walk" through each email and see if the sender email matches any in your customers table. Then so an INSERT to the comments table.

Anther way is to read through the emails each time the comments page is loaded, but this will cause the page to take longer to load. However, the data will always be more "real-time" compared to cron jobs.

Niacin answered 6/1, 2012 at 14:43 Comment(1)
Thanks for your response. I use PHPMailer and connect via SMTP to send e-mail, but I can't find anything on the web on how to connect via SMTP to read the e-mails and check what is coming in? I have the customers email stored in the users table - so I just need help detecting whether there's a reply from a customer with PHPmailer.Griselgriselda
O
1

You could use email piping (if your server supports it).

In the subject, you'd have a unique identifier which contains the ticket ID or something unique to the ticket. Example: "How do I eat food [Question: #1234]", where 1234 is the ticket ID.

In your control panel, you would set up an email forwarder to your email piping script.

This tutorial offers the basics to email piping, and I used it as the base for my piping script: http://www.damnsemicolon.com/php/parse-emails-in-php-with-email-piping-part-1

Oversold answered 6/1, 2012 at 14:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.