Jump to content

reading email with php script


Drongo_III

Recommended Posts

Hi Guys

 

I'm just looking for some advice to make sure i go in the right direction from the off!

 

Building a new system for a client. They'll receive contact information from a contact form on their website and the details of the contact form are logged in the admin area of the cms. The client wants to be able to respond to these contacts via email without logging into the system and then have the details of the reply logged in the admin area of the cms to know when something has been responded to.

 

So essentially i need some way of getting that email into the database. The only way i can see this happening is to setup a new mailbox, the client blind copies that mailbox address into all replies, a cron then runs a php script that picks up most recent emails via imap and then reads in the data - thereby registering the fact a response has happened (probably from the subject line reference) and it would then update the status of the contact. I am assuming this is theoretically possible as i've never done anything like that before.

 

So...

 

1) Is there a better way of doing this without having the client  login to the site to respond?

2) Does the proposal above sound reasonable?

 

Any advice would be much appreciated...

 

Drongo

 

 

 

Link to comment
Share on other sites

You can use IMAP functions to read mail. eg

<?php
if (!extension_loaded('imap')) {
    dl('php_imap.dll');
}
/* conneciont to mail */
$hostname = "{servername:110/pop3}INBOX";
$username = 'domain\\mailboxusername';
$password = 'password';

/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to server: ' . imap_last_error());
$startdate = date('d M Y', strtotime($_GET['date']));
$nowdate = date ('d M Y');

/* grab emails */
$emails = imap_search($inbox, "ALL SINCE \"$startdate\" BEFORE \"$nowdate\"");

  
?>

Link to comment
Share on other sites

Hi Barand

 

Thanks for that. I thought imap might be the way to go but wanted to make sure i wasn't missing some simpler solution.

 

:)

 

You can use IMAP functions to read mail. eg

<?php
if (!extension_loaded('imap')) {
    dl('php_imap.dll');
}
/* conneciont to mail */
$hostname = "{servername:110/pop3}INBOX";
$username = 'domain\\mailboxusername';
$password = 'password';

/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to server: ' . imap_last_error());
$startdate = date('d M Y', strtotime($_GET['date']));
$nowdate = date ('d M Y');

/* grab emails */
$emails = imap_search($inbox, "ALL SINCE \"$startdate\" BEFORE \"$nowdate\"");

  
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.