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
https://forums.phpfreaks.com/topic/261308-reading-email-with-php-script/
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\"");

  
?>

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\"");

  
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.