Skip to content

Commit

Permalink
Implemented CC recipients
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyoushu committed Sep 1, 2014
1 parent 6eda4fe commit 14212fa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/nbproject/private/
/nbproject/
/nbproject/
/.idea
/vendor
/composer.lock
23 changes: 16 additions & 7 deletions SwiftMailer/MandrillTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ class MandrillTransport implements Swift_Transport {

protected $started = false;

/**
* @param Swift_Events_EventDispatcher $dispatcher
* @param type $apiKey
*/
/**
* @param Swift_Events_EventDispatcher $dispatcher
*/
public function __construct(Swift_Events_EventDispatcher $dispatcher) {
$this->dispatcher = $dispatcher;
}
Expand All @@ -48,6 +47,7 @@ public function setApiKey($apiKey){

/**
* @param Swift_Mime_Message $message
* @param null $failedRecipients
* @return int Number of messages sent
*/
public function send(Swift_Mime_Message $message, &$failedRecipients = NULL)
Expand Down Expand Up @@ -108,7 +108,8 @@ protected function getMandrillMessage(Swift_Mime_Message $message)

$fromAddresses = $message->getFrom();
$formEmails = array_keys($fromAddresses);
$toAddresses = $message->getTo();
$toAddresses = $message->getTo();
$ccAddresses = $message->getCc();
$to = array();
$attachments = array();

Expand All @@ -119,6 +120,14 @@ protected function getMandrillMessage(Swift_Mime_Message $message)
'type' => 'to'
);
}

foreach($ccAddresses as $ccEmail => $ccName){
$to[] = array(
'email' => $ccEmail,
'name' => $ccName,
'type' => 'cc'
);
}

foreach($message->getChildren() as $child){
if($child instanceof \Swift_Attachment){
Expand All @@ -129,7 +138,7 @@ protected function getMandrillMessage(Swift_Mime_Message $message)
);
}
}

$mandrillMessage = array(
'html' => $message->getBody(),
'subject' => $message->getSubject(),
Expand All @@ -148,7 +157,7 @@ protected function getMandrillMessage(Swift_Mime_Message $message)
/**
* @param Swift_Mime_Message $message
* @param string $mime_type
* @return Swift_Mime_MimePart
* @return null|\Swift_Mime_MimeEntity
*/
protected function getMIMEPart(Swift_Mime_Message $message, $mime_type) {
$html_part = NULL;
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"require": {
"php": ">=5.3.3",
"symfony/framework-bundle": ">=2.3",
"mandrill/mandrill": "1.0.52"
"mandrill/mandrill": "1.0.52",
"swiftmailer/swiftmailer": "5.2.1"
},
"autoload": {
"psr-0": { "Accord\\MandrillSwiftMailerBundle": "" }
Expand Down

0 comments on commit 14212fa

Please sign in to comment.