diff --git a/include/class.mailfetch.php b/include/class.mailfetch.php
index 2e0b8b004067305bfb0aba1d2c2024873f2d8012..8b0cfcd7b8130cf6090612efa22f0159fa09a4e3 100644
--- a/include/class.mailfetch.php
+++ b/include/class.mailfetch.php
@@ -181,7 +181,9 @@ class MailFetcher {
             $text=imap_binary($text);
             break;
             case 3:
-            $text=imap_base64($text);
+            // imap_base64 implies strict mode. If it refuses to decode the
+            // data, then fallback to base64_decode in non-strict mode
+            $text = (($conv=imap_base64($text))) ? $conv : base64_decode($text);
             break;
             case 4:
             $text=imap_qprint($text);