Skip to content

Commit

Permalink
Merge pull request #2 from dashford/add-recipient-type
Browse files Browse the repository at this point in the history
Add type to recipient and use this in the message struct
  • Loading branch information
jlinn committed Oct 17, 2015
2 parents 3b8d9ed + 46a4f22 commit 424b2c8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Mandrill/Struct/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ public function setMetadata(array $metadata){
public function addRecipient(Recipient $recipient){
$this->to[] = array(
'email' => $recipient->email,
'name' => $recipient->name
'name' => $recipient->name,
'type' => $recipient->type
);
$this->merge_vars[] = array(
'rcpt' => $recipient->email,
Expand Down
13 changes: 11 additions & 2 deletions src/Mandrill/Struct/Recipient.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ class Recipient extends Struct{
*/
public $name;

/**
* @var string the recipient's header type i.e. 'to', 'cc', 'bcc'
*/
public $type = 'to';

/**
* @var array associative array of recipient-specific merge variables
*/
Expand All @@ -33,14 +38,18 @@ class Recipient extends Struct{
/**
* @param string $email the recipient's email address
* @param string $name the recipient's name
* @param string $type the recipient's header type i.e. 'to', 'cc', 'bcc'
*/
function __construct($email = NULL, $name = NULL){
function __construct($email = NULL, $name = NULL, $type = NULL){
if(!is_null($email)){
$this->email = $email;
}
if(!is_null($name)){
$this->name = $name;
}
if(!is_null($type)){
$this->type = $type;
}
}


Expand Down Expand Up @@ -105,4 +114,4 @@ public function setMetadata(array $metadata){
public function getMetadata(){
return $this->metadata;
}
}
}

0 comments on commit 424b2c8

Please sign in to comment.