I'm working on a newsletter solution with WireMailSMTP and this Newsletter Tutorial.
I only changed the lines 73 to 83 in newsletter.php, but there's a strange issue with the $subscribers array:
$testMode = isset($_POST['test_email']) ? true : false;
if ($testMode) {
$subscribers = wire('input')->post('test_email');
if (strpos($subscribers, ',') !== false) {
$subscribers = explode(',', $subscribers);
}
} else {
$subscribers = $pages->find('template=subscriber');
$subscribers = $subscribers->explode('email');
}
if (is_array($subscribers)) {
$subscribers = array_map('trim', $subscribers);
}
$mail = wireMail();
$mail->sendSingle(true)->to('test@domain.de')->bcc($subscribers);
$mail->from('xxx@domain.de');
$mail->subject($newsletter->title);
$mail->bodyHTML($html);
$numSent = $mail->send();
echo json_encode(count($subscribers));
$this->halt();
The email is sent to test@domain.de but not to bcc $subscribers.
Errorlog: PHP Notice: Unknown: Invalid mailbox list: <> (errflg=3) in Unknown on line 0
I'm grateful for any advice.
Greetings
Florian