email.org (6511B)
1 # -*- org-use-property-inheritance: t; -*- 2 #+TITLE: Email config - mbysnc, msmtp, notmuch 3 4 * mbsync 5 :PROPERTIES: 6 :header-args: :tangle "xdg-config/mbsync/config" :mkdirp yes 7 :END: 8 9 MBSYNC (ISYNC) is the program that downloads all mail. The 10 configuration is whitespace-dependent, so I have split it into the 11 proper sections. 12 13 ** IMAP Account 14 15 This section describes the account used 16 17 #+begin_src conf-space 18 IMAPAccount gmail 19 Host imap.gmail.com 20 User beardsleejamie@gmail.com 21 PassCmd "pass mail/gmail.com" 22 SSLType IMAPS 23 CertificateFile /etc/ssl/certs/ca-certificates.crt 24 #+end_src 25 26 ** IMAP Store 27 28 #+begin_src conf-space 29 IMAPStore gmail-remote 30 Account gmail 31 #+end_src 32 33 ** Maildir Store 34 35 #+begin_src conf-space 36 MaildirStore gmail-local 37 Subfolders Verbatim 38 Path ~/.local/share/mail/ 39 Inbox ~/.local/share/mail/Inbox 40 #+end_src 41 42 ** Putting it all together 43 44 #+begin_src conf-space 45 Channel gmail 46 Master :gmail-remote: 47 Slave :gmail-local: 48 Patterns * ![Gmail]* "[Gmail]/Sent Mail" "[Gmail]/Starred" "[Gmail]/All Mail" 49 Create Both 50 SyncState * 51 #+end_src 52 53 * notmuch 54 :PROPERTIES: 55 :header-args: :tangle "xdg-config/notmuch/config" 56 :header-args+: :mkdirp t 57 :END: 58 59 NOTMUCH is the program that searches and indexes all local mail. It 60 has a nice emacs interface. 61 62 ** database 63 64 The only value supported here is 'path' which should be the top-level 65 directory where your mail currently exists and to where mail will be 66 delivered in the future. Files should be individual email messages. 67 Notmuch will store its database within a sub-directory of the path 68 configured here named ".notmuch". 69 70 #+begin_src conf-unix 71 [database] 72 path=/home/jdb/.local/share/mail 73 #+end_src 74 75 ** user 76 77 Here is where you can let notmuch know how you would like to be 78 addressed. Valid settings are 79 80 name Your full name. 81 primary_email Your primary email address. 82 other_email A list (separated by ';') of other email addresses 83 at which you receive email. 84 85 Notmuch will use the various email addresses configured here when 86 formatting replies. It will avoid including your own addresses in the 87 recipient list of replies, and will set the From address based on the 88 address to which the original email was addressed. 89 90 #+begin_src conf-unix 91 [user] 92 name=Jamie Beardslee 93 primary_email=beardsleejamie@gmail.com 94 #+end_src 95 96 ** Configuration for "notmuch new" 97 98 The following options are supported here: 99 100 tags A list (separated by ';') of the tags that will be 101 added to all messages incorporated by "notmuch new". 102 103 ignore A list (separated by ';') of file and directory names 104 that will not be searched for messages by "notmuch new". 105 106 #+begin_src conf-unix 107 [new] 108 tags=unread;inbox; 109 ignore= 110 #+end_src 111 112 ** Search configuration 113 114 The following option is supported here: 115 116 exclude_tags 117 A ;-separated list of tags that will be excluded from 118 search results by default. Using an excluded tag in a 119 query will override that exclusion. 120 121 #+begin_src conf-unix 122 [search] 123 exclude_tags=deleted;spam; 124 #+end_src 125 126 ** Maildir compatibility 127 128 The following option is supported here: 129 130 synchronize_flags Valid values are true and false. 131 132 #+begin_src conf-unix 133 [maildir] 134 synchronize_flags=true 135 #+end_src 136 137 ** hooks 138 139 *** Update database 140 141 The following is a hook to update the mail database with [[*mbsync][mbsync]] before 142 invoking =notmuch new=. 143 144 #+begin_src sh :shebang "#!/bin/sh" :tangle "out/.local/share/mail/.notmuch/hooks/pre-new" 145 mbsync -a -c "$XDG_CONFIG_HOME/mbsync/config"; true 146 #+end_src 147 148 *** Add tags 149 150 The post-new hook should tag all mail appropriately. I use a =list= 151 tag for mailing lists, and a =uni= tag for university emails. 152 153 I also make sure that my sent mail is properly tagged as =sent=. This 154 is achieved in the post-insert hook as well, but that doesn't work if 155 I send an email any way other than via notmuch. 156 157 #+begin_src sh :shebang "#!/bin/sh" :tangle "out/.local/share/mail/.notmuch/hooks/post-new" 158 # Mailing lists -- remove them from inbox 159 notmuch tag +list +emacs -- "/emacs.*@gnu\.org" 160 notmuch tag +list +lilypond -- "/lilypond.*/@gnu\.org" 161 notmuch tag -inbox -- tag:list 162 163 # University -- keep in inbox, but tag with "uni" 164 notmuch tag +uni -- "*vuw.ac.nz" 165 notmuch tag +uni -- "*wgtn.ac.nz" 166 167 # Tag sent mail as sent 168 notmuch tag +sent -- from:"$EMAIL" 169 170 # If unread mail exists and Xorg is running, send a notification 171 if [ -n "$(notmuch search tag:unread AND tag:inbox)" ] ; then 172 [ -n "$DISPLAY" ] && notify-send "You've got mail!" 173 fi 174 #+end_src 175 176 #+begin_src sh :shebang "#!/bin/sh" :tangle "out/.local/share/mail/.notmuch/hooks/post-insert" 177 # Tag sent mail as sent 178 notmuch tag +sent -- from:"$EMAIL" 179 #+end_src 180 181 * msmtp 182 :PROPERTIES: 183 :header-args: :tangle "xdg-config/msmtp/config" 184 :header-args+: :mkdirp t 185 :END: 186 187 MSMTP is the program that sends mail. 188 189 ** defaults 190 191 Set default values for all accounts 192 193 #+begin_src conf-space 194 defaults 195 tls_trust_file /etc/ssl/certs/ca-certificates.crt 196 #+end_src 197 198 *** Use the mail submission port 587 instead of the SMTP port 25. 199 200 #+begin_src conf-space 201 port 587 202 #+end_src 203 204 *** TLS settings 205 206 #+begin_src conf-space 207 tls on 208 tls_starttls on 209 tls_certcheck off 210 #+end_src 211 212 ** accounts 213 214 I only use one email, but you can set multiple here. 215 216 *** gmail 217 218 The account name and host 219 220 #+begin_src conf-space 221 account gmail 222 host smtp.gmail.com 223 port 587 224 #+end_src 225 226 **** address and user 227 228 #+begin_src conf-space 229 from beardsleejamie@gmail.com 230 user beardsleejamie 231 #+end_src 232 233 **** password 234 235 Similar to mbsync, you can specify a command to get the password 236 rather than write in the config file itself. 237 238 #+begin_src conf-space 239 auth plain 240 passwordeval "pass mail/gmail.com" 241 #+end_src 242 243 *** University 244 245 The account name and host 246 247 #+begin_src conf-space 248 account uni 249 host smtp.office365.com 250 port 587 251 #+end_src 252 253 **** address and user 254 255 #+begin_src conf-space 256 from beardsjami@myvuw.ac.nz 257 user beardsjami@myvuw.ac.nz 258 #+end_src 259 260 **** password 261 262 Similar to mbsync, you can specify a command to get the password 263 rather than write in the config file itself. 264 265 #+begin_src conf-space 266 auth plain 267 passwordeval "pass mail/office365.com" 268 #+end_src 269 *** my own server 270 271 #+begin_src conf-space 272 account jamzattack.xyz 273 host mail.jamzattack.xyz 274 port 587 275 #+end_src 276 277 **** address and user 278 279 #+begin_src conf-space 280 from jdb@jamzattack.xyz 281 user jdb 282 #+end_src 283 284 **** password 285 286 Similar to mbsync, you can specify a command to get the password 287 rather than write in the config file itself. 288 289 #+begin_src conf-space 290 auth plain 291 passwordeval "pass mail/mail.jamzattack.xyz" 292 #+end_src