0

hey folks any ideas on how to approach this problem. I am sending out mails to users on a particular activity. Now when the user gets the mail, I need a functionality wherein if he replies from the email, the reply has to be stored in the database. Stack - PHP(Yii framework) & mysql

I read about IMAP and I have this code.

$hostname = '{imap.gmail.com:993/imap/ssl}INBOX'; 
$username = 'xx.xx@gmail.com'; 
$password = 'mypassword'; 
$inbox = imap_open($hostname,$username,$password) or exit('Cannot connect to Gmail: ' );

if ($inbox)
{
  echo "connected";
  imap_close($inbox);
}
else
{
  echo "not connected :<br>" . imap_last_error();
}

But nothing happens , am I doing anything wrong?

Ajey
  • 7,924
  • 12
  • 62
  • 86

1 Answers1

0

Have your application periodically connect to a mailbox receiving the replies via IMAP or POP3 and store the data in the database.

PHP's imap library can be used for working with POP3 mailboxes. Most of the advanced IMAP features won't work (e.g. folders or fetching message parts), but the basic POP3 functionality is implemented.

The main difference is the option string that you're passing to imap_open:

// To connect to a POP3 server on port 110 on the local server, use:
$mbox = imap_open ("{localhost:110/pop3}INBOX", "user_id", "password");
Kai
  • 277
  • 1
  • 3
  • 14
  • i am trying to connect to my gmail account. $hostname = '{imap.gmail.com:993/imap/ssl}INBOX'; $username = 'prince.lampard@gmail.com'; $password = 'mypassword'; $inbox = imap_open($hostname,$username,$password) or exit('Cannot connect to Gmail: ' ); – Ajey Mar 20 '14 at 05:44