Send email email with no attachments
authorJamie Cameron <jcameron@webmin.com>
Sat, 4 Jul 2009 23:48:23 +0000 (23:48 +0000)
committerJamie Cameron <jcameron@webmin.com>
Sat, 4 Jul 2009 23:48:23 +0000 (23:48 +0000)
mailboxes/boxes-lib.pl

index d9826d5..553273a 100644 (file)
@@ -639,10 +639,16 @@ else {
        else {
                $body = $_[0]->{'body'};
                }
-       $_[0]->{'attach'} = [ { 'type' => lc($type),
-                               'idx' => 0,
-                               'parent' => $_[1],
-                               'data' => $body } ];
+       if ($body =~ /\S/) {
+               $_[0]->{'attach'} = [ { 'type' => lc($type),
+                                       'idx' => 0,
+                                       'parent' => $_[1],
+                                       'data' => $body } ];
+               }
+       else {
+               # Body is completely empty
+               $_[0]->{'attach'} = [ ];
+               }
        }
 delete($_[0]->{'body'}) if (!$_[2]);
 }
@@ -996,6 +1002,12 @@ if (defined($_[0]->{'body'})) {
        (print MAIL $_[0]->{'body'}) || &error("Write failed : $!");
        $lnum += ($_[0]->{'body'} =~ tr/\n/\n/);
        }
+elsif (!@{$_[0]->{'attach'}}) {
+       # No content, so just send empty email
+       print MAIL "Content-Type: text/plain",$eol;
+       print MAIL $eol;
+       $lnum += 2;
+       }
 elsif (!$_[2] || $ftype !~ /text\/plain/i ||
        $fenc =~ /quoted-printable|base64/) {
        # Sending MIME-encoded email