Click to See Complete Forum and Search --> : [RESOLVED] access mail box
thamizhinpan
Mar 18th, 2008, 11:43 AM
I would like to access mail box of gmail account.
How can I do it? If you have any ideas please share it with me?
If you can give sample source code on PHP, it'll be more use full and easy for me?:bigyello:
k1ll3rdr4g0n
Mar 22nd, 2008, 10:56 PM
This should get you started.
http://www.php.net/manual/en/function.imap-open.php
thamizhinpan
Mar 23rd, 2008, 05:17 AM
Thank you.
But I have already visited to this page and I have written a code with their help like this.
<?php
//connect to IMAP server
$imap = imap_open ("{imap.gmail.com:993/imap/ssl}INBOX", "xyz@gmail.com", "abcdef")
or die("can't connect: " . imap_last_error());
//get the number of messages in the INBOX
$check = imap_check($imap);
print("$check->Nmsgs messages<br>\n");
print("$check->Recent new messages<br>\n");
print("Most Recent Message: $check->Date<br>\n");
for($n=1; $n <= $check->Nmsgs; $n++)
{
$header = imap_headerinfo($imap, $n);
$body = imap_body($imap, $n, FT_INTERNAL | FT_PEEK);
print("<hr>\n");
$to = array();
foreach($header->to as $t)
{
$to[] = "$t->personal <$t->mailbox@$t->host>";
}
$to = implode(",", $to);
$from = array();
foreach($header->from as $f)
{
$from[] = "$f->personal <$f->mailbox@$f->host>";
}
$from = implode(",", $from);
print(
"Date: $header->date<br>\n" .
"To: " . htmlentities($to) . "<br>" .
"From: " . htmlentities($from) . "<br>\n" .
"Subject: $header->subject<br>\n" .
"<br>\n" .
nl2br(htmlentities($body)) . "<br>\n");
}
//close connection
imap_close($imap);
?>
But this is not working
k1ll3rdr4g0n
Mar 23rd, 2008, 10:39 AM
What is not working?
What error messages are you getting?
thamizhinpan
Mar 23rd, 2008, 02:09 PM
I got this error
Warning: imap_open() [function.imap-open]: Couldn't open stream {imap.gmail.com:993/imap/ssl}INBOX in e:\MyServer\apache group\Apache\htdocs\MyTest\Test 1.php on line 3
can't connect: Can't open mailbox {imap.gmail.com:993/imap/ssl}INBOX: invalid remote specification
k1ll3rdr4g0n
Mar 23rd, 2008, 02:35 PM
This is what I use to connect to pop3:
pop.gmail.com:995/pop3/ssl/novalidate-cert}INBOX
I wonder if you need SSL installed or something...
But try connecting using that, if you still get an error, then I might be right.
But that works fine under a linux system.
thamizhinpan
Mar 24th, 2008, 12:43 PM
I think you may right.
Because I have tried POP also. But it is worth less.
So I want install SSL. But Can I do it for my local server?
k1ll3rdr4g0n
Mar 24th, 2008, 07:04 PM
Of course. Someone probably has an OpenSSL package out there. If I am right all you need to do is install that and you should be good...
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.