hello,
i am having some problems retrieving email from gmail. im not sure if its because its pop or what. unfortunatly my host doesnt have the pop module. but here is the code.

$imap = imap_open("{pop.gmail.com:995}INBOX", 

"username", "password");
   $messages = imap_sort($imap, SORTFROM, 1);

   foreach ($messages as $message) {
      $header = imap_header($imap, $message); 
      $prettydate = date("jS F Y", $header->udate);
      print "{$header->fromaddress} - $prettydate";?><br><?php
   }

   imap_close($imap);

any help with this will be greatly appreciated.

Member Avatar for langsor

Sorry, I have never done IMAP stuff with PHP (POP Yes) but luckily with all things Google there is plenty of documentation all over the web...

My first take is that you're using POP protocol on google's side of things pop.gmail.com:995 ...

This link suggests you need to enable IMAP on google before using it ...
http://mail.google.com/support/bin/answer.py?answer=75725

This is someone who has already done it, maybe you can learn through example here ...
http://deepakssn.blogspot.com/2006/06/gmail-php-send-email-using-php-with.html

This is the PHP main site discussion on using IMAP methods in PHP ...
http://us2.php.net/imap_open
Here I find useful nuggets like this ... possibly a useful example

$mbox = imap_open ("{imap.gmail.com:993/imap/ssl}INBOX", "username@gmail.com", "password")
     or die("can't connect: " . imap_last_error());

Sorry I can't help you more

Good luck

I have found that the script does work on other servers. I think my host has me locked down a little more than i would like. Guess its time to look for that VPS i have been wanting.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.