Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Respect MailboxHeader 'To' possibly set by hook 'mailHeadersHook' #113

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions Classes/Dmailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -957,10 +957,11 @@ public function setContent(&$mailer)
/**
* Send of the email using php mail function.
*
* @param string/array $recipient The recipient array. array($name => $mail)
* @param array $recipRow Recipient's data array
* @param string|array $recipient The recipient array. array($name => $mail)
* @param array $recipRow Recipient's data array
*
* @return void
* @return void
* @throws \Swift_RfcComplianceException
*/
public function sendTheMail($recipient, $recipRow = null)
{
Expand All @@ -985,7 +986,7 @@ public function sendTheMail($recipient, $recipRow = null)
if ($this->organisation) {
$header->addTextHeader('Organization', $this->organisation);
}

// Hook to edit or add the mail headers
if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/direct_mail']['res/scripts/class.dmailer.php']['mailHeadersHook'])) {
$mailHeadersHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/direct_mail']['res/scripts/class.dmailer.php']['mailHeadersHook'];
Expand All @@ -1005,8 +1006,22 @@ public function sendTheMail($recipient, $recipRow = null)
$mailer->setReturnPath($this->dmailer['sys_dmail_rec']['return_path']);
}

// set the recipient
$mailer->setTo($recipient);
/**
* Set the recipients
*/
$to = $header->get('To');

if ($to instanceof \Swift_Mime_Headers_MailboxHeader
&& count($to->getAddresses()) > 0
&& is_array($recipient)
){
$to->setNameAddresses(
array_merge($to->getNameAddresses(), $recipient)
);
}
else {
$mailer->setTo($recipient);
}

// TODO: setContent should set the images (includeMedia) or add attachment
$this->setContent($mailer);
Expand Down