function attachsource($source, $name, $mimetype = 'autodetect', $disposition = 'attachment', $encoding = 'base64')
 {
     $ret = false;
     if (is_string($source) && $source != "") {
         if (is_string($name)) {
             $name = FUNC::str_clear($name);
             $name = trim($name);
             if ($name != "") {
                 $ret = true;
                 $mime = 'application/octet-stream';
                 if (is_string($mimetype)) {
                     $mimetype = FUNC::str_clear($mimetype, array(' '));
                     $mimetype = trim(strtolower($mimetype));
                     $mime = $mimetype == "autodetect" || $mimetype == "" ? FUNC::mimetype($name) : $mimetype;
                 }
                 $disp = 'attachment';
                 if (is_string($disposition)) {
                     $disposition = FUNC::str_clear($disposition, array(' '));
                     $disposition = trim(strtolower($disposition));
                     if ($disposition == "attachment" || $disposition == "inline") {
                         $disp = $disposition;
                     } else {
                         throw new Exception('Invalid disposition value, on class SMTP::attachsource()', 512);
                     }
                 } else {
                     throw new Exception('Invalid disposition type value, on class SMTP::attachsource()', 512);
                 }
                 $encode = 'base64';
                 if (is_string($encoding)) {
                     $encoding = FUNC::str_clear($encoding, array(' '));
                     $encoding = trim(strtolower($encoding));
                     if ($encoding != "" && isset($this->_arrenc[$encoding])) {
                         $encode = $encoding;
                     } else {
                         throw new Exception('Invalid encoding value, on class SMTP::attachsource()', 512);
                     }
                 } else {
                     throw new Exception('Invalid encoding type value, on class SMTP::attachsource()', 512);
                 }
                 $this->_attach[] = array('name' => $name, 'mime' => $mime, 'disp' => $disp, 'encode' => $encode, 'source' => $source);
             } else {
                 throw new Exception('Invalid name value, on class SMTP::attachsource()', 512);
             }
         } else {
             throw new Exception('Invalid name type value, on class SMTP::attachsource()', 512);
         }
     } else {
         throw new Exception('Invalid source value, on class SMTP::attachsource()', 512);
     }
     return $ret;
 }