Generate corresponding plain-text attachment
authorJamie Cameron <jcameron@webmin.com>
Fri, 31 Oct 2008 21:47:20 +0000 (21:47 +0000)
committerJamie Cameron <jcameron@webmin.com>
Fri, 31 Oct 2008 21:47:20 +0000 (21:47 +0000)
mailboxes/CHANGELOG
mailboxes/send_mail.cgi

index f4bb0bd..d95a32d 100644 (file)
@@ -54,3 +54,5 @@ Detection of messages with attachments is now 100% accurate, rather than taking
 ---- Changes since 1.430 ----
 Added support for Exim, thanks to Emmanuel Florac.
 Re-wrote the entire user interface to use the new Webmin UI library, and to bring it into sync with the Usermin module for reading mail.
+---- Changes since 1.440 ----
+HTML messages now have a converted plain-text attachment automatically added, for mail clients that only support text.
index 7218543..8d47f57 100755 (executable)
@@ -93,6 +93,25 @@ if ($in{'body'} =~ /\S/) {
                              'data' => $in{'body'} } );
                }
        $bodyattach = $attach[0];
+
+       if ($in{'html_edit'}) {
+               # Add the plain-text body
+               local $mt = "text/plain";
+               if ($plainbody =~ /[\177-\377]/) {
+                       push(@attach,
+                         { 'headers' => [ [ 'Content-Type', $mt ],
+                                          [ 'Content-Transfer-Encoding',
+                                            'quoted-printable' ] ],
+                           'data' => quoted_encode($plainbody) });
+                       }
+               else {
+                       push(@attach,
+                         { 'headers' => [ [ 'Content-Type', $mt ],
+                                          [ 'Content-Transfer-Encoding',
+                                            '7bit' ] ],
+                           'data' => $plainbody });
+                       }
+               }
        }
 $attachsize = 0;
 for($i=0; defined($in{"attach$i"}); $i++) {