public static function getReceiptFrom($activityID) {
$name = $address = NULL;
- if (!empty($activityID)) {
+ if (!empty($activityID) && (Civi::settings()->get('allow_mail_from_logged_in_contact'))) {
+ // This breaks SPF/DMARC if email is sent from an email address that the server is not authorised to send from.
+ // so we can disable this behaviour with the "allow_mail_from_logged_in_contact" setting.
// There is always a 'Added by' contact for a activity,
// so we can safely use ActivityContact.Getvalue API
$sourceContactId = civicrm_api3('ActivityContact', 'getvalue', array(
if (!empty($domain['domain_email'])) {
return array($domain['name'], $domain['domain_email']);
}
- $userID = CRM_Core_Session::singleton()->getLoggedInContactID();
$userName = '';
$userEmail = '';
+
+ if (!Civi::settings()->get('allow_mail_from_logged_in_contact')) {
+ return array($userName, $userEmail);
+ }
+
+ $userID = CRM_Core_Session::singleton()->getLoggedInContactID();
if (!empty($userID)) {
list($userName, $userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($userID);
}