Quoted-printable encoding of autoreplies
authorJamie Cameron <jcameron@webmin.com>
Thu, 18 Sep 2008 17:59:47 +0000 (17:59 +0000)
committerJamie Cameron <jcameron@webmin.com>
Thu, 18 Sep 2008 17:59:47 +0000 (17:59 +0000)
postfix/CHANGELOG
sendmail/CHANGELOG
sendmail/autoreply.pl

index 1a0dcd9..c4f1226 100644 (file)
@@ -59,3 +59,5 @@ Updated the BCC Mappings page to allow both sender and recipient maps to be defi
 Properly handle multiple reject_rbl_client DNS domains on the SMTP Client Restrictions page.
 ---- Changes since 1.430 ----
 Converted all pages to use the new Webmin UI library, for a more consistent and themable look.
+Autoreply messages containing non-ASCII characters are now properly quoted-printable encoded.
+
index b5b38d8..b50c42f 100644 (file)
@@ -35,3 +35,5 @@ Added an option to show the directory queued messages are in, which is useful on
 Network ports and addresses used by Sendmail can now be more easily edited on the new Network Ports page, which updates both sendmail.cf and any .mc file.
 ---- Changes since 1.400 ----
 Added an access control page option to prevent creation and editing of catchall address mappings.
+---- Changes since 1.430 ----
+Autoreply messages containing non-ASCII characters are now properly quoted-printable encoded.
index 8131bc9..80be6c7 100755 (executable)
@@ -203,6 +203,17 @@ foreach $f (@files) {
                        'data' => $data });
        }
 
+# Work out the encoding
+if ($rbody =~ /[\177-\377]/) {
+       # High-ascii
+       $enc = "quoted-printable";
+       $encrbody = &quoted_encode($rbody);
+       }
+else {
+       $enc = undef;
+       $encrbody = $rbody;
+       }
+
 # run sendmail and feed it the reply
 ($rfrom) = &split_addresses($rheader{'From'});
 if ($rfrom->[0]) {
@@ -218,8 +229,11 @@ foreach $h (keys %rheader) {
 # Create the message body
 if (!@attach) {
        # Just text, so no encoding is needed
+       if ($enc) {
+               print MAIL "Content-Transfer-Encoding: $enc\n";
+               }
        print MAIL "\n";
-       print MAIL $rbody;
+       print MAIL $encrbody;
        }
 else {
        # Need to send a multi-part MIME message
@@ -228,9 +242,13 @@ else {
        $ctype = "multipart/mixed";
        print MAIL "Content-Type: $ctype; boundary=\"$bound\"\n";
        print MAIL "\n";
-       splice(@attach, 0, 0, { 'headers' => [ [ 'Content-Type', 'text/plain' ],
-                                            ],
-                               'data' => $rbody });
+       $bodyattach = { 'headers' => [ [ 'Content-Type', 'text/plain' ], ],
+                       'data' => $encrbody };
+       if ($enc) {
+               push(@{$bodyattach->{'headers'}},
+                    [ 'Content-Transfer-Encoding', $enc ]);
+               }
+       splice(@attach, 0, 0, $bodyattach);
 
        # Send attachments
        print MAIL "This is a multi-part message in MIME format.","\n";
@@ -350,3 +368,12 @@ if (open(CONF, $_[0])) {
 return %config;
 }
 
+# quoted_encode(text)
+# Encodes text to quoted-printable format
+sub quoted_encode
+{
+local $t = $_[0];
+$t =~ s/([=\177-\377])/sprintf("=%2.2X",ord($1))/ge;
+return $t;
+}
+