Skip to content

Commit

Permalink
add config flag to disable email sending #120
Browse files Browse the repository at this point in the history
  • Loading branch information
dantheta committed Oct 31, 2021
1 parent 0b19ab5 commit 9fc4f74
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/1.2/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -1752,7 +1752,7 @@ function result_callback($msg, $queue) {
# send email here

if (($contact['verified'] || $network_name == 'ORG') && $network_name != 'BBFC' && $age_limit == false && $hold == false) {
false && sendISPReport(
sendISPReport(
$mailname,
$data['reporter']['name'],
$data['reporter']['email'],
Expand Down
2 changes: 2 additions & 0 deletions api/1.2/libs/config.docker.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

$REQUEUE_EXCLUDE_SOURCES = array();

define('SEND_EMAIL', false);

#define('AWS_DYNAMODB_ACCESS_KEY', 'asdasd');
#define('AWS_DYNAMODB_SECRET_KEY', '');
#define('AWS_DYNAMODB_URL', 'http://localhost:8000');
Expand Down
17 changes: 17 additions & 0 deletions api/1.2/libs/email.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php

function sendISPReport($mailname, $name, $email, $network, $url, $message, $report_type, $category, $renderer) {
if (defined('SEND_EMAIL') && SEND_EMAIL == false) {
// disable email flag for debug/testing
return;
}
$msg = new PHPMailer();
if (FEATURE_EMAIL_TRACKING) {
$msg->setFrom($mailname . '@' . MAIL_DOMAIN, $name . ' via Blocked.org.uk');
Expand Down Expand Up @@ -37,6 +41,10 @@ function sendISPReport($mailname, $name, $email, $network, $url, $message, $repo
}

function sendISPReminder($row, $network, $url, $renderer) {
if (defined('SEND_EMAIL') && SEND_EMAIL == false) {
// disable email flag for debug/testing
return;
}
$msg = new PHPMailer();

if (FEATURE_EMAIL_TRACKING) {
Expand Down Expand Up @@ -97,6 +105,11 @@ function sendBBFCReport($mailname, $name, $email, $network, $original_network, $
// "nature_of_the_complaint" => $message
// );

if (defined('SEND_EMAIL') && SEND_EMAIL == false) {
// disable email flag for debug/testing
return;
}

$msg = new PHPMailer();
if (FEATURE_EMAIL_TRACKING) {
$msg->setFrom($mailname . '@' . MAIL_DOMAIN, $name . ' via Blocked.org.uk');
Expand Down Expand Up @@ -136,6 +149,10 @@ function sendBBFCReport($mailname, $name, $email, $network, $original_network, $
}

function sendUserVerification($email, $name, $token, $attempt, $renderer) {
if (defined('SEND_EMAIL') && SEND_EMAIL == false) {
// disable email flag for debug/testing
return;
}
$msg = new PHPMailer();
$msg->setFrom(SITE_EMAIL, SITE_NAME);
$msg->addAddress(
Expand Down

0 comments on commit 9fc4f74

Please sign in to comment.