Skip to content

Commit

Permalink
[TASK] Update manipulation example of the receiver address
Browse files Browse the repository at this point in the history
  • Loading branch information
einpraegsam committed Jul 11, 2016
1 parent a7089bd commit c9d9076
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
14 changes: 8 additions & 6 deletions Classes/Domain/Service/SendMailService.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ class SendMailService
*
* @param MailMessage $message
* @param array $email
* @param SendMailServicePowermail $originalService
* @param SendMailServicePowermail $sendMailService
*/
public function manipulateMail($message, &$email, SendMailServicePowermail $originalService)
public function manipulateMail($message, &$email, SendMailServicePowermail $sendMailService)
{
// overwrite the receiver in the email array to have it saved correctly!
$email['receiverName'] = 'John Mega';
$email['receiverEmail'] = 'john@mega.com';
// change receiver name and email for a defined senderemail (as an example)
if ($sendMailService->getMail()->getSenderMail() === 'manipulatereceiver@powermailextended.org') {
$email['receiverName'] = 'in2code.de';
$email['receiverEmail'] = 'alex@in2code.de';

$message->setTo([$email['receiverEmail'] => $email['receiverName']]);
$message->setTo([$email['receiverEmail'] => $email['receiverName']]);
}
}
}
14 changes: 7 additions & 7 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
//);

// Change receiver mail
//$signalSlotDispatcher->connect(
// 'In2code\Powermail\Domain\Service\SendMailService',
// 'sendTemplateEmailBeforeSend',
// 'In2code\Powermailextended\Domain\Service\SendMailService',
// 'manipulateMail',
// false
//);
$signalSlotDispatcher->connect(
\In2code\Powermail\Domain\Service\SendMailService::class,
'sendTemplateEmailBeforeSend',
\In2code\Powermailextended\Domain\Service\SendMailService::class,
'manipulateMail',
false
);

0 comments on commit c9d9076

Please sign in to comment.