+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018 |
+ | Copyright CiviCRM LLC (c) 2004-2019 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2018
+ * @copyright CiviCRM LLC (c) 2004-2019
*
*/
$mailParams['message'] = CRM_Utils_Array::value('suggested_message', $params);
// Default "from email address" is default domain address.
- // This is normally overridden by one of the if statements below
list($_, $mailParams['email_from']) = CRM_Core_BAO_Domain::getNameAndEmail();
list($username, $mailParams['domain']) = explode('@', $mailParams['email_from']);
$mailParams['module'] = 'event';
}
elseif ($params['entity_table'] == 'civicrm_pcp') {
- $mailParams['email_from'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Email', $params['source_contact_id'],
- 'email', 'contact_id'
- );
+ if (Civi::settings()->get('allow_mail_from_logged_in_contact')) {
+ $mailParams['email_from'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Email', $params['source_contact_id'],
+ 'email', 'contact_id'
+ );
+ }
$urlPath = 'civicrm/pcp/info';
$mailParams['module'] = 'contribute';
}
$fromName = $email;
}
- // use contact email, CRM-4963
+ if (Civi::settings()->get('allow_mail_from_logged_in_contact')) {
+ // use contact email, CRM-4963
+ if (empty($values['email_from'])) {
+ $values['email_from'] = $email;
+ }
+ }
+
+ // If we have no "email_from" when we get to here, explicitly set it to the default domain email.
if (empty($values['email_from'])) {
- $values['email_from'] = $email;
+ list($domainFromName, $domainEmail) = CRM_Core_BAO_Domain::getNameAndEmail();
+ $values['email_from'] = $domainEmail;
+ $values['domain'] = $domainFromName;
}
$templateParams = array(