-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME
152 lines (115 loc) · 4.31 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
Mailshare receives email and presents it in a web interface. CC your
discussions to your Mailshare server's email address. Emails can then
be viewed in a web browser.
This is intended to be used in a team as an alternative to forwarding
emails to the whole team.
License
=======
See https://github.com/RobFisher/mailshare/blob/master/LICENSE
Status
======
Just starting so few features, but it is already somewhat useful.
Installation
============
1. Copy the file settings_example.py to settings.py
2. Edit settings.py, supplying database details for storing emails and
IMAP details for retrieving them.
3. Create a database with MySQL, e.g.:
mysql -u root -p
CREATE DATABASE mailshare
4. Let Django set up the database: python manage.py syncdb
Say yes and answer the prompts when asked to set up a super user
for Django's authentication system. Later this will be used for
the admin interface.
5. Set up full text search with MySQL, e.g.:
sudo cp mailshare/mysql/mailshare.cnf /etc/mysql/conf.d
sudo service mysql restart
mysql -u root -p
USE mailshare;
ALTER TABLE mailshareapp_mail ADD FULLTEXT(body, subject)
The config file sets the minimum word length for full text search to
3. After that you are just creating the index.
Use
===
python manage.py shell
>>> import mailshareapp.process_emails
>>> mailshareapp.process_emails.quick_test()
This downloads 10 emails from the email server and puts them into the
database. You should now have a database containing up to 10
emails. All information from the mail server is also logged to a file
called mailfile. You can delete the database and replay previously
downloaded messages from this file with:
>>> mailshare.mailshareapp.process_emails.quick_test(True)
To view the database contents, start the Django test server with:
python manage.py runserver
Visit http://localhost:8000/admin/mailshareapp/mail/ to see the
emails.
Once you are happy that the IMAP connection is working, you can start
the full email polling process. In settings.py, make sure that
MAILSHARE_IMAP_ENABLE_EXPUNGE is set to True. Then:
poll_mail.sh
This just calls poll_mail.py which sets up the Django environment then
runs mailshareapp.process_emails.poll_emails which runs forever,
retrieving 10 emails at a time, adding them to the database, then
deleting them.
Environment
===========
For information, here is how I set up my environment in Ubuntu
10.04. Other platforms will be supported but I have to start
somewhere.
Install these Ubuntu packages:
lampserver^
libabache2-mod-python
phpmyadmin
- Apache and MySQL; hook Apache up to Python; and phpMyAdmin to see
what the database looks like.
python-MySQLdb
- Hook Python up to MySQL.
python-lxml
- used to sanitise HTML from emails.
Python libraries:
sudo apt-get install python-setuptools
sudo easy_install django
sudo easy_install django-dajaxice
sudo easy_install django-dajax
Deployment
==========
(See also
http://blog.stannard.net.au/2010/12/11/installing-django-with-apache-and-mod_wsgi-on-ubuntu-10-04/ )
Commands to deploy Mailshare on an Ubuntu 10.04 server:
sudo apt-get install git-core
git clone git://github.com/RobFisher/mailshare.git
sudo apt-get install mysql
sudo cp mailshare/mysql/mailshare.cnf /etc/mysql/conf.d/
sudo service mysql restart
sudo apt-get install apache2
sudo apt-get install apache2 libapache2-mod-wsgi
sudo apt-get install python-setuptools
sudo easy_install django
sudo easy_install django-dajaxice
sudo easy_install django-dajax
sudo apt-get install python-MySQLdb
sudo apt-get install python-lxml
sudo mkdir /srv/www
sudo ln -s `readlink -f mailshare` /srv/www/mailshare
sudo cp mailshare/apache/mailshare_site /etc/apache2/sites-available/mailshare
sudo a2ensite mailshare
sudo /etc/init.d/apache2 reload
cd mailshare
cp settings_example.py settings.py
vim settings.py
# fill in database and IMAP settings; enable IMAP_EXPUNGE;
# add /srv/www/mailshare/templates to TEMPLATE_DIRS
mysql -u root -p
mysql> CREATE DATABASE mailshare;
mysql> quit
python manage.py syncdb
mysql -u root -p
mysql> USE mailshare;
mysql> ALTER TABLE mailshareapp_mail ADD FULLTEXT(body, subject);
bmysql> quit
# The web server needs permission to write into the cache directory
sudo chgrp www-data cache
chmod ug+w cache
# whenever you change source code (including settings.py):
touch mailshare/apache/mailshare.wsgi