Skip to content

Commit

Permalink
Read send_email from config file and act appropriately
Browse files Browse the repository at this point in the history
  • Loading branch information
jrha committed Aug 26, 2020
1 parent 249809d commit 1329fec
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/Gocdb_Services/NotificationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ private function get_webPortalURL() {
}


/**
* Return whether send_email is enabled in the config file
*/
private function get_config_send_email() {
$localInfoXML = simplexml_load_file(__DIR__ . "/../../config/local_info.xml");
return strtolower($localInfoXML->local_info->send_email) === 'true';
}


private function mock_mail($to, $subject, $message, $additional_headers = "", $additional_parameters = "") {
echo "<!--\n";
echo "Sending mail disabled, but would have sent:\n";
Expand Down Expand Up @@ -165,7 +174,7 @@ private function send_email($role_requested, $requesting_user, $entity_name, $ap
$email = $approving_user->getEmail();
$headers = "From: [email protected]";

if (True) {
if (get_config_send_email()) {
mail($email, $subject, $body, $headers);
} else {
mock_mail($email, $subject, $body, $headers);
Expand Down

0 comments on commit 1329fec

Please sign in to comment.