Index: trunk/roundcubemail/program/steps/mail/show.inc
===================================================================
--- trunk/roundcubemail/program/steps/mail/show.inc	(revision 1400)
+++ trunk/roundcubemail/program/steps/mail/show.inc	(revision 1525)
@@ -45,4 +45,22 @@
   // calculate Etag for this request
   $etag = md5($MESSAGE->uid.$mbox_name.session_id().intval($MESSAGE->headers->mdn_sent).intval($MESSAGE->is_safe).intval($PRINT_MODE));
+
+  // check known senders to display images
+  if (!$MESSAGE->is_safe 
+	&& !$_SESSION['safe_messages'][$MESSAGE->uid]
+	&& !isset($_GET['_safe']) 
+	&& $RCMAIL->config->get('addrbook_show_images')
+	&& $MESSAGE->has_html_part())
+    {
+      $CONTACTS = new rcube_contacts($DB, $_SESSION['user_id']);
+      $senders = $IMAP->decode_address_list($MESSAGE->headers->from);
+
+      foreach ($senders as $sender)
+        if ($sender['mailto'] && $CONTACTS->search('email', $sender['mailto'], true, false)->count)
+	  {
+	  $MESSAGE->set_safe();
+	  break;
+	  }
+    }
 
   // allow caching, unless remote images are present
