Mutt
Servus,
ich nutze für meinen Mailverkehr Mutt. Hier habe ich alle meine E-Mailadresse (5) untergebracht. Ich weiß das meine Konfig nicht die einzige Lösung ist und sicherlich nicht die beste. Doch ich komme sehr gut zurecht, und da ich gefragt wurde, diese zu Teilen, werde ich das hier gerne tun. Wenn es fragen dazu gibt, könnt ihr mich gerne in Jabber/XMPP anschreiben
pr3ach3r@trashserver.net
Installation
Im folgenden werden wir Mutt und einige zusätzliche Programme die wir für die Darstellung und Anhänge benötigen installieren:
apt install mutt w3m sxiv mpv apvlv libreoffice urlview
- w3m => Darstellung von HTML Mails
- sxiv => Anzeigen von Bildern
- mpv => Abspielen von Mediendateien
- apvlv => PDF Dokumente anzeigen
- libreoffice => ist glaube ich klar
- urlview => wie Links geöffnet werden sollen
Ordner
Als nächstes erstellen wir alle wichtigen Ordner:
mkdir .mutt/{alias,cache/{bodies,headers},temp} -p
Anlegen der Konfiguration
Fangen wir mit den leichten Teilen an, und erstellen als erste im Ordner .mutt/ die Datei mailcap und füllen Sie mit folgenden Inhalt:
message/rfc822; less %s; edit=${EDITOR-vi} %s; compose=${EDITOR-vi} %s; needsterminal;
text/html; w3m -I %{charset} -T text/html; copiousoutput;
image/*; sxiv %s &>/dev/null
video/*; mpv %s
audio/*; mpv %s
text/*; vim %s
application/pdf; apvlv %s
application/odt; libreoffice %s
application/ods; libreoffice %s
application/msword; libreoffice %s
application/vnd.oasis.opendocument.text; libreoffice %s
application/vnd.openxmlformats-officedocument.wordprocessingml.document; libreoffice %s &>/dev/nul
Diese Datei sagt Mutt, wie bestimmte Dateitypen zu handhaben sind.
Als nächstes legen wir im selben Ordner die Datei gpg.rc an, diese Schritt ist optional und gibt an wie wir gerne mit GPG umgehen wollen:
set crypt_use_gpgme = yes
set crypt_autosign = yes
set pgp_timeout = 1800
set pgp_good_sign="gpg: (Korrekte Unterschrift von|Good signature from) "
set crypt_replysign = yes
set crypt_replyencrypt = yes
set crypt_replysignencrypted = yes
set crypt_verify_sig = yes
- crypt_replysign => Signiert antworten
- crypt_replyencrypt => verschlüsselt antworten
- crypt_replysignencrypted => Signiert und verschlüsselt antworten
- crypt_verify_sig => Signatur überprüfen
Diese Optionen können noch erweitert werden Mutt Doku
Jetzt legen wir die Datei colors an, diese ist einfach eine Theme, in diesem Fall solarized dark :
# vim: filetype=muttrc
# basic colors ---------------------------------------------------------
color normal brightyellow default
color error red default
color tilde black default
color message cyan default
color markers red white
color attachment white default
color search brightmagenta default
#color status J_black J_status
color status brightyellow black
color indicator brightblack yellow
color tree yellow default # arrow in threads
# basic monocolor screen
mono bold bold
mono underline underline
mono indicator reverse
mono error bold
# index ----------------------------------------------------------------
color index red default "~A" # all messages
color index brightred default "~E" # expired messages
color index blue default "~N" # new messages
color index blue default "~O" # old messages
color index brightmagenta default "~Q" # messages that have been replied to
color index brightgreen default "~R" # read messages
color index blue default "~U" # unread messages
color index blue default "~U~$" # unread, unreferenced messages
color index brightyellow default "~v" # messages part of a collapsed thread
color index brightyellow default "~P" # messages from me
color index cyan default "~p!~F" # messages to me
color index cyan default "~N~p!~F" # new messages to me
color index cyan default "~U~p!~F" # unread messages to me
color index brightgreen default "~R~p!~F" # messages to me
color index red default "~F" # flagged messages
color index red default "~F~p" # flagged messages to me
color index red default "~N~F" # new flagged messages
color index red default "~N~F~p" # new flagged messages to me
color index red default "~U~F~p" # new flagged messages to me
color index black red "~D" # deleted messages
color index brightcyan default "~v~(!~N)" # collapsed thread with no unread
color index yellow default "~v~(~N)" # collapsed thread with some unread
color index green default "~N~v~(~N)" # collapsed thread with unread parent
color index red black "~v~(~F)!~N" # collapsed thread with flagged, no unread
color index yellow black "~v~(~F~N)" # collapsed thread with some unread & flagged
color index green black "~N~v~(~F~N)" # collapsed thread with unread parent & flagged
color index green black "~N~v~(~F)" # collapsed thread with unread parent, no unread inside, but some flagged
color index cyan black "~v~(~p)" # collapsed thread with unread parent, no unread inside, some to me directly
color index yellow red "~v~(~D)" # thread with deleted (doesn't differentiate between all or partial)
# message headers ------------------------------------------------------
#color header brightgreen default "^"
color hdrdefault brightgreen default
color header brightyellow default "^(From)"
color header blue default "^(Subject)"
# body -----------------------------------------------------------------
color quoted blue default
color quoted1 cyan default
color quoted2 yellow default
color quoted3 red default
color quoted4 brightred default
color signature brightgreen default
color bold black default
color underline black default
color normal default default
#
color body brightcyan default "[;:][-o][)/(|]" # emoticons
color body brightcyan default "[;:][)(|]" # emoticons
color body brightcyan default "[*]?((N)?ACK|CU|LOL|SCNR|BRB|BTW|CWYL|\
|FWIW|vbg|GD&R|HTH|HTHBE|IMHO|IMNSHO|\
|IRL|RTFM|ROTFL|ROFL|YMMV)[*]?"
color body brightcyan default "[ ][*][^*]*[*][ ]?" # more emoticon?
color body brightcyan default "[ ]?[*][^*]*[*][ ]" # more emoticon?
## pgp
color body red default "(FALSCHE Unterschrift)"
color body black red "(WARNUNG: Wir haben KEINEN Beleg, dass der Schlüssel zur oben genannten Person gehört)"
color body green default "(Gültige Unterschrift)"
color body brightblack default "^gpg: Gültige Unterschrift .*"
color body brightyellow default "^gpg: "
color body brightyellow red "^gpg: FALSCHE Unterschrift von.*"
mono body bold "^gpg: Gültige Unterschrift von.*"
# yes, an insance URL regex
color body red default "([a-z][a-z0-9+-]*://(((([a-z0-9_.!~*'();:&=+$,-]|%[0-9a-f][0-9a-f])*@)?((([a-z0-9]([a-z0-9-]*[a-z0-9])?)\\.)*([a-z]([a-z0-9-]*[a-z0-9])?)\\.?|[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+)(:[0-9]+)?)|([a-z0-9_.!~*'()$,;:@&=+-]|%[0-9a-f][0-9a-f])+)(/([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*(;([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*)*(/([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*(;([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*)*)*)?(\\?([a-z0-9_.!~*'();/?:@&=+$,-]|%[0-9a-f][0-9a-f])*)?(#([a-z0-9_.!~*'();/?:@&=+$,-]|%[0-9a-f][0-9a-f])*)?|(www|ftp)\\.(([a-z0-9]([a-z0-9-]*[a-z0-9])?)\\.)*([a-z]([a-z0-9-]*[a-z0-9])?)\\.?(:[0-9]+)?(/([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*(;([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*)*(/([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*(;([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*)*)*)?(\\?([-a-z0-9_.!~*'();/?:@&=+$,]|%[0-9a-f][0-9a-f])*)?(#([-a-z0-9_.!~*'();/?:@&=+$,]|%[0-9a-f][0-9a-f])*)?)[^].,:;!)? \t\r\n<>\"]"
# and a heavy handed email regex
#color body J_magent default "((@(([0-9a-z-]+\\.)*[0-9a-z-]+\\.?|#[0-9]+|\\[[0-9]?[0-9]?[0-9]\\.[0-9]?[0-9]?[0-9]\\.[0-9]?[0-9]?[0-9]\\.[0-9]?[0-9]?[0-9]\\]),)*@(([0-9a-z-]+\\.)*[0-9a-z-]+\\.?|#[0-9]+|\\[[0-9]?[0-9]?[0-9]\\.[0-9]?[0-9]?[0-9]\\.[0-9]?[0-9]?[0-9]\\.[0-9]?[0-9]?[0-9]\\]):)?[0-9a-z_.+%$-]+@(([0-9a-z-]+\\.)*[0-9a-z-]+\\.?|#[0-9]+|\\[[0-2]?[0-9]?[0-9]\\.[0-2]?[0-9]?[0-9]\\.[0-2]?[0-9]?[0-9]\\.[0-2]?[0-9]?[0-9]\\])"
Ok kommen wir zum komplizierten Teil, zur eigentlich Mutt Konfiguration. Im folgenden werde ich immer Abschnitt für Abschnitt machen. Am Ende gibt es das Ding dann komplett. Wir legen die Datei muttrc im besagten Ordner an, und fangen an Sie zu befüllen:
source "~/.mutt/account.exmaple2"
folder-hook $folder 'source ~/.mutt/example2'
source "~/.mutt/account.example1"
folder-hook $folder 'source ~/.mutt/example1'
macro index <f3> '<sync-mailbox><enter-command>source ~/.mutt/account.example1<enter><change-folder>!<enter>'
macro index <f4> '<sync-mailbox><enter-command>source ~/.mutt/account.example2<enter><change-folder>!<enter>'
So, wir legen jetzt zwei Tasten für das Wechseln zwischen den Accounts fest, hier F6 und F7. Diese binden wir an die entsprechenden Account Dateien, die wir dann noch erstellen werden. Zum Schluss sagen wir noch welche Account der default Account ist und beim Start geladen werden soll
macro pager \cb <pipe-entry>'urlview'<enter> 'Follow links with urlview'
auto_view text/html # view html automatically
alternative_order text/plain text/enriched text/html # save html for lastw
source ~/.mutt/colors
source ~/.mutt/gpg.rc
Als nächstes legen wir die Taste fest, mit dem wir Links in Mails folgen, und das wir wollen das HTML Mails mit w3m gerendert werden. Zum Schluss binden wir noch die colors und die gpg Datei ein.
Im folgenden noch ein paar Einstellungen, da alle mit Kommentaren versehen sind, werde ich nicht mehr viel dazu sagen:
set header_cache = ~/.mutt/cache/headers # where to store headers
set message_cachedir = ~/.mutt/cache/bodies # where to store bodies
#set certificate_file = ~/.mutt/certificates # where to store certs
set mailcap_path = ~/.mutt/mailcap # entrys for filetypes
set tmpdir = ~/.mutt/temp # where to keep temp files
set editor = "vim +13 -c 'set nobackup' -c 'set noswapfile' -c 'set nowritebackup' -c 'set tw=72 ft=mail noautoindent'" ft=mail noautoindent'"
set ispell = "/usr/bin/aspell -e -c" # use aspell as ispell
set imap_peek = no # Gmail mark as read
set sleep_time = 0 # instantaneous mailbox change
set timeout = 3 # idle time before scanning
set mail_check = 0 # minimum time between scans
set sort_alias = alias # sort alias file by alias
set reverse_alias # show names from alias file in index
unset move # gmail does that
set delete # don't ask, just do
unset confirmappend # don't ask, just do!
set quit # don't ask, just do!!
unset mark_old # read/new is good enough for me
set beep_new # bell on new mails
set pipe_decode # strip headers and eval mimes when piping
set thorough_search # strip headers and eval mimes before searching
set text_flowed = yes # no hard breaks in quoted text
unset help
set record =+Sent # Gesendet Ordner
set sig_on_top = yes # Signatur am Anfang
# index options
set sort = threads # like gmail
set sort_aux = reverse-last-date-received # like gmail
set uncollapse_jump # don't collapse on an unread message
set sort_re # thread based on regex
#set reply_regexp = "^(([Rr][Ee]?(\[[0-9]+\])?: *)?(\[[^]]+\] *)?)*"
set pager_index_lines = 10 # number of index lines to show
set pager_context = 5 # number of context lines to show
set pager_stop # don't go to next message automatically
set menu_scroll # scroll in menus
set smart_wrap # don't split words
set tilde # show tildes like in vim
unset markers # no ugly plus signs
set quote_regexp = "^( {0,4}[>|:#%]| {0,4}[a-z0-9]+[>|]+)+"
set status_on_top # as you'd expect
set date_format = "%d/%m/%y at %I:%M%P"
#set index_format = "%3C %?X?A& ? %S %D • %-25.25L %s %> %c"
#set pager_format = "Reading message %C of %m %> %lL [%P]" # pager statusbar
#set folder_format = "%2C %t %N %8s %d %f" # mailbox list view
#set status_format = " %?M?%M/?%m Mails %?n?%n new, ?%?u?%u unread, ?%?p?%p drafts, ?%?t?%t +tagged, ?%?d?%d deleted, ?[%f %l] %?b?%b unread messages. ?%> %V [%P]"
##set alias_format = "%4n %t %-20a %r"
set realname = "Malte Kiefer" # who am i?
set envelope_from # which from?
set sig_dashes # dashes before my sig... sweet
set edit_headers # show headers when composing
set fast_reply # skip to compose when replying
set sendmail_wait = -1 # don't wait for sending... to complete
set askcc # ask for CC
set askbcc # and blind CC
set fcc_attach # save attachments with the body
set mime_forward # forward attachments as part of body
set mime_forward_rest # include attachments
set forward_format = "Fwd: %s" # format for subject when forwarding
set forward_decode # decode when forwarding
set attribution = "On %d, %n wrote:" # set the attribution
set reply_to # reply to Reply to: field
set reverse_name # reply as whomever it was to
set include # include message in replies
set forward_quote # include message in forwards
ignore * # ignore all headers
unignore from: to: cc: date: subject: # show only these
hdr_order from: to: cc: date: subject: # and in this order
Wenn man khard als Adressbuch nutzt, kann man am Ende noch das einfügen:
set query_command= "khard email --parsable %s"
bind editor <Tab> complete-query
bind editor ^T complete
So kann man beim Eingeben der Empfängeradresse einfach zwiemal Tab drücken und die Adresse wirde aus dem Adressbuch genommen bzw. gesucht.
my_hdr X-PGP-Key: https://malte-kiefer.de/media/pub_maltekiefer.asc
set user_agent = no
Hier die vollständige Datei:
source "~/.mutt/account.exmaple2"
folder-hook $folder 'source ~/.mutt/example2'
source "~/.mutt/account.example1"
folder-hook $folder 'source ~/.mutt/example1'
macro index <f3> '<sync-mailbox><enter-command>source ~/.mutt/account.example1<enter><change-folder>!<enter>'
macro index <f4> '<sync-mailbox><enter-command>source ~/.mutt/account.example2<enter><change-folder>!<enter>'
macro pager \cb <pipe-entry>'urlview'<enter> 'Follow links with urlview'
auto_view text/html # view html automatically
alternative_order text/plain text/enriched text/html # save html for lastw
set header_cache = ~/.mutt/cache/headers # where to store headers
set message_cachedir = ~/.mutt/cache/bodies # where to store bodies
#set certificate_file = ~/.mutt/certificates # where to store certs
set mailcap_path = ~/.mutt/mailcap # entrys for filetypes
set tmpdir = ~/.mutt/temp # where to keep temp files
set editor = "vim +13 -c 'set nobackup' -c 'set noswapfile' -c 'set nowritebackup' -c 'set tw=72 ft=mail noautoindent'" ft=mail noautoindent'"
set ispell = "/usr/bin/aspell -e -c" # use aspell as ispell
set imap_peek = no # Gmail mark as read
set sleep_time = 0 # instantaneous mailbox change
set timeout = 3 # idle time before scanning
set mail_check = 0 # minimum time between scans
set sort_alias = alias # sort alias file by alias
set reverse_alias # show names from alias file in index
unset move # gmail does that
set delete # don't ask, just do
unset confirmappend # don't ask, just do!
set quit # don't ask, just do!!
unset mark_old # read/new is good enough for me
set beep_new # bell on new mails
set pipe_decode # strip headers and eval mimes when piping
set thorough_search # strip headers and eval mimes before searching
set text_flowed = yes # no hard breaks in quoted text
unset help
set sig_on_top = yes # Signatur am Anfang
# index options
set sort = threads # like gmail
set sort_aux = reverse-last-date-received # like gmail
set uncollapse_jump # don't collapse on an unread message
set sort_re # thread based on regex
#set reply_regexp = "^(([Rr][Ee]?(\[[0-9]+\])?: *)?(\[[^]]+\] *)?)*"
set pager_index_lines = 10 # number of index lines to show
set pager_context = 5 # number of context lines to show
set pager_stop # don't go to next message automatically
set menu_scroll # scroll in menus
set smart_wrap # don't split words
set tilde # show tildes like in vim
unset markers # no ugly plus signs
set quote_regexp = "^( {0,4}[>|:#%]| {0,4}[a-z0-9]+[>|]+)+"
set status_on_top # as you'd expect
set date_format = "%d/%m/%y at %I:%M%P"
#set index_format = "%3C %?X?A& ? %S %D • %-25.25L %s %> %c"
#set pager_format = "Reading message %C of %m %> %lL [%P]" # pager statusbar
#set folder_format = "%2C %t %N %8s %d %f" # mailbox list view
#set status_format = " %?M?%M/?%m Mails %?n?%n new, ?%?u?%u unread, ?%?p?%p drafts, ?%?t?%t +tagged, ?%?d?%d deleted, ?[%f %l] %?b?%b unread messages. ?%> %V [%P]"
##set alias_format = "%4n %t %-20a %r"
set realname = "Malte Kiefer" # who am i?
set envelope_from # which from?
set sig_dashes # dashes before my sig... sweet
set edit_headers # show headers when composing
set fast_reply # skip to compose when replying
set sendmail_wait = -1 # don't wait for sending... to complete
set askcc # ask for CC
set askbcc # and blind CC
set fcc_attach # save attachments with the body
set mime_forward # forward attachments as part of body
set mime_forward_rest # include attachments
set forward_format = "Fwd: %s" # format for subject when forwarding
set forward_decode # decode when forwarding
set attribution = "On %d, %n wrote:" # set the attribution
set reply_to # reply to Reply to: field
set reverse_name # reply as whomever it was to
set include # include message in replies
set forward_quote # include message in forwards
ignore * # ignore all headers
unignore from: to: cc: date: subject: # show only these
hdr_order from: to: cc: date: subject: # and in this order
source ~/.mutt/colors
source ~/.mutt/gpg.rc
set query_command= "khard email --parsable %s"
bind editor <Tab> complete-query
bind editor ^T complete
my_hdr X-PGP-Key: https://malte-kiefer.de/media/pub_maltekiefer.asc
set user_agent = no
Acounts
Jetzt fehlen uns noch die Account Dateien, fangen wir gleich an: account.example1
set from=mail@example.de
set hostname="example.de"
set folder="imaps://mail.example.de/"
set postponed="=Drafts"
set spoolfile="imaps://mail.example.de/INBOX"
set smtp_url="smtps://$imap_user:$imap_pass@mail.example.de:465"
set imap_user="USERNAME"
set imap_pass="PASSWORD"
# SSL hardening
set ssl_force_tls=yes
set ssl_starttls=yes
set ssl_use_sslv3=no
set ssl_use_tlsv1=no
set ssl_use_tlsv1_1=no
set ssl_use_tlsv1_2=yes
set ssl_verify_dates=yes
set ssl_verify_host=yes
Und den Zweiten account.example2
set from=mail@example2.org
set hostname="example2.org"
set folder="imaps://imap.example2.org"
set postponed="=Drafts"
set spoolfile="imaps://imap.example2.org/INBOX"
set smtp_url="smtp://$imap_user:$imap_pass@smtp.example2.org"
set imap_user="USERNAME"
set imap_pass="PASSWORD"
# SSL hardening
set ssl_force_tls=yes
set ssl_starttls=yes
set ssl_use_sslv3=no
set ssl_use_tlsv1=no
set ssl_use_tlsv1_1=no
set ssl_use_tlsv1_2=yes
set ssl_verify_dates=yes
set ssl_verify_host=yes
Nutzung
Durch das eingeben von mutt im Terminal wird das Mailprogramm gestartet. Die erste Übersicht, die ihr seht, nennt man index. Jetzt könnt ihr mit F6 und F7 zwischen den Accounts hin und her springen.
Hier mal die wichtigsten Keys: