Преглед изворни кода

Rules for specific email addresses

Bob Mottram пре 11 година
родитељ
комит
357e21f865
1 измењених фајлова са 66 додато и 1 уклоњено
  1. 66
    1
      beaglebone.txt

+ 66
- 1
beaglebone.txt Прегледај датотеку

@@ -1145,6 +1145,7 @@ service dovecot restart
1145 1145
 #+END_SRC
1146 1146
 
1147 1147
 ** Create Email folders and rules
1148
+*** Rules for mailing lists
1148 1149
 A common situation with email is that you may be subscribed to various mailing lists and want incoming email from those to be automatically grouped into a separate folder for each list.
1149 1150
 
1150 1151
 We can make a script to make adding mailing list rules easy:
@@ -1190,7 +1191,7 @@ chmod +x /usr/bin/mailinglistrule
1190 1191
 Now we can add a new mailing list rule with the following, where /myusername/ is your username, /mailinglistname/ is the name of the mailing list (with no spaces) and /subjecttag/ is the tag which usually appears within square brackets in the subject line of emails from the list.
1191 1192
 
1192 1193
 #+BEGIN_SRC: bash
1193
-mailinglistrule myusername mailinglistname subjecttag
1194
+mailinglistrule [myusername] [mailinglistname] [subjecttag]
1194 1195
 #+END_SRC
1195 1196
 
1196 1197
 Repeat this command for as many mailing lists as you need.  Then edit your local Mutt configuration.
@@ -1207,6 +1208,70 @@ mailboxes = =Sent =mailinglistname
1207 1208
 
1208 1209
 Then save and exit.
1209 1210
 
1211
+*** Rules for specific email addresses
1212
+
1213
+You can also make a script which will allow you to add specific email addresses to a folder.
1214
+
1215
+#+BEGIN_SRC: bash
1216
+emacs /usr/bin/emailrule
1217
+#+END_SRC
1218
+
1219
+Add the following:
1220
+
1221
+#+BEGIN_SRC: bash
1222
+#!/bin/bash
1223
+MYUSERNAME=$1
1224
+EMAILADDRESS=$2
1225
+MAILINGLIST=$3
1226
+MUTTRC=/home/$MYUSERNAME/.muttrc
1227
+PM=/home/$MYUSERNAME/.procmailrc
1228
+LISTDIR=/home/$MYUSERNAME/Maildir/$MAILINGLIST
1229
+if [ ! -d "$LISTDIR" ]; then
1230
+  mkdir -m 700 $LISTDIR
1231
+  mkdir -m 700 $LISTDIR/tmp
1232
+  mkdir -m 700 $LISTDIR/new
1233
+  mkdir -m 700 $LISTDIR/cur
1234
+fi
1235
+chown -R $MYUSERNAME:$MYUSERNAME $LISTDIR
1236
+echo "" >> $PM
1237
+echo ":0" >> $PM
1238
+echo "  * ^From: $EMAILADDRESS" >> $PM
1239
+echo "$LISTDIR/new" >> $PM
1240
+chown $MYUSERNAME:$MYUSERNAME $PM
1241
+if [ ! -f "$MUTTRC" ]; then
1242
+  cp /etc/Muttrc $MUTTRC
1243
+  chown $MYUSERNAME:$MYUSERNAME $MUTTRC
1244
+fi
1245
+#+END_SRC
1246
+
1247
+Save and exit, then make the script executable.
1248
+
1249
+#+BEGIN_SRC: bash
1250
+chmod +x /usr/bin/emailrule
1251
+#+END_SRC
1252
+
1253
+Then to add a particular email address to a folder run the command:
1254
+
1255
+#+BEGIN_SRC: bash
1256
+emailrule [myusername] [emailaddress] [foldername]
1257
+#+END_SRC
1258
+
1259
+If you want any mail from the given email address to be deleted then set the /foldername/  to /Trash/.
1260
+
1261
+To ensure that the folder appears within Mutt.
1262
+
1263
+#+BEGIN_SRC: bash
1264
+emacs /home/myusername/.muttrc
1265
+#+END_SRC
1266
+
1267
+Search for the *mailboxes* variable and add entries for the mailing lists you just created.  For example:
1268
+
1269
+#+BEGIN_SRC: bash
1270
+mailboxes = =Sent =foldername
1271
+#+END_SRC
1272
+
1273
+Then save and exit.
1274
+
1210 1275
 ** Setting up a web site
1211 1276
 
1212 1277
 #+BEGIN_VERSE