Page 1 of 1
PHP and POP3
Posted: Sun Jan 25, 2009 5:40 pm
by arya6000
Hello
I want to write a small php script that connects to my gmail pop3 account and receive the sender's email and store it in a database, I searched online but did not find anything related to php and pop3, can you help me move forward with this?
Thank You
Re: PHP and POP3
Posted: Mon Jan 26, 2009 1:23 am
by John Cartwright
I'm off to bed so I won't get into this much (plus it is well documented).
Take a look at
imap, and more specifically imap_open() using the /pop3 flag, which will allow you to connect to your pop3 account.
I.e.
Code: Select all
$connection = imap_open ("{gmail.com:110/pop3}INBOX", "username", "password");
Re: PHP and POP3
Posted: Mon Jan 26, 2009 3:43 am
by Apollo
POP3'ing Google requires SSL.
I used
PHPMailer to achieve this. See also
this thread.
Re: PHP and POP3
Posted: Mon Jan 26, 2009 11:08 am
by John Cartwright
I would advise to avoid using PHPmailer. It has been unsupported for quite some time.
From a user comment, if you want to connect to imap with gmail you would do (
source)
Code: Select all
$mbox = imap_open ("{imap.gmail.com:993/imap/ssl}INBOX", "username@gmail.com", "password")
or die("can't connect: " . imap_last_error());
If you really want to use pop3 (slower I believe), (
source)
Code: Select all
imap_open("{pop.gmail.com:995/pop3/ssl/novalidate-cert}INBOX", $username, $pasword);
Re: PHP and POP3
Posted: Tue Jan 27, 2009 2:34 am
by Apollo
Jcart wrote:I would advise to avoid using PHPmailer. It has been unsupported for quite some time.
You sure? The latest version is only 2 months old, and some spin-off projects (built on PHPmailer) were updated even last week.
Re: PHP and POP3
Posted: Tue Jan 27, 2009 1:42 pm
by John Cartwright
Ah I didn't know. Last time I checked it was a few years or so since the last update. But again.. I may be mistaken.