I am trying to write a very simple web-based email client from scratch with PHP's standard library. I'll be honest; I'm not entirely sure what I'm doing, so this is something that I hacked together for trial-and-error learning. However, I keep timing out no matter what I try. Any advice? I know the intended output won't look pretty, but like I said, this is just for trial and error.
<?php
$stream = imap_open('{imap.gmail.com:993/imap/ssl}INBOX', '<email_removed>', '<password_removed>') or
die('Cannot connect to server: ' . imap_last_error());
$date = date('d M Y', strtotime('-1 month'));
if ($emails = imap_search($stream, "SINCE \"$date\"")) {
rsort($emails);
foreach ($emails as $email_number) {
echo imap_fetchbody($stream, $email_number, 2);
}
}
imap_close($stream);
?>
The output I get it as follows.
Warning: imap_open() [function.imap-open]: Couldn't open stream {imap.gmail.com:993/imap/ssl}INBOX in on line 3 Cannot connect to server: Can't connect to gmail-imap.l.google.com,993: Network is unreachable
Notice: Unknown: Can't connect to gmail-imap.l.google.com,993: Connection timed out (errflg=1) in Unknown on line 0
Notice: Unknown: Can't connect to gmail-imap.l.google.com,993: Connection timed out (errflg=1) in Unknown on line 0
Notice: Unknown: Can't connect to gmail-imap.l.google.com,993: Network is unreachable (errflg=2) in Unknown on line 0
After further research, my host (HostMonster) disallows this, so I will have to take my business elsewhere. :/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With