Pages:
Author

Topic: Email and sms sender using Claymore's remote manager - page 2. (Read 2217 times)

legendary
Activity: 1084
Merit: 1003
≡v≡
Great job for sharing this scripts. Anyway I was just looking at Twilio website and can't find any fees/pricing per sms or anything. Can you share that information ?
this is totally free, I'm using it for two month now. As I know if you want to use some kind of special number or clean text that costs min 20$ as I remember (when you enter you own text like: "rig is down" you get sms "Sent from your Twilio trial account - rig is down")
legendary
Activity: 1878
Merit: 1038
Telegram: https://t.me/eckmar
Great job for sharing this scripts. Anyway I was just looking at Twilio website and can't find any fees/pricing per sms or anything. Can you share that information ?
legendary
Activity: 1084
Merit: 1003
≡v≡
I was unable to manage Remote Manager to send me email or even sms in case of alarm, so after spending some time searching the internet how to make .bat file to send sms and email  I came up with an idea to send sms and email with python script and make but file to run these scripts. It's very helpful for me to manage my rigs even if I'm offline.
First you need to install python 3.5.2 and don't forget to check both boxes:

After fresh installing the python lets configure Twilio account.
Sign up for Twilio account and create API https://www.twilio.com/try-twilio
Code:
Step 1: Create an API Key

First, you need to create an API Key, which contains a secret used to sign Access Tokens. You can create API Keys from the Twilio Console or using the REST API. At the time you create the API Key, you'll be shown the Key's secret. For security, you will only be shown the secret when the key is created. You should store it with the Key's SID in a secure location for the next step.

Step 2: Generate an Access Token

Next, you'll use the the secret of the API Key you created in step 1 to generate an access-token using the Twilio Helper Library. Each token is granted access to specific client features.

then make a .py file and fill it with this(replace _sid and _token to your live _sid and _token and also replace numbers):
Code:
# Download the twilio-python library from http://twilio.com/docs/libraries
from twilio.rest import TwilioRestClient

# Find these values at https://twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXX"
auth_token = "YYYYYYYYYYYYYYYYYY"
client = TwilioRestClient(account_sid, auth_token)

message = client.messages.create(to="+12316851234", from_="+15555555555",
                                     body="Hello there!")

Then run this in CMD:
Code:
pip install twilio

Now you can test sms.py file by double clicking on it, after few second you should get sms from Twilio number with your own text.




Configure email sender:
Open CMD and type:
Code:
>python
>>> import smtplib


After this replace email accounts in code above and save it as email.py:
Code:
import smtplib
 
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login("YOUR EMAIL ADDRESS", "YOUR PASSWORD")
 
msg = "YOUR MESSAGE!"
server.sendmail("YOUR EMAIL ADDRESS", "THE EMAIL ADDRESS TO SEND TO", msg)
server.quit()

If you will using gmail don't forget to allow "less secure apps" to access your account.


After these steps you can create simple .bat file to use in remote manager to run these two python scripts in case of alarm
Code:
@ECHO OFF

start C:\******\gmail.py
start C:\******\sms.py



P.S. I've done these steps and everything is working fine for me, I didn't write neither sms sender script nor email sender one, use them on your discretion.
sources used:
Twilio API creation https://www.twilio.com/docs/api/rest/access-tokens
SMS .py file https://www.twilio.com/docs/quickstart/python/sms/sending-via-rest
email stuff http://naelshiab.com/tutorial-send-email-python/
Pages:
Jump to: