diff --git a/README.md b/README.md index ded5276..11c4a17 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,5 @@ Emails_SMS_Free_Mobile_API ========================== Receive your emails _via_ SMS with the Free Mobile API. + +Compatible python 2 and 3 diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/emails_sms_free.py b/emails_sms_free.py index 388cd37..30bbcfc 100755 --- a/emails_sms_free.py +++ b/emails_sms_free.py @@ -1,14 +1,25 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python +# -*- coding:utf-8-*- + +from __future__ import print_function #print function python 2 and 3 compatible import email import hashlib import imaplib -import json import os.path import requests import sys import time +#This is used to import library depending on the python version used. +try: + #for python 3 + import json +except ImportError: + # for python 2 + import simplejson as json + print('Error importing lib as python3, switching to python 2 libraries') + msg_ids = {} @@ -53,7 +64,7 @@ def send(url, user, password, msg, i=0): def get_emails(imap_server, imap_user, imap_password, inbox, uid): global msg_ids - + print('Connecting to '+imap_server+'… ', end='') conn = imaplib.IMAP4_SSL(imap_server) print('Connected') diff --git a/test.py b/test.py new file mode 100644 index 0000000..45bb98a --- /dev/null +++ b/test.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python + +from builtins import input #pour rendre input python2 and 3 compatible +import emails_sms_free + + +if __name__ == '__main__': + url = "https://smsapi.free-mobile.fr/sendmsg" + user= input("Please enter usr: ") + print("you entered" + str(user)) + password= input("Please enter password: ") + print("you entered"+ str(password)) + msg = input("Please enter msg: ") + print("you entered"+ str(msg)) + end = emails_sms_free.send(url, user, password, msg)