Use mail.php send mail but no subject.
-
Hello
I has use follow script to get new pppoe ip address.#!/bin/sh # 設定 PPPoE 介面名稱 (請確認 pfSense 上的名稱,可能是 pppoe0) PPPOE_IF="pppoe0" # 設定紀錄檔 IP_FILE="/root/current_pppoe_ip.txt" LOG_FILE="/root/ip_change.log" # 取得 PPPoE 的外部 IP CURRENT_IP=$(ifconfig $PPPOE_IF | grep 'inet ' | awk '{print $2}') # 確保有抓到 IP,否則跳出 if [ -z "$CURRENT_IP" ]; then echo "$(date) - Failed to get PPPoE IP" >> "$LOG_FILE" exit 1 fi # 如果檔案不存在,則建立它 if [ ! -f "$IP_FILE" ]; then echo "$CURRENT_IP" > "$IP_FILE" fi # 讀取上次的 IP LAST_IP=$(cat "$IP_FILE") # 檢查 IP 是否變更 if [ "$CURRENT_IP" != "$LAST_IP" ]; then # 記錄變更 echo "$(date) - IP changed from $LAST_IP to $CURRENT_IP" >> "$LOG_FILE" # 使用 pfSense 設定的通知 Email 發送通知 echo "New PPPoE IP: $CURRENT_IP (Previous: $LAST_IP)" | /usr/local/bin/mail.php -s "pfSense PPPoE IP Change Alert" # 更新紀錄檔 echo "$CURRENT_IP" > "$IP_FILE" fi
I use follow script to send mail to my email.
echo "New PPPoE IP: $CURRENT_IP (Previous: $LAST_IP)" | /usr/local/bin/mail.php -s "pfSense PPPoE IP Change Alert"
But I got mail have no subject.Have any error?
-
@akong77 said in Use mail.php send mail but no subject.:
But I got mail have no subject.Have any error?
The PHP manual for getopt states:
"Note: Optional values do not accept " " (space) as a separator."
And in the code "getopt("s::");" means '-s' is an optional value and there can't be a space between '-s' and "pfSense PPPoE IP Change Alert":
/usr/local/bin/mail.php -s"pfSense PPPoE IP Change Alert"
-
@patient0
Ohh.
I got it.Thanks a lot.
Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.