|
|
@@ -13,19 +13,25 @@ sender="wyn3-14@shandan.one"
|
|
|
recipient="sms@voip.ms"
|
|
|
subject="$TO.$CODE.$FROM"
|
|
|
|
|
|
-store_to_db(){
|
|
|
- export MESSAGE FROM TO
|
|
|
- python3 <<'EOF'
|
|
|
+printf 'To:\r\nFrom:\r\nContent-Type:\r\n\r\n%s\r\n' "$MESSAGE" \
|
|
|
+ | reformail \
|
|
|
+ -I"To: $recipient" \
|
|
|
+ -I"From: $sender" \
|
|
|
+ -I"Subject: $subject" \
|
|
|
+ -I"Content-Type: text/plain" -d1 \
|
|
|
+ | sendmail -f "$sender" -t
|
|
|
+
|
|
|
+export MESSAGE FROM TO
|
|
|
+python3 <<'EOF'
|
|
|
import sqlite3
|
|
|
from os import environ as env
|
|
|
params = [ env.get(x) for x in ('FROM', 'TO', 'MESSAGE') ]
|
|
|
conn = sqlite3.connect('sms.db')
|
|
|
cursor = conn.cursor()
|
|
|
-cursor.execute(""" INSERT INTO outbox (sent, "from", "to", payload) VALUES (CURRENT_TIMESTAMP, '+1'||?, '+1'||?, ?) """, params)
|
|
|
+cursor.execute("""
|
|
|
+INSERT INTO outbox (sent, "from", "to", payload)
|
|
|
+VALUES (CURRENT_TIMESTAMP, '+1'||?, '+1'||?, ?)
|
|
|
+""", params)
|
|
|
conn.commit()
|
|
|
conn.close()
|
|
|
EOF
|
|
|
-}
|
|
|
-
|
|
|
-reformail -I"To: $recipient" -I"From: $sender" -I"Subject: $subject" -I"Content-Type: text/plain" -d1 < <(printf 'To:\r\nFrom:\r\nContent-Type:\r\n\r\n%s\r\n' "$MESSAGE") | sendmail -f "$sender" -t
|
|
|
-store_to_db
|