반응형
How to send text messages with Python for Free
https://medium.com/testingonprod/how-to-send-text-messages-with-python-for-free-a7c92816e1a4
What you’ll need
For this post, I’ll be using the following:
- Python (I used version 3.9.1)
- smtplib (https://docs.python.org/3/library/smtplib.html)
- Email (I use gmail)
It should be noted that if you’re using gmail, like me, you’ll need to setup and use an application password with your account. You can read more information and security warnings on that here: https://support.google.com/accounts/answer/185833?p=InvalidSecondFactor&visit_id=637700239874464736-1954441174&rd=1
import smtplib
import sys
CARRIERS = {
"att": "@mms.att.net",
"tmobile": "@tmomail.net",
"verizon": "@vtext.com",
"sprint": "@messaging.sprintpcs.com"
}
EMAIL = "EMAIL"
PASSWORD = "PASSWORD"
def send_message(phone_number, carrier, message):
recipient = phone_number + CARRIERS[carrier]
auth = (EMAIL, PASSWORD)
server = smtplib.SMTP("smtp.gmail.com", 587)
server.starttls()
server.login(auth[0], auth[1])
server.sendmail(auth[0], recipient, message)
if __name__ == "__main__":
if len(sys.argv) < 4:
print(f"Usage: python3 {sys.argv[0]} <PHONE_NUMBER> <CARRIER> <MESSAGE>")
sys.exit(0)
phone_number = sys.argv[1]
carrier = sys.argv[2]
message = sys.argv[3]
send_message(phone_number, carrier, message)
반응형
'프로그래밍 > Python' 카테고리의 다른 글
[python] sudoku 만들기 - 랜덤 문제 (0) | 2023.09.27 |
---|---|
[python] sudoku 만들기 (0) | 2023.09.27 |
[python] algorithm, 알고리즘 (0) | 2023.09.20 |
[python] GUI 비밀번호 자동 생성기 (0) | 2023.09.18 |
[python] pyperclip (0) | 2023.09.18 |