Connecting to strato.de with imap isn’t easy at all, as there’s little documentations on the Internet, and they are mainly in dutch. So I will present in the following lines how you can access your e-mails from a php file.
$server = ‘{imap.strato.de:143}’;
$connection = imap_open($server, “youremail@yourdomain.nl”, “yourpassword”);print_r(imap_errors());
$mailboxes = imap_list($connection, $server, ‘*’);
foreach($mailboxes as $mailbox)
$shortname = str_replace($server, ”, $mailbox);imap_reopen($connection, $server.’INBOX’);
$count = imap_num_msg($connection);
for($i = 1; $i <= $count; $i++) {
$header = imap_headerinfo($connection, $i);
$raw_body = imap_body($connection, $i);
}
$server – the connection parameteres, differs from server to server. For exemple:
- Google: {imap.gmail.com:993/ssl/novalidate-cert}
- Google Apps: {imap.googlemail.com:993/ssl/novalidate-cert}
$connection: this is the IMAP stream
$mailboxes: will contain all the mailboxes you have (Inbox, Trash, Sent + persobal mailboxes)
$shortname: will contain just the name of the mailboxes, without their server address
imap-reopen: you can make a new stream, connecting to a given mailbox (INBOX in my case)
$count: how many mails do you have in the selected mailbox
- the last for cycle runs through the mailbox, and for every e-mail gets it’s header information ($header) and the mail’s content ($raw_body)

January 5th, 2011
admin
Posted in
Tags:



