Skip to content

Commit

Permalink
Merge pull request #12037 from mattwire/mail_constants
Browse files Browse the repository at this point in the history
dev/core#86 Notify admin when testing email if CIVICRM_MAIL_LOG_AND_SEND is set
  • Loading branch information
monishdeb authored Apr 29, 2018
2 parents d94ee64 + 2ddaef9 commit 6bba6d7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
12 changes: 7 additions & 5 deletions CRM/Admin/Form/Setting/Smtp.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,9 @@ public function postProcess() {

$to = '"' . $toDisplayName . '"' . "<$toEmail>";
$from = '"' . $domainEmailName . '" <' . $domainEmailAddress . '>';
$testMailStatusMsg = ts('Sending test email. FROM: %1 TO: %2.<br />', array(
1 => $domainEmailAddress,
2 => $toEmail,
));
$testMailStatusMsg = ts('Sending test email') . ':<br />'
. ts('From: %1', array(1 => $domainEmailAddress)) . '<br />'
. ts('To: %1', array(1 => $toEmail)) . '<br />';

$params = array();
if ($formValues['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_SMTP) {
Expand Down Expand Up @@ -170,7 +169,10 @@ public function postProcess() {
$errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
$result = $mailer->send($toEmail, $headers, $message);
unset($errorScope);
if (defined('CIVICRM_MAIL_LOG')) {
if (defined('CIVICRM_MAIL_LOG') && defined('CIVICRM_MAIL_LOG_AND_SEND')) {
$testMailStatusMsg .= '<br />' . ts('You have defined CIVICRM_MAIL_LOG_AND_SEND - mail will be logged.') . '<br /><br />';
}
if (defined('CIVICRM_MAIL_LOG') && !defined('CIVICRM_MAIL_LOG_AND_SEND')) {
CRM_Core_Session::setStatus($testMailStatusMsg . ts('You have defined CIVICRM_MAIL_LOG - no mail will be sent. Your %1 settings have not been tested.', array(1 => strtoupper($mailerName))), ts("Mail not sent"), "warning");
}
elseif (!is_a($result, 'PEAR_Error')) {
Expand Down
7 changes: 7 additions & 0 deletions templates/CRM/common/civicrm.settings.php.template
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,13 @@ if (!defined('CIVICRM_MAIL_SMARTY')) {
// define( 'CIVICRM_MAIL_LOG', '%%templateCompileDir%%/mail.log');
// }

/**
* This setting will only work if CIVICRM_MAIL_LOG is defined. Mail will be logged and then sent.
*/
//if (!defined('CIVICRM_MAIL_LOG_AND_SEND')) {
// define( 'CIVICRM_MAIL_LOG_AND_SEND', 1);
//}


if (!defined('CIVICRM_DOMAIN_ID')) {
define( 'CIVICRM_DOMAIN_ID', 1);
Expand Down

0 comments on commit 6bba6d7

Please sign in to comment.