Looking to be pointed in the right direction to create the ie. someone emails to support#domain.com, with their issue, the email via php is recognized that it's a "fresh" email that's not in the system so the email is registered in a database, the sender of the email would receive an auto response with a ticket ID saying we'll get back to them & that's their ticket and any emails back and forth with that ticket id in the subject line and/or bottom body would be registered in the database so the customer could login to the client area and see them and reply there as well.
I know DreamHost & Apple (specifically iTunes Customer Support) makes use of this "id - ticket" type system, and just want to be pointed in the correct direction.
Thanks.
This would probably be a good read for retrieving and working with emails in PHP - http://www.tuxradar.com/practicalphp/15/6/1.
Each email message should have message id in the headers, but this not something that you can really rely on so I would use some combination of a few email message attributes. Maybe the sender's email address and a checksum (http://php.net/manual/en/function.crc32.php) of the body and subject.
You could use this (http://php.net/manual/en/function.uniqid.php) to generate unique ticket ids and store them in the db or just use the primary key of the tickets/emails table.
Related
I have a website that let users subscribe with their email IDs.
I want to create a cron job that checks the bounced emails via imap connection, and I am using PHP class for that.
The cron job's script supposed to search for emails from "Mail delivery system" and scan the body of the email to detect the invalid email ID in order to mark it in mysql database.
I don't have any problem with IMAP connection or search, but the problem is: I can't find the pattern that the script should look for to define where is the invalid email ID written in the message.
Could you please help me what shall the script look for? (e.g. some word that the email ID will come after or before? Or maybe an HTML tag in the body of the message that carries the invalid email ID)
Thanks for the help
I have a problem with sending answer mails ans hope somebody can help me. First of all, sorry for my english ;)
I'm programming a forum. By sending an e-mail, datas (id, message, sender-mail, receiver-mails) get entered into a database. In the mail, there is also a link to a php-site. On this site one can accept/cancel (via checkboxes) and these commitments/cancellations will be sent in an answer-mail to the original sender of the mail.
Now my problem: I'm not able to send the answer-mail automatically back to the original sender, because I don't know how to get the mail-address.
Is there a possibility to include the ID in the mail, so that I'm able to filer the mail-address from the database?
Or are there any other possibilities?
Many thanks in advance :)
The question isn't very clear but I'll try anyway. If what you're trying to do is to know which recipient clicked a link in your email you can add that email plus a unique hash key to ensure authenticity of that info.
For example if email is abc#example.com then you could add the email as a parameter plus a hash parameter that it a simple hash of the email and a salt string to verify it was actually from the email sent to that person.
This is simpler than keeping it all in the database but you can also decide to store all pending confirmations for some days so that even a hacker won't be able to guess email addresses.
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!
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
support12345#mydomain.com
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
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.
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
Is there a way in PHP to update an email id in a mail server if we have the access details of the mail server. The requirement is as follows.
I am developing a community website which need a provision to upload photos to their photo gallery by sending an email. We planned to create email id for each user so that they could send emails with photo attachments to that id. A cron job will search for emails inside those id's and if it finds a mail with attachment, uploads the file to the server and subject of the email will be considered as the photo caption.
But it has a security loophole such that anyone who knows the email id can send an email and add photo to others account. We are planning to have a security code in their id which can be modified by user if required.
eg. name.XXXX#domain.com where XXXX is a four digit secret code. THe user can change that code whenever required. i.e. the email id can be name.1234#domain.com or name.3452#domain.com according to the user's wish to maintain privacy. So is there a way to edit the email id using PHP functions.
Creating email accounts and/or aliases would certainly be possible with PHP, but it would depend so much on your server setup.
Another route to consider would be to not have any real email boxes, but to instead have all email delivered to a catch-all account and have your cron script search through that one mailbox and compare all recipient addresses against a database, then you don't have to worry about actually creating real email users on the server.
Additionally, in terms of improving security, you could have each user authenticate which sender email addresses are allowed to send emails with photo attachments. It's still not bullet-proof, because sender addresses can be spoofed, but it's an extra step in the right direction.
Twitter and Facebook invite new users to send an invitation to everyone in their Gmail, Hotmail, or Yahoo Mail accounts.
Is it easy to add this functionality to a website?
Thanks,
John
Last I checked you basically have to pretend to be a web browser then programatically log in to the site, scrape the contacts, then compose/send the message. It isn't difficult, but it is time consuming as each of these services works differently.
I does, however, look like people have written script for some of this though: example.
Yes!
What they generally do is to send in the email a special URL that contain a code, for example:
www.mysite.com?UserCode=ABC
That code (ABC) is associated to the email of the user so the application undestand which user is trying to subscribe. You must keep in a database the pair: email, code.
HTH
All of the above answers are correct, here is a summary and some more explanation:
You first need to get the user's login for each service you want to get contacts from (I personally don't understand why people would do that - I would never give my GMail password to Facebook, let along some little known web site).
Then you can simulate a login to the said website and grab their contact list as an export (all serious email services allow you to export the contact list as CSV or something). You can implement this yourself or use some external library such as contactgrabber mentioned by Haim.
You then go over their list of contacts and for each contact you generate a key (you want to generate a unique key for each email you send so you'd know who responded to you). Generating the keys is easy - take some info like the current user's email plus the target email address, add the current time and pass everything to a hashing function like SHA1 - should do the trick.
Now store in a database table for each contact you got: the inviting user's ID, the email address being invited and the key you generated.
Lastly send a nice email to each contact with a URL to your website's "invitation activation page" with the correct key applied - like so: http://www.somesite.com/invited?key=123456780abcdefgh
when that page is accessed, get the key from the URL and find it in the table - that would give you the email address that activated the invite and the user that invited them. From here you can take it to where ever you want.