Skip to content

Commit e37ec74

Browse files
author
Jared Hancock
committed
mailer: Pick content_ids that Mail_Mime will enjoy
1 parent c0f49c6 commit e37ec74

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

include/class.mailer.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,14 @@ function send($to, $subject, $message, $options=null) {
162162
$isHtml = false;
163163
}
164164

165-
$domain = 'local';
166165
if ($isHtml && $cfg && $cfg->isHtmlThreadEnabled()) {
167-
// TODO: Lookup helpdesk domain
168-
$domain = substr(md5($ost->getConfig()->getURL()), -12);
166+
// Pick a domain compatible with pear Mail_Mime
167+
$matches = array();
168+
if (preg_match('#(@[0-9a-zA-Z\-\.]+)#', $this->getFromAddress(), $matches)) {
169+
$domain = $matches[1];
170+
} else {
171+
$domain = '@localhost';
172+
}
169173
// Format content-ids with the domain, and add the inline images
170174
// to the email attachment list
171175
$self = $this;
@@ -175,10 +179,10 @@ function($match) use ($domain, $mime, $self) {
175179
return $match[0];
176180
$mime->addHTMLImage($file->getData(),
177181
$file->getType(), $file->getName(), false,
178-
$match[1].'@'.$domain);
182+
$match[1].$domain);
179183
// Don't re-attach the image below
180184
unset($self->attachments[$file->getId()]);
181-
return $match[0].'@'.$domain;
185+
return $match[0].$domain;
182186
}, $message);
183187
// Add an HTML body
184188
$mime->setHTMLBody($message);

0 commit comments

Comments
 (0)