public function EmailMerge::sendMail in Forena Reports 8
File
- src/
FrxPlugin/ Document/ EmailMerge.php, line 103
Class
- EmailMerge
- Provides MS Excel Exports
Namespace
Drupal\forena\FrxPlugin\DocumentCode
public function sendMail($email, $max, $subject = '', $body = '') {
$i = 0;
if (!$max) {
$max = count($this->emails);
}
foreach ($this->emails as $doc) {
$i++;
$to = !empty($email) ? $email : $doc['to'];
$from = $doc['from'];
// Replace body
if (!empty($body)) {
$doc['parms']['body'] = $body;
}
// Replace subject
if (!empty($subject)) {
$doc['parms']['subject'] = $subject;
}
// If we're in test mode foce unset of header.
if ($email) {
// Remove bcc and cc
unset($doc['parms']['headers']);
}
/** @var MailManagerInterface $mailManager */
$mailManager = \Drupal::service('plugin.manager.mail');
if ($i <= $max) {
$mailManager
->mail('forena', 'mailmerge', $to, \Drupal::languageManager()
->getLanguages(), $doc['parms'], $from, TRUE);
}
}
}