Project:Contact attach
Version:5.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:oadaeh
Status:active

Issue Summary

Thank-you, thank-you for this module.

However, I had mime-mail turned on, and the attachment came out as junk on the end of the mail. Turned it off.... all is well.
It is more important to have attachments than MIME-mail, but I'd love both....

Thanks again!

kent

Comments

#1

Category:bug report» feature request
Assigned to:Anonymous» oadaeh

I'm not particularly fond of Mime Mail as it's not flexible some areas and is presumptuous in other areas. However, I will look to see if there is something I can do to work with the module, though it may be a while before I can get to this issue.

#2

Version:5.x-1.1» 5.x-1.x-dev

I spent some time looking at integrating Mime Mail with Mass Contact. As soon as I have a few free minutes, I'll take what I learned there and apply it here.

#3

I've integrated contact_attach with mimemail by adding the following function to contact_attach.module:

/*
  *   Mimemail exception routine:  mimemail interferes with sending of attachments via contact_attach
  *   Mimemail can be suppressed by using the code from drupal_mail_send() for contact_attach forms
  *  The code in the else condition is taken directly from mimemail's drupal_mail_wrapper()
  *   In order for this to work the weight for the contact_attach module has to be lower than the weight for mimemail
  */
if (!function_exists('drupal_mail_wrapper')) {

  function drupal_mail_wrapper(&$message) {
    if(substr($message['id'],0,14) == "contact_attach") {
      $mimeheaders = array();
      foreach ($message['headers'] as $name => $value) {
        $mimeheaders[] = $name .': '. mime_header_encode($value);
      }
      return mail(
        $message['to'],
        mime_header_encode($message['subject']),
        // Note: e-mail uses CRLF for line-endings, but PHP's API requires LF.
        // They will appear correctly in the actual e-mail that is sent.
        str_replace("\r", '', $message['body']),
        // For headers, PHP's API suggests that we use CRLF normally,
        // but some MTAs incorrecly replace LF with CRLF. See #234403.
        join("\n", $mimeheaders)
      );
    }
    else {
      $from = $message['from'];
      $to = $message['to'];
      $subject = $message['subject'];
      if ($format = variable_get('mimemail_format', FILTER_FORMAT_DEFAULT)) {
      $body = check_markup($message['body'], $format);
    }
    else {
      $body = $message['body'];
    }
    $headers = isset($message['headers']) ? $message['headers'] : array();
    $mailkey = isset($message['mailkey']) ? $message['mailkey'] : '';
    return mimemail($from, $to, $subject, $body, NULL, $headers, NULL, array(), $mailkey);

    }
  }
}

For this to work you need to set the weight of the contact_attach module to a value less than the weight for the mimemail module in the system table, so that this version of drupal_mail_wrapper gets loaded and not the mimemail one.

Note that this function works by overriding the mail send function before mimemail gets to.

#4

Thanks!!!!

nobody click here