Last active
June 26, 2020 20:07
-
-
Save jack-champagne/947c94b75e4acaf1b22e25198002c689 to your computer and use it in GitHub Desktop.
pc to phone takes CLI input or clipboard and send it to a phone using provider sms gateway.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! python | |
import smtplib | |
import pyperclip as clip | |
import sys | |
import os | |
def send_msg(message): | |
print("Sending %s" % (message)) | |
message = "\r\n".join([ | |
"From: my-personal-email@gmail.com", | |
"To: my-phone-number@vtext.com", | |
message, | |
"", | |
"" | |
]) | |
server = smtplib.SMTP("smtp.gmail.com") | |
server.ehlo() | |
server.starttls() | |
password = open("static\\token.tk", "rb").read().decode("UTF-8") | |
server.login("my-personal-email@gmail.com", password) | |
failed = server.sendmail("my-personal-email@gmail.com", ["my-phone-number@vtext.com"], message) | |
if len(failed) > 0: | |
print(failed.keys()) | |
else: | |
print("Sent") | |
server.quit() | |
# First we must check for command line arguments | |
if len(sys.argv) > 1: | |
if sys.argv[1] == "-h": | |
print("""Usage: | |
pctophone -h (This help menu) | |
pctophone [string to be sent] | |
pctophone (No arguments: Will take contents of clipboard)""") | |
else: | |
send_msg(" ".join(sys.argv[1:])) | |
else: | |
send_msg(clip.paste()) |
Updated today for best implementation by using port 587 for mail requests and submissions.
Verizon (and other large ISPS) have activity blocked on default ports.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use for self, change my-personal-email@gmail.com to your email address and my-phone-number@vtext.com to your number @ your service provider's sms gateway (for me, Verizon). Here is a list of sms gateways through providers: gateways.
Make sure when you login to your email, you pass it your password, or if you are using gmail. You should generate an 'App password' and also use your email provider's smtp url for the .SMTP() call.