Details about "Use this server to handle my e-mails"

goodytwoshoes

Verified User
Joined
Jul 12, 2019
Messages
10
Hi all.

This is regarding the MX setting where you tell DirectAdmin to send all mail to the external MX record.

We have a user who has this setting auto-magically get enabled by itself without any action from us and with the user saying they don't enable it but its causing frustration "Use this server to handle my e-mails. If not, change the MX records and uncheck this option."
We need this setting to remain un selected because the user uses office 365 for their mail, and they have an addon domain on this account sending mails to them which has to relay to 365 but sends locally when this selection becomes enabled.

We understand the functionality around it and it works when its not enabled, but we need to address this concern for the customer.

Is there a way to audit who (which ip) enables it ?
Then we need to try and "watch" a configuration file if possible, where does this entry get written or how do we call its status to confirm its disabled ?
We would ideally like to have a cron run every morning that tells us if its become enabled and if possible, set it back to disabled via bash.

Is this possible to check the state via SSH, and to audit user actions somehow ? Or is this going to require the laborious task of manually checking every morning ?

Thanks
 

Attachments

  • Screenshot 2024-06-04 001046.png
    Screenshot 2024-06-04 001046.png
    3.9 KB · Views: 2
  • Screenshot 2024-06-04 001040.png
    Screenshot 2024-06-04 001040.png
    2.7 KB · Views: 2
Hello,

Is there a way to audit who (which ip) enables it ?

Check logs under /var/log/directadmin/ for possible clues

Then we need to try and "watch" a configuration file if possible, where does this entry get written or how do we call its status to confirm its disabled ?

Whenever the option is enabled, it causes a user domain to be added into the file /etc/virtual/domains
If you remove a domain from the file in CLI (SSH, cron), then it will be the same as if you uncheck the option in WebUI
 
ok this works a treat, thanks, we wrote a cron that checks the file for a string and removes the string and logs when found, sharing it here if anyone else needs to do this as well.

#!/bin/bash

# The string to search for and remove
search_string="exampledomain.com"

# The file to search within
file="/etc/virtual/domains"

# The log file to write the log entry
log_file="/root/exampledomain.com.txt"

# Check if the entry in the file exists
if [ ! -f "$file" ]; then
echo "The entry in the file $file does not exist."
exit 1
fi

# Search for the exact string in the file
if grep -q "^$search_string$" "$file"; then
# If the exact string is found, delete it using sed
sed -i "/^$search_string$/d" "$file"

# Get the current date and time
current_datetime=$(date '+%Y-%m-%d %H:%M:%S')

# Write a log entry
echo "$current_datetime: The string '$search_string' was found and removed from $file." >> "$log_file"
else
echo "The string '$search_string' was not found in $file."
fi
 
Back
Top