These two python scripts will accept a mail message at STDIN and call or text via the Twillio service.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

32 lines
815B

  1. #!/usr/bin/python3
  2. from twilio.rest import Client
  3. import sys
  4. import email
  5. # Find these values at https://twilio.com/user/account
  6. account_sid = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  7. auth_token = "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"
  8. client = Client(account_sid, auth_token)
  9. raw_msg = ""
  10. for line in sys.stdin:
  11. raw_msg = raw_msg + line
  12. msg = email.message_from_string(raw_msg)
  13. text = msg['Subject'] + "\n\n"
  14. if msg.is_multipart():
  15. for payload in msg.get_payload():
  16. text = text + payload.get_payload()
  17. else:
  18. text = text + msg.get_payload()
  19. text = text[:160] if len(text) > 160 else text
  20. #print(text)
  21. message = client.api.account.messages.create(to = "+357XXXXXXXX",
  22. from_ = " +177XXXXXXXX",
  23. body = text)