Skip to content
This repository was archived by the owner on May 7, 2023. It is now read-only.

Add Cc and Bcc to the recipients argument of Mail::send() #16

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
15 changes: 14 additions & 1 deletion lib/Foomo/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,22 @@ public function sendMail($to, $subject, $plaintext = '', $html = '', $headers =
if (!isset($headers['Return-Path']) && !empty($headers['From'])) {
$hdrs['Return-Path'] = $headers['From'];
}
foreach ($headers as $headerName => $headerValue) {

foreach($headers as $headerName => $headerValue) {
$hdrs[$headerName] = $headerValue;

/*
* see http://pear.php.net/manual/en/package.mail.mail.send.php:
* Note by: [email protected], 2007-07-08 05:13 UTC
* In order to send e-mail to cc or bcc with smtp you have to list the cc e-mail address both as a
* recipient (which decides where the e-mail is sent) and in the cc header, which tells the mail
* client how to display it.
*/
if (($headerName == 'Cc' || $headerName == 'Bcc') && !empty($headerValue)) {
$to .= ',' . $headerValue;
}
}

if (!empty($plaintext) && !empty($html)) {
// multipart
$mime = new \Mail_mime(PHP_EOL);
Expand Down