/** * Process that send notification e-mails * * @params int $contactId contact id * @params array $values associative array of name/value pair * @return void * @access public */ static function commonSendMail($contactID, &$values) { if (!$contactID || !$values) { return; } $template =& CRM_Core_Smarty::singleton(); $displayName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactID, 'display_name'); self::profileDisplay($values['id'], $values['values'], $template); $emailList = explode(',', $values['email']); $contactLink = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$contactID}", true, null, false); //get the default domain email address. require_once 'CRM/Core/BAO/Domain.php'; list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail(); if (!$domainEmailAddress || $domainEmailAddress == '*****@*****.**') { CRM_Core_Error::fatal(ts('The site administrator needs to enter a valid \'FROM Email Address\' in Administer CiviCRM » Configure » Domain Information. The email address used may need to be a valid mail account with your email service provider.')); } require_once 'CRM/Core/BAO/MessageTemplates.php'; foreach ($emailList as $emailTo) { // FIXME: take the below out of the foreach loop CRM_Core_BAO_MessageTemplates::sendTemplateParams(array('groupName' => 'msg_tpl_workflow_uf', 'valueName' => 'uf_notify', 'contactId' => $contactID, 'tplParams' => array('displayName' => $displayName, 'currentDate' => date('r'), 'contactLink' => $contactLink), 'from' => "{$domainEmailName} <{$domainEmailAddress}>", 'toEmail' => $emailTo)); } }
/** * Function to send the emails for Recurring Contribution Notication * * @param string $type txnType * @param int $contactID contact id for contributor * @param int $pageID contribution page id * @param object $recur object of recurring contribution table * * @return void * @access public * @static */ static function recurringNofify($type, $contactID, $pageID, $recur) { $value = array(); CRM_Core_DAO::commonRetrieveAll('CRM_Contribute_DAO_ContributionPage', 'id', $pageID, $value, array('title', 'is_email_receipt', 'receipt_from_name', 'receipt_from_email', 'cc_receipt', 'bcc_receipt')); if ($value[$pageID]['is_email_receipt']) { $receiptFrom = '"' . CRM_Utils_Array::value('receipt_from_name', $value[$pageID]) . '" <' . $value[$pageID]['receipt_from_email'] . '>'; require_once 'CRM/Contact/BAO/Contact/Location.php'; list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID, false); require_once 'CRM/Core/BAO/MessageTemplates.php'; list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplates::sendTemplateParams(array('groupName' => 'msg_tpl_workflow_contribution', 'valueName' => 'contribution_recurring_notify', 'contactId' => $contactID, 'tplParams' => array('recur_frequency_interval' => $recur->frequency_interval, 'recur_frequency_unit' => $recur->frequency_unit, 'recur_installments' => $recur->installments, 'recur_start_date' => $recur->start_date, 'recur_end_date' => $recur->end_date, 'recur_amount' => $recur->amount, 'recur_txnType' => $type, 'displayName' => $displayName, 'receipt_from_name' => $value[$pageID]['receipt_from_name'], 'receipt_from_email' => $value[$pageID]['receipt_from_email']), 'from' => $receiptFrom, 'toName' => $displayName, 'toEmail' => $email)); if ($sent) { CRM_Core_Error::debug_log_message('Success: mail sent for recurring notification.'); } else { CRM_Core_Error::debug_log_message('Failure: mail not sent for recurring notification.'); } } }