Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#86 Notify admin when testing email if CIVICRM_MAIL_LOG_AND_SEND is set #12037

Merged
merged 2 commits into from
Apr 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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