--- /dev/null
+import mailbox
+
+def read_mail(path):
+ mdir = mailbox.Maildir(path)
+ return mdir
+
+def get_mails(mdir):
+ l = []
+ for id, msg in mdir.iteritems():
+ msg_obj = {}
+ msg_obj["from"] = msg.getheaders('From')[0]
+ msg_obj["to"] = msg.getheaders('To')[0]
+ msg_obj["subject"] = msg.getheaders('Subject')[0]
+ msg_obj["contents"] = msg.getheaders('Subject')[0]
+ l.append(msg_obj)
+ return l
+
+
+
--- /dev/null
+import bottle
+import json
+from bottle import route, template, response
+from maildir import *
+
+@route('/kite/<user>/mail')
+def index(user):
+ response.content_type = "application/json"
+ mdir = read_mail("/home/kite/Maildir")
+ return json.dumps(get_mails(mdir))
+
+bottle.run(host='localhost', port='8080')
+++ /dev/null
-import bottle
-import json
-from bottle import route, template, response
-
-@route('/kite/<user>/mail')
-def index(user):
- response.content_type = "application/json"
- return json.dumps([
- {"from": "random.spam@spam.com",
- "to": "you",
- "subject": "-50% promo on everything !",
- "contents": "Everything must go !",
- "date": "2013-23-9"
- },
-
- {"from": "nigerian.prince@spam.com",
- "to": "user@mail.com",
- "subject": "I need your urgent help",
- "contents": "Hi my dear friend. I need your help urgently in a matter of financial problems.",
- "date": " 1992-04-05",
- },
- {"from": "team@kitemail",
- "name": "Kite team",
- "to": "user@mail.com",
- "subject": "Welcome to Kite !",
- "contents": "This is the basic inbox page. As you can see, it looks a lot like a famous email service.",
- "date": "1995-05-30"
- }])
-
-
-bottle.run(host='localhost', port='8080')
angular.module('KiteMail.services', ['ngResource']).
factory('Emails', ['$resource',
function($resource) {
- var data = $resource('/kite/:user/mail/', {}, {
+ var res = $resource('/kite/:user/mail/', {}, {
query: {
method:'GET',
params:{user: "karim"},
},
});
-
+
+ return res;
}
]);