Permalink
Browse files

Stripping - from default Message-ID header.

This Fixes issues where certiain spamassassin rules would
flag EmailComponent messages as spam due to too many - in the messageID.
Fixes #2019
  • Loading branch information...
1 parent f57f730 commit c2104a3613ed5a991822958ec407a99f3abc2ee0 @markstory markstory committed Sep 24, 2011
@@ -589,7 +589,7 @@ function _createHeader() {
if ($this->messageId !== false) {
if ($this->messageId === true) {
- $headers['Message-ID'] = '<' . String::uuid() . '@' . env('HTTP_HOST') . '>';
+ $headers['Message-ID'] = '<' . str_replace('-', '', String::uuid()) . '@' . env('HTTP_HOST') . '>';
@ADmad

ADmad Sep 24, 2011

Member

When sending mails through shell/CLI env('HTTP_HOST') will be empty, so we should probably fix that too.

@markstory

markstory Sep 25, 2011

Owner

Indeed, that's something we should do in 2.0 for sure. I don't really know what we could use as a default domain though.

@ADmad

ADmad Sep 25, 2011

Member

I see no better option than having a property in the CakeEmail class for domain name and fallback to env('HTTP_HOST') if that property is empty. Plus throw an exception if both return empty value.

@rodrigorm

rodrigorm Sep 26, 2011

Contributor

When I send email through CLI I use:
HTTP_HOST=example.com cake

} else {
$headers['Message-ID'] = $this->messageId;
}
@@ -1211,7 +1211,7 @@ function testMessageId() {
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
$result = $this->Controller->Session->read('Message.email.message');
- $this->assertPattern('/Message-ID: \<[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}@' . env('HTTP_HOST') . '\>\n/', $result);
+ $this->assertPattern('/Message-ID: \<[a-f0-9]{32}@' . env('HTTP_HOST') . '\>\n/', $result);
$this->Controller->EmailTest->messageId = '<22091985.998877@localhost>';

0 comments on commit c2104a3

Please sign in to comment.