There is problem in file mailmime.inc with extending Mail_mime class from https://raw.githubusercontent.com/pear/Mail_Mime/master/Mail/mime.php - current class realization does not has the _htmlBody property, but this property is using in the get method.

public function &get($params = NULL, $filename = NULL, $skip_head = FALSE) {
    if (isset($this->_htmlbody)) {
      $this->_htmlbody = preg_replace_callback(
        array(
          ...
        ),
        array(&$this, 'attachRegex'),
        $this->_htmlbody
      );
    }
    return self::successful(
      parent::get($params, $filename, $skip_head)
    );
  }

The good news is that class has two interface functions - getHTMLBody and setHTMLBody, so we just need to use them instead of protected property (which now is called simply htmlBody).

 public function &get($params = NULL, $filename = NULL, $skip_head = FALSE) {
    $sBody = $this->getHTMLBody();
    if (!is_null($sBody)) {
      $this->setHTMLBody(
				preg_replace_callback(
					array(
						...
					),
					array(&$this, 'attachRegex'),
					$sBody
				)
      );
    }
    return self::successful(
      parent::get($params, $filename, $skip_head)
    );
  }

With this modification class should work with both old and new (git) version of Mail_Mime pear module.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

spuki’s picture

Issue summary: View changes
spuki’s picture

Title: Searching for inline file references and attaching local files does not working with current pear Mail_Mime module from git » Searching for inline file references and attaching local files are not working with current pear Mail_Mime module from git
spuki’s picture

spuki’s picture

Status: Active » Patch (to be ported)
salvis’s picture

Status: Patch (to be ported) » Needs review
FileSize
891 bytes

Thank you for tracking this down and posting your patch, spuki!

The breakage was introduced in this patch on GitHub two weeks ago.

You've introduced tabs which are not allowed by the https://www.drupal.org/coding-standards#indenting .

Also, changing the indent level of the regexes makes them appear changed when they aren't. I want to minimize changes and not break history unnecessarily. So here's my take of the patch.

(Please set Status to NR when you upload a patch so that the testbot can check it.)


I'm assuming you're installing Mail MIME right now — would you help me to update the installation instructions on the front page, please?
See #2526362: Update installation instructions on the front page.

salvis’s picture

Is the patch in #5 working?

spuki’s picture

Yes, it's working. What shall I do?

salvis’s picture

Set Status to RTBC. :-)

spuki’s picture

Status: Needs review » Reviewed & tested by the community

  • salvis committed 544f713 on 7.x-2.x
    Issue #2525864 by spuki, salvis: Searching for inline file references...
salvis’s picture

Status: Reviewed & tested by the community » Fixed

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.