Hello, I was visiting some sites like spam.la and dodgeit.com and wondering how these sites are implemented. I often wonder how things are implemented and feel bad when I fail to understand it I have no idea how one could link postfix and php so that all emails sent to a specific domain are shown. Can someone give me an idea on how to do this? Once I have the incoming email data, it's pretty easy to insert them in a MySQL database and display them. Thanks! Pryda
I'm not too familiar with IMAP, but here's something I wrote. (Yes I was bored, lol) <?php error_reporting(E_ALL); $imap_host = 'xxxxx.com'; $imap_port = 110; $imap_userid = 'xxxx@xxxxx.com'; $imap_password = 'xxxxxx'; $imap = @imap_open("{{$imap_host}/pop3:{$imap_port}}INBOX", $imap_userid, $imap_password) OR die(imap_last_error()); $status = imap_check($imap); $bgcolor1 = '#CCCCCC'; $bgcolor2 = '#FFFFFF'; if (isset($_GET['do'], $_GET['msgid']) AND $_GET['do'] == 'viewmsg') { $_GET['msgid'] = intval($_GET['msgid']); $structure = imap_fetchstructure($imap, $_GET['msgid']); if ($structure->type == 1 AND sizeof($structure->parts) == 0) { $body = imap_fetchbody($imap, $_GET['msgid'], 1); } else { $body = imap_body($imap, $_GET['msgid']); } ?> <pre> <?php echo $body; ?> </pre> <?php } else { ?> <table cellpadding="3"> <tr style="font-weight: bold;"> <td>#</td> <td>From</td> <td>Subject</td> <td>Date</td> </tr> <?php if (!$status->Nmsgs) { ?> <tr> <td colspan="4">No messages found</td> </tr> <?php } else { for ($i = 1; $i <= $status->Nmsgs; $i++) { if (!$msg = @imap_headerinfo($imap, $i)) { continue; } if (!trim($msg->Subject)) { $msg->Subject = '[No subject]'; } ?> <tr style="background-color: <?php echo $i % 2 == 0 ? $bgcolor1 : $bgcolor2; ?>;"> <td><?php echo $i; ?></td> <td><?php echo htmlspecialchars($msg->fromaddress); ?></td> <td><a href="?do=viewmsg&msgid=<?php echo $i; ?>"><?php echo $msg->Subject; ?></a></td> <td><?php echo $msg->Date; ?></td> </tr> <?php } } ?> </table> <?php } imap_close($imap); ?> PHP: It's not perfect, but should get you started...
Nice nico, I started, but I just couldn't be bothered to finish, something shiny prolly caught my attention
I made a simple site with nico_swd's code, but it's rather slow. Are there any ways to speed it up, besides caching the entries in a mysql database? The site is here: http://spamplz.com/