-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3fec786
commit 7edcb44
Showing
1 changed file
with
22 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,9 @@ | |
from email.mime.text import MIMEText | ||
from email.mime.multipart import MIMEMultipart | ||
|
||
# System settings | ||
sysopEmails = ["[email protected]", ] # list of authorized emails for sysop control | ||
|
||
# SMTP settings (required for outbound email/sms) | ||
SMTP_SERVER = "smtp.gmail.com" # Replace with your SMTP server | ||
SMTP_PORT = 587 # 587 SMTP over TLS/STARTTLS, 25 legacy SMTP | ||
|
@@ -25,13 +28,16 @@ | |
IMAP_PASSWORD = SMTP_PASSWORD # IMAP password usually same as SMTP | ||
IMAP_FOLDER = "inbox" # IMAP folder to monitor for new messages | ||
|
||
# System variables // Do not edit | ||
trap_list_smtp = ("email", "setmail", "sms", "setsms") | ||
smtpThrottle = {} | ||
|
||
if enableImap: | ||
# Import IMAP library | ||
import imaplib | ||
import email | ||
|
||
|
||
# Send email | ||
def send_email(to_email, message): | ||
global smtpThrottle | ||
|
@@ -65,7 +71,7 @@ def send_email(to_email, message): | |
return False | ||
return True | ||
|
||
def check_email(nodeID): | ||
def check_email(nodeID, sysop=False): | ||
if not enableImap: | ||
return | ||
|
||
|
@@ -86,12 +92,21 @@ def check_email(nodeID): | |
email_subject = email_message['subject'] | ||
email_body = "" | ||
|
||
# Check if email is whitelisted by a particpant in the mesh | ||
for address in sms_db[nodeID]: | ||
if address in email_from: | ||
email_body = email_message.get_payload() | ||
logger.info("System: Email received from: " + email_from[:-6] + " for " + nodeID) | ||
return email_body.strip() | ||
if not sysop: | ||
# Check if email is whitelisted by particpant in the mesh | ||
for address in sms_db[nodeID]: | ||
if address in email_from: | ||
email_body = email_message.get_payload() | ||
logger.info("System: Email received from: " + email_from[:-6] + " for " + nodeID) | ||
return email_body.strip() | ||
else: | ||
# Check if email is from sysop | ||
for address in sysopEmails: | ||
if address in email_from: | ||
email_body = email_message.get_payload() | ||
logger.info("System: SysOp Email received from: " + email_from[:-6] + " for sysop") | ||
return email_body.strip() | ||
|
||
except Exception as e: | ||
logger.warning("System: Failed to check email: " + str(e)) | ||
return False | ||
|