-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemail2task.sh
More file actions
28 lines (24 loc) · 1.17 KB
/
email2task.sh
File metadata and controls
28 lines (24 loc) · 1.17 KB
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
#!/bin/bash
# Frank Sommer / frank@sommers.cloud
# Simple solution to create tasks via email in taskworrior
# you need a separate email for taskwarrior
# date: 2022-05-01
set -e # abort in case of error
access="user@mailhost.com:topsecret" # username:credentials
host="imaps://mailhost.com" # host url
logfile="/var/log/email2task.log" # log file, make sure that you have access
# get number of emails
anz=$(curl --silent --url $host --user $access -X 'SELECT INBOX' |grep EXISTS | cut -c 3-4)
echo "$(date "+%F %H:%M:%S") $anz New Mails" >> $logfile
for((i=0; i<$anz; i++))
do
# fetch email from server
commopt=$(curl --silent --url $host"/INBOX;MAILINDEX=1;SECTION=Text" --user $access)
echo "$(date "+%F %H:%M:%S") MailID $i $commopt" >> $logfile
# create task
task $commopt >> $logfile
# delete email, after deleting the next email gets the number 1
curl --silent --url $host"/INBOX;MAILINDEX=1" --user $access -X "STORE 1 +Flags \Deleted" >> $logfile
curl --silent --url $host"/INBOX;MAILINDEX=1" --user $access -X "EXPUNGE" >> $logfile
done
exit 0