Index: listhandler.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/listhandler/listhandler.module,v
retrieving revision 1.75.2.3
diff -r1.75.2.3 listhandler.module
76a77,81
>   $form['listhandler_attachments_as_link'] = array(
>     '#type' => 'checkbox',
>     '#title' => t('Attachments as link'),
>     '#default_value' => variable_get('listhandler_attachments_as_link', 0),
>     '#description' => t('Send attachments as links instead of MIME attachments. It affects only mails generated by forum posts.'));
131a137
>   variable_set('listhandler_attachments_as_link', $form_values['listhandler_attachments_as_link']);
214a221
>   $mid=array();
271,272c278,279
<     $mid = "References: ". $result->msgid ."\n";
<     $mid .= "In-Reply-To: ". $result->msgid ."\n";
---
>     $mid['References'] = $result->msgid;
>     $mid['In-Reply-To'] = $result->msgid;
282c289
<     $mid .= "Message-Id: ". $msgid ."\n";
---
>     $mid['Message-Id'] = $msgid;
296,299c303,323
< 
<     // OLD  $err = user_mail($address, $subject, $body, "From: ". $edit["name"] ." <". $edit["mail"] .">\n". $mid);
< 
<     $ok = drupal_mail($mid, $address, $subject, $body, $edit["mail"]);
---
>     $fragment = NULL;
>     $lfiles = false;
>     if ($edit['cid']) {
>       $fragment = "comment-" . $edit['cid'];
>       //attachment comments are already created
>       if (function_exists('_comment_upload_load_files')) {
>         $lfiles = _comment_upload_load_files($edit['cid']);
>       }
>     } 
>     else {
>       $lfiles = $edit['files'];
>     }
>     if ($lfiles) {
>       if (variable_get('listhandler_attachments_as_link', 0)) {
>         $body .= _listhandler_mail_links($lfiles, $edit['nid']);
>       }
>       else {
>         $body = _listhandler_mail_attachments($body, $lfiles, $mid);
>       }
>     }
>     $ok = drupal_mail('listhandler-mail', $address, $subject, $body, $edit["mail"], $mid);
471a496,543
> /**
>  * Convert upload files into links
>  */
> function _listhandler_mail_links($lfiles, $nid) {
>   $body = '';
>   $attachments = '';
>   foreach ($lfiles as $key => $ufile) {
>     $ufile = (object) $ufile;
>     $href = file_create_url((strpos($ufile->fid, 'upload') === FALSE ? $ufile->filepath : file_create_filename($ufile->filename, file_create_path())));
>     $href = str_replace(' ', '%20', $href);
>     $text = $ufile->description ? $ufile->description : $ufile->filename ;
>     $attachments .= "\n\n"." [". $text ."]:\n". $href;
>   }
>   if (!empty($attachments)) {
>     $url = url('node/'. $nid, NULL, $fragment, TRUE);
>     $body .= "\n\n". t('File attachments') .":";
>     $body .= $attachments;
>     $body .= "\n----------\n". t("Original attachments can be found at:\n!u", array('!u' => $url));
>   }
>   return $body;
> }
> 
> /**
>  * Convert upload files into mail attachments
>  */
> function _listhandler_mail_attachments($body, $files, &$mid) {
>   $trenner  = md5(uniqid(time()));
>   $mid['Content-Type'] = "multipart/mixed; boundary=$trenner";
>   $message  = "\n--$trenner\n";
>   $message .= "Content-Type: text/plain; charset=UTF-8; format=flowed;"."\n\n"; // sets the mime type
>   $message .= $body ."\n";
>   $message .= "\n\n";
>   foreach ($files as $key => $file) {
>     $file = (object) $file;
>     if ($file->filename) {
>       $file->filepath = str_replace("\\", "\\\\", $file->filepath);
>       $message  .= "--$trenner"."\n";
>       $message  .= "Content-Type:$file->filemime;\n\tname=$file->filename\n";
>       $message  .= "Content-Transfer-Encoding: base64\n";
>       $message  .= "Content-Disposition: attachment;\n\tfilename=$file->filename\n\n";
>       $filedata  = fread(fopen($file->filepath, "rb"), $file->filesize);
>       $message  .= chunk_split(base64_encode($filedata));
>       $message  .= "\n\n";
>     }
>   }
>   $message .= "--$trenner--";
>   return $message;
> }
Index: listhandler.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/listhandler/listhandler.install,v
retrieving revision 1.2.2.2
diff -r1.2.2.2 listhandler.install
45a46
>   variable_del('listhandler_attachments_as_link');
