Merge pull request #2147 from eileenmcnaughton/CRM-13901
[civicrm-core.git] / CRM / Utils / Mail.php
index 108786c9e5f3a78003508c50278b95e92c3b8cb9..e5e56acabb6f254e216be3262549f8b345fb55bd 100644 (file)
@@ -163,19 +163,21 @@ class CRM_Utils_Mail {
     $headers = &$msg->headers($headers);
 
     $to = array($params['toEmail']);
-
-    //get emails from headers, since these are
-    //combination of name and email addresses.
-    if (CRM_Utils_Array::value('Cc', $headers)) {
-      $to[] = CRM_Utils_Array::value('Cc', $headers);
-    }
-    if (CRM_Utils_Array::value('Bcc', $headers)) {
-      $to[] = CRM_Utils_Array::value('Bcc', $headers);
-      unset($headers['Bcc']);
+    $result = null;
+    $mailer =& CRM_Core_Config::getMailer( );
+
+    // Mail_smtp and Mail_sendmail mailers require Bcc anc Cc emails
+    // be included in both $to and $headers['Cc', 'Bcc']
+    if (get_class($mailer) != "Mail_mail") {
+        //get emails from headers, since these are 
+        //combination of name and email addresses.
+        if ( CRM_Utils_Array::value( 'Cc', $headers ) ) {
+            $to[] = CRM_Utils_Array::value( 'Cc', $headers );
+        }
+        if ( CRM_Utils_Array::value( 'Bcc', $headers ) ) {
+            $to[] = CRM_Utils_Array::value( 'Bcc', $headers );
+        }
     }
-
-    $result = NULL;
-    $mailer = CRM_Core_Config::getMailer();
     if (is_object($mailer)) {
       CRM_Core_Error::ignoreException();
       $result = $mailer->send($to, $headers, $message);
@@ -206,7 +208,7 @@ class CRM_Utils_Mail {
     }
 
     $message .= '<li>' . ts('The FROM Email Address configured for this feature may not be a valid sender based on your email service provider rules.') . '</li>' . '</ul>' . '<p>' . ts('Check <a href="%1">this page</a> for more information.', array(
-      1 => CRM_Utils_System::docURL2('user/initial-set-up/email-system-configuration', TRUE))) . '</p>';
+      1 => CRM_Utils_System::docURL2('user/advanced-configuration/email-system-configuration', TRUE))) . '</p>';
 
     return $message;
   }