Small script to run on OpenPanel server to check if custom SMTP logins are working or if any errors when sending:
#!/bin/bash
CONFIGURED_EMAIL=$(opencli config get email)
DEV_MODE=$(opencli config get dev_mode)
[[ -z "$CONFIGURED_EMAIL" ]] && { echo "ERROR: Email address is not configured to receive notification. Please first run: 'opencli config update email example@yourdomain.com'. Exiting."; exit 1; }
[[ "$DEV_MODE" != "on" ]] && { echo "ERROR: dev_mode must be 'on' to actually check the admin error log. Please first run: 'opencli config update dev_mode on && service admin restart'. Exiting."; exit 1; }
echo -e "\nCURSTOM SMTP SETTINGS:"
grep '^mail_' /etc/openpanel/openpanel/conf/openpanel.config
# move existing log files
mv /var/log/openpanel/admin/error.log /var/log/openpanel/admin/error.log.OLD && touch /var/log/openpanel/admin/error.log
mv /var/log/openpanel/admin/notifications.log /var/log/openpanel/admin/notifications.log.OLD && touch /var/log/openpanel/admin/notifications.log
echo -e "\nEMAIL ERROR?"
# trigger notification to check log afterwards
opencli -x sentinel --startup 2>&1 | tail -n 10
echo -e "\nOPENADMIN RECEIVED IT:"
grep "/send_email" /var/log/openpanel/admin/access.log | tail -n 1
echo -e "\nERROR OCCURED:"
cat /var/log/openpanel/admin/error.log