Skip to content
This repository has been archived by the owner on Apr 10, 2022. It is now read-only.

Commit

Permalink
Merge pull request #14 from evaldemar/master
Browse files Browse the repository at this point in the history
add support headers in mail message
  • Loading branch information
ofat authored Dec 6, 2016
2 parents 59b3eb5 + 6ad7765 commit 2a9f110
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,4 +347,11 @@ public function getHeaders()
//todo: make headers for debug
return '';
}

public function setHeader($key, $value)
{
$this->getSesMessage()->addTextHeader($key, $value);

return $this;
}
}
18 changes: 18 additions & 0 deletions libs/SimpleEmailServiceMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ final class SimpleEmailServiceMessage {
public $subject, $messagetext, $messagehtml;
public $subjectCharset, $messageTextCharset, $messageHtmlCharset;
public $attachments = array();
public $headers = [];

function __construct() {
$this->to = array();
Expand All @@ -35,6 +36,8 @@ function __construct() {
$this->subjectCharset = null;
$this->messageTextCharset = null;
$this->messageHtmlCharset = null;

$this->headers = [];
}


Expand Down Expand Up @@ -79,6 +82,14 @@ function addReplyTo($replyto) {
}
}

function addTextHeader($key, $value) {
if (!$key) {
return;
}

$this->headers[] = [$key => $value];
}

function setFrom($from) {
$this->from = $from;
}
Expand Down Expand Up @@ -198,6 +209,13 @@ function getRawMessage()
$raw_message .= 'Subject: =?' . $this->subjectCharset . '?B?' . base64_encode($this->subject) . '?=' . "\n";
}
}

foreach ($this->headers as &$header) {
foreach ($header as $key => $value) {
$raw_message .= $key . ': ' . $value . "\n";
}
}

$raw_message .= 'MIME-Version: 1.0' . "\n";
$raw_message .= 'Content-type: Multipart/Mixed; boundary="' . $boundary . '"' . "\n";
$raw_message .= "\n--{$boundary}\n";
Expand Down

0 comments on commit 2a9f110

Please sign in to comment.