Compare commits
No commits in common. "e7ca4cb4344cff762f19283a59521751f4354cbf" and "c981bfd0332fef7bcf3de5efdbc680524207fa8d" have entirely different histories.
e7ca4cb434
...
c981bfd033
22
README.md
22
README.md
@ -47,30 +47,16 @@ In commands You can use fields ```<email>```, ```<subject>``` and ```<message>``
|
|||||||
|
|
||||||
#### *nix
|
#### *nix
|
||||||
|
|
||||||
##### send-mail
|
|
||||||
|
|
||||||
**Usage:** ```send-mail recipient 'subject' 'message'```
|
|
||||||
|
|
||||||
Configuration file ```/etc/email.conf```
|
|
||||||
|
|
||||||
- ```Username:``` - Set e-mail user name here
|
|
||||||
- ```Password:``` - Set e-mail password here
|
|
||||||
- ```SMTP Server:``` - Set SMTP server address here
|
|
||||||
- ```Port:``` - Set SMTP port here
|
|
||||||
##### send-telegram
|
##### send-telegram
|
||||||
|
|
||||||
**Usage:** ```send-telegram 'message'```
|
Next lines needs to be configured:
|
||||||
|
|
||||||
Configuration file ```/etc/telegram.conf```
|
- ```GROUP_ID=<group_id>``` - Set Telegram group ID here
|
||||||
|
- ```BOT_TOKEN=<bot_token>``` - Set Telegram token here
|
||||||
- ```Group ID:``` - Set Telegram group ID here
|
|
||||||
- ```Bot token:``` - Set Telegram token here
|
|
||||||
#### Windows
|
#### Windows
|
||||||
|
|
||||||
##### send-mail.ps1
|
##### send-mail.ps1
|
||||||
|
|
||||||
**Usage:** ```send-mail.ps1 recipient 'subject' 'message'```
|
|
||||||
|
|
||||||
Next lines needs to be configured:
|
Next lines needs to be configured:
|
||||||
|
|
||||||
- ```$EmailFrom = "yourmailadress@somedomain.com"``` - Set sender e-mail address here
|
- ```$EmailFrom = "yourmailadress@somedomain.com"``` - Set sender e-mail address here
|
||||||
@ -80,8 +66,6 @@ Next lines needs to be configured:
|
|||||||
|
|
||||||
##### send-telegram.ps1
|
##### send-telegram.ps1
|
||||||
|
|
||||||
**Usage:** ```send-telegram.ps1 'message'```
|
|
||||||
|
|
||||||
- ```$Telegramtoken = "Your_Telegram_Token"``` - Set Telegram token here
|
- ```$Telegramtoken = "Your_Telegram_Token"``` - Set Telegram token here
|
||||||
- ```$Telegramchatid = "Your_Telegram_Chat_ID"``` - Set Telegram chat ID here
|
- ```$Telegramchatid = "Your_Telegram_Chat_ID"``` - Set Telegram chat ID here
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +0,0 @@
|
|||||||
Username: user@domain.local
|
|
||||||
Password: str0ngP@$$word
|
|
||||||
SMTP Server: smtp.domain.local
|
|
||||||
Port: 465
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
Group ID: Telegram_Group_ID
|
|
||||||
Bot token: Telegram_Bot_Token
|
|
||||||
23
scripts/unix/send-telegram.template
Normal file
23
scripts/unix/send-telegram.template
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
GROUP_ID=<group_id>
|
||||||
|
BOT_TOKEN=<bot_token>
|
||||||
|
|
||||||
|
# this 3 checks (if) are not necessary but should be convenient
|
||||||
|
if [ "$1" == "-h" ]; then
|
||||||
|
echo "Usage: `basename $0` \"text message\""
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$1" ]
|
||||||
|
then
|
||||||
|
echo "Add message text as second arguments"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$#" -ne 1 ]; then
|
||||||
|
echo "You can pass only one argument. For string with spaces put it on quotes"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
curl -s --data "text=$1" --data "chat_id=$GROUP_ID" 'https://api.telegram.org/bot'$BOT_TOKEN'/sendMessage' > /dev/null
|
||||||
@ -1,42 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
rcpt=$1
|
|
||||||
subj=$2
|
|
||||||
message=$3
|
|
||||||
|
|
||||||
ARGS=$(xargs echo $(perl -anle 's/^[^:]+//g && s/:\s+//g && print' /etc/email.conf) < /dev/null)
|
|
||||||
set -- $ARGS "$@";
|
|
||||||
|
|
||||||
declare -A email;
|
|
||||||
email['user']=$1
|
|
||||||
email['pass']=$2
|
|
||||||
email['smtp']=$3
|
|
||||||
email['port']=$4
|
|
||||||
|
|
||||||
email_content='From: "Watchdog" <'"${email['user']}"'>
|
|
||||||
To: "Subscriber" <'"${rcpt}"'>
|
|
||||||
Subject: '"${subj}"'
|
|
||||||
Date: '"$(date)"'
|
|
||||||
|
|
||||||
'"${message}"'
|
|
||||||
-----
|
|
||||||
'"${HOSTNAME}"'
|
|
||||||
';
|
|
||||||
|
|
||||||
|
|
||||||
echo "$email_content" | curl -s \ # -vvv \
|
|
||||||
--url "smtps://${email['smtp']}:${email['port']}" \
|
|
||||||
--user "${email['user']}:${email['pass']}" \
|
|
||||||
--mail-from "${email['user']}" \
|
|
||||||
--mail-rcpt "${rcpt}" \
|
|
||||||
--upload-file - \
|
|
||||||
-T -
|
|
||||||
|
|
||||||
|
|
||||||
if [[ $? == 0 ]]; then
|
|
||||||
echo;
|
|
||||||
echo 'okay';
|
|
||||||
else
|
|
||||||
echo "curl error code $?";
|
|
||||||
man curl | grep "^ \+$? \+"
|
|
||||||
fi
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
SCRIPT_NAME=$0
|
|
||||||
MESSAGE_TEXT=$1
|
|
||||||
|
|
||||||
if [ "$#" -ne 1 ]; then
|
|
||||||
echo "You can pass only one argument. For string with spaces put it on quotes"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
ARGS=$(xargs echo $(perl -anle 's/^[^:]+//g && s/:\s+//g && print' /etc/email.conf) < /dev/null)
|
|
||||||
set -- $ARGS "$@";
|
|
||||||
|
|
||||||
GROUP_ID=$1
|
|
||||||
BOT_TOKEN=$2
|
|
||||||
|
|
||||||
# this 3 checks (if) are not necessary but should be convenient
|
|
||||||
if [ "${MESSAGE_TEXT}" == "-h" ]; then
|
|
||||||
echo "Usage: `basename ${SCRIPT_NAME}` \"text message\""
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "${MESSAGE_TEXT}" ]
|
|
||||||
then
|
|
||||||
echo "Add message text as second arguments"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
curl -s --data "text=${MESSAGE_TEXT}" --data "chat_id=$GROUP_ID" 'https://api.telegram.org/bot'$BOT_TOKEN'/sendMessage' > /dev/null
|
|
||||||
Loading…
x
Reference in New Issue
Block a user