Update 2025-04-13_16:14:16

This commit is contained in:
root@6core
2025-04-13 16:14:17 +02:00
commit 535c2a093d
6 changed files with 474 additions and 0 deletions

47
sendmail_test.sh Executable file
View File

@ -0,0 +1,47 @@
#!/bin/bash
# Script Name: sendmail_test.sh
# Version: 02
# Description: This script sends a test email using sendmail. The recipient's email address is the first argument.
# Check if an argument (email address) is provided
if [ -z "$1" ]; then
TO="root"
else
TO="$1"
fi
# Email details
SUBJECT="Postfix Test"
FROM="noreply@$(hostname)"
BODY="This is the email body!"
# Function to send email
send_email() {
if ! command -v sendmail &> /dev/null; then
echo "Sendmail is not installed or configured. Please ensure sendmail is installed and properly set up." >&2
exit 1
fi
sendmail -t <<EOF
To: $TO
Subject: $SUBJECT
From: $FROM
$BODY
EOF
}
# Function to log messages
log_message() {
MESSAGE=$1
echo "$(date '+%Y-%m-%d %H:%M:%S') - $MESSAGE"
}
# Send email and log the result
log_message "Starting email send process."
if send_email; then
log_message "Email sent successfully to $TO."
else
log_message "Failed to send email to $TO."
fi