Skip to content

Commit

Permalink
Stripping - from default Message-ID header.
Browse files Browse the repository at this point in the history
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
markstory committed Sep 24, 2011
1 parent f57f730 commit c2104a3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cake/libs/controller/components/email.php
Expand Up @@ -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') . '>';

This comment has been minimized.

Copy link
@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.

This comment has been minimized.

Copy link
@markstory

markstory Sep 25, 2011

Author Member

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.

This comment has been minimized.

Copy link
@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.

This comment has been minimized.

Copy link
@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;
}
Expand Down
2 changes: 1 addition & 1 deletion cake/tests/cases/libs/controller/components/email.test.php
Expand Up @@ -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>';

Expand Down

0 comments on commit c2104a3

Please sign in to comment.