Jump to content

Geting subjects with IMAP


Pufas

Recommended Posts

Hello,

Here's little script that should get all email's subject via IMAP:

<?php

$imap = imap_open("{imap.gmail.com:993/imap/ssl}", "[email protected]", "password"); 
$message_count = imap_num_msg($imap); 

for ($i = 1; $i <= $message_count; ++$i) { 
  $header = imap_fetchheader($imap,$i,0);

  $first=strstr($header, "Subject: ");
  $second=strstr($header, "From: ");

  $fc=strlen($first);
  $sc=strlen($second);
  $le=$fc-$sc-9;

  $subject=substr($first,8,$le);
  echo $subject."\n";
  } 

imap_close($imap); 

?>

 

Well it works just fine on inbox with few emails, else, if you have lots of mail with attachments, it will give 30 sec timeout warning. How the the would i bypass downloading the whole message+body, but just a header (subject).

Thank's in advance!

Link to comment
https://forums.phpfreaks.com/topic/234607-geting-subjects-with-imap/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.