|
@@ -1,37 +1,37 @@
|
|
|
#!/bin/bash
|
|
#!/bin/bash
|
|
|
|
|
+#
|
|
|
|
|
+# Requires: maildrop, postfix, python3
|
|
|
|
|
+#
|
|
|
|
|
+
|
|
|
|
|
+set -euo pipefail
|
|
|
|
|
+
|
|
|
FROM="$1"
|
|
FROM="$1"
|
|
|
TO="$2"
|
|
TO="$2"
|
|
|
MESSAGE="$3"
|
|
MESSAGE="$3"
|
|
|
-CODE="25203"
|
|
|
|
|
|
|
|
|
|
-if [ -z "$TO" ] || [ -z "$FROM" ] || [ -z "$MESSAGE" ]
|
|
|
|
|
-then
|
|
|
|
|
- exit 1
|
|
|
|
|
-fi
|
|
|
|
|
|
|
+. .env
|
|
|
|
|
|
|
|
-sender="wyn3-14@shandan.one"
|
|
|
|
|
recipient="sms@voip.ms"
|
|
recipient="sms@voip.ms"
|
|
|
subject="$TO.$CODE.$FROM"
|
|
subject="$TO.$CODE.$FROM"
|
|
|
|
|
|
|
|
printf 'To:\r\nFrom:\r\nContent-Type:\r\n\r\n%s\r\n' "$MESSAGE" \
|
|
printf 'To:\r\nFrom:\r\nContent-Type:\r\n\r\n%s\r\n' "$MESSAGE" \
|
|
|
| reformail \
|
|
| reformail \
|
|
|
-I"To: $recipient" \
|
|
-I"To: $recipient" \
|
|
|
- -I"From: $sender" \
|
|
|
|
|
|
|
+ -I"From: $SENDER" \
|
|
|
-I"Subject: $subject" \
|
|
-I"Subject: $subject" \
|
|
|
-I"Content-Type: text/plain" -d1 \
|
|
-I"Content-Type: text/plain" -d1 \
|
|
|
- | sendmail -f "$sender" -t
|
|
|
|
|
|
|
+ | sendmail -f "$SENDER" -t
|
|
|
|
|
|
|
|
export MESSAGE FROM TO
|
|
export MESSAGE FROM TO
|
|
|
python3 <<'EOF'
|
|
python3 <<'EOF'
|
|
|
import sqlite3
|
|
import sqlite3
|
|
|
from os import environ as env
|
|
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("""
|
|
|
|
|
|
|
+for x in ('FROM', 'TO', 'MESSAGE', 'DB'):
|
|
|
|
|
+ globals()[x] = env.get(x)
|
|
|
|
|
+with sqlite3.connect(DB) as conn:
|
|
|
|
|
+ cursor = conn.cursor()
|
|
|
|
|
+ cursor.execute("""
|
|
|
INSERT INTO outbox (sent, "from", "to", payload)
|
|
INSERT INTO outbox (sent, "from", "to", payload)
|
|
|
VALUES (CURRENT_TIMESTAMP, '+1'||?, '+1'||?, ?)
|
|
VALUES (CURRENT_TIMESTAMP, '+1'||?, '+1'||?, ?)
|
|
|
-""", params)
|
|
|
|
|
-conn.commit()
|
|
|
|
|
-conn.close()
|
|
|
|
|
|
|
+""", [FROM, TO, MESSAGE])
|
|
|
EOF
|
|
EOF
|