User Tools

Site Tools


s-mailx

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
s-mailx [2022/02/07 17:43] – created zilogs-mailx [2022/06/26 15:15] (current) – flagged Gmail config as no longer functional zilog
Line 5: Line 5:
 ===== Documentation and Features ===== ===== Documentation and Features =====
  
-The s-mailx(1) manpage ((use ''$ man s-nail'' to ensure you are reading s-mailx documentation)) is the best place to learn all it'features but the standouts are:+The s-mailx manpage''s-nail(1)''((the s-nail(1) manpage also available in html format on the project's website))is very detailed and the best place to learn about its features but the standouts are:
  
-  * all of Heirloom-mailx features: POP3/IMAP/SMTP, folder hooks, macros, threading, etc.+  * all Heirloom-mailx features: POP3/IMAP/SMTP, folder hooks, macros, threading, etc.
   * Maildir support   * Maildir support
 +  * readline (cmd history)
   * optional coloration   * optional coloration
   * enhanced spam filtering   * enhanced spam filtering
Line 21: Line 22:
  
 ==== Configuration ==== ==== Configuration ====
-The default user configuration file for S-mailx is ''~/.mailrc'', unfortunately also used by the native NetBSD mail(1) client.  If you never plan to use native mail(1) then you can go ahead and put all your settings in ''~/.mailrc'' ; chances are the native mail(1) will just ignore any settings it doesn't understand.  A somewhat better option which maintains settings separation is to create a minimal ''~/.mailrc'' and add the following to it:+Several S-mailx options are pre-set via ''/usr/pkg/etc/s-nail.rc'', the system-wide S-mailx configuration file; worth checking out to see what the defaults are before making customizations. 
 + 
 +The default user configuration file for S-mailx is ''~/.mailrc'' , unfortunately also used by the native NetBSD mail(1) and Heirloom-mailx clients.  If you never plan to use the other clients then you can go ahead and put all your settings in ''~/.mailrc'' ; chances are the native NetBSD mail(1) will just ignore any settings it doesn't understand; Heirloom-mailx likely will complain more.  A somewhat better option which maintains settings separation is to create a minimal ''~/.mailrc'' and add the following to it:
  
 <file ~sdfuser/.mailrc> <file ~sdfuser/.mailrc>
Line 41: Line 44:
 </file> </file>
  
-Note that this technique is also used for the Heirloom mailx client via the NAIL_EXTRA_RC variable; having both ''NAIL_EXTRA_RC'' and ''mailx-extra-rc'' set in ''~sdfuser/.mailrc'' will likely produce ignorable but annoying errors when S-mailx is run.+Note that this technique is also used for the Heirloom mailx client via the NAIL_EXTRA_RC variable; having both ''NAIL_EXTRA_RC'' and ''mailx-extra-rc'' set in ''~sdfuser/.mailrc'' will likely produce ignore-able but fairly annoying errors when S-mailx is run.
  
 <file config ~/.s-nailrc> <file config ~/.s-nailrc>
 ## ~sdfuser/.s-nailrc file - use with /usr/pkg/bin/s-nail ## ~sdfuser/.s-nailrc file - use with /usr/pkg/bin/s-nail
 +
 +# hold mail in system Inbox (default):
 +set hold
  
 # see s-nail(1) for details: # see s-nail(1) for details:
 set v15-compat=yes set v15-compat=yes
 +
 +# set EDITOR if different than default:
 +#set EDITOR=vi
 +
 # allow "dot" EOF; reverse 'r'/'R'; print next msg: # allow "dot" EOF; reverse 'r'/'R'; print next msg:
 set bsdcompat dot flip autoprint set bsdcompat dot flip autoprint
  
-# set some additional headers (must separate w/ commas): +## Mbox settings: 
-set customhdr='Organization: SDF Public Access UNIX System,\ +set from='SDF User <sdfuser@sdf.org>' 
-               Zodiac-SignScorpio'+set reply-to='SDF User <sdfuser@sdf.org>' 
 +# redundant is set in ~/.mailrc: 
 +set folder=mail 
 +# '+' prefix => relative to ~/mail/: 
 +set MBOX=+Save 
 +set record=+Sent 
 +shortcut saved +Save 
 +shortcut sent +Sent 
 + 
 +## automatic MIME type processing: 
 +# pipe all webified msgs thru lynx(1): 
 +set pipe-text/html='?* lynx -stdin -dump -force_html' 
 + 
 +## command aliases: 
 +# use to return from remote accts: 
 +commandalias home 'account null' 
 +# match mail(1) cmd: 
 +commandalias inc 'newmail' 
 +# quiet the 'set' cmd: 
 +commandalias set '\ignerr set' 
 +# thread/unthread cmds: 
 +commandalias thrd 'sort thread' 
 +commandalias uthr 'unsort' 
 + 
 +## email address aliases: 
 +alias snail-list  "S-Mailx List <s-mailx@sdaoden.eu>" 
 + 
 +# group aliases - note: cc/bcc mailings need to have 
 +#                       at least one To: entry 
 +#alias hop-list   hoppy@mud.bog \ 
 +#   mrwarts@mud.bog \ 
 +#   "Kermit <froggy@mud.bog>" 
 + 
 +## SMTP stuff: 
 +# wait until MTA finishes when sending mail. 
 +# => allows seeing any errors: 
 +set sendwait 
 + 
 +### IMAP accounts section: ### 
 + 
 +# Another SDF user account: 
 +account sdfuser2 { 
 +        set hold 
 +        # just because.. 
 +        set ssl-verify-mx.sdf.org=ignore 
 +        set MBOX=+Saved 
 +        set folder=imaps://sdfuser2@mx.sdf.org/ 
 +        set inbox=imaps://sdfuser2@mx.sdf.org/ 
 +        set password-sdfuser2@mx.sdf.org="********" 
 +        set from='SDF User2 <sdfuser2@sdf.org>' 
 +        set record=+Sent 
 +        shortcut saved +Saved 
 +        shortcut sent +Sent 
 +        } 
 + 
 +### note: due to 2022 Gmail policy change this no longer works ### 
 +# Typical Gmail IMAP/SMTP w/ SSL setup (enable IMAP on your acct first)
 +# note use of "URL percent encoded" chars in some settings, i.e. '%40' = '@' 
 +account gmail { 
 +        set hold 
 +        set folder="imaps://gmail.user%40gmail.com@imap.gmail.com/INBOX" 
 +        set inbox="imaps://gmail.user%40gmail.com@imap.gmail.com/INBOX" 
 +        set password-gmail.user%40gmail.com@imap.gmail.com='********' 
 +        set shortcut sent="imaps://gmail.user%40gmail.com@imap.gmail.com/[Gmail]/Sent Mail" 
 +        set shortcut trash="imaps://gmail.user%40gmail.com@imap.gmail.com/[Gmail]/Trash" 
 +        set from='Gmail User <gmail.user@gmail.com>' 
 +        set reply-to='Gmail User <gmail.user@gmail.com>' 
 +        set record=+Sent 
 +        shortcut saved +Saved 
 +        shortcut sent +Sent 
 +        ### Gmail SMTP stuff ### 
 +        # => reserved chars in SMTP pwd need to be URL percent encoded <= 
 +        set mta="smtps://gmail.user%40gmail.com:*********@smtp.gmail.com 
 +        } 
 + 
 +</file> 
 + 
 +===== S-mailx Usage ===== 
 + 
 +Basic usage is essentially identical for all mailx-style clients and so won't be covered here; see the [[traditional_mail_1_mailx_1#getting_started|Documentation]] to get started. 
 + 
 +S-mailx has fairly decent interactive help.  Get a listing of all commands with ''list'', then use ''help <command>'' to see a short synopsis of the command.  Type ''set'' for list of current settings or ''showvar <setting/variable>'' for specific setting.  If one or more errors are reported the ''errors'' commands will provide the details.  S-mailx also has EMACS-style command line editting, i.e. **CTRL+P / CTRL+N** or **⬆ / ⬇** (Up/Down arrow keys) selects prior commands, **CTRL+W** deletes a word, etc. 
 + 
 +==== Remote accounts ==== 
 + 
 +Remote or alternate SDF accounts are accessed via the ''account'' command -- can be abbreviated to ''ac'' Run without an arguement ''acc'' simply lists any configured accounts.  To switch to an account within a S-mailx session use ''ac <acct_name>'' ; to start S-mailx on a specific account from the shell use ''$ s-nail -A <acct_name> [-f <subfolder>]'' For exampleif we have an alternate SDF account named ""sdfuser2"" which has a sub-folder called "Spam" we'd use 
 + 
 +<code>$ s-nail -A sdfuser2 -f +Spam</code> 
 + 
 +Note the "+" ; sub-folders //under// your main mail directory, i.e. //~/mail//, are accessed using ''fi +<subfolder>'' ; use user-configurable shortcuts to make this more convenience, i.e. setting ''shortcut sent +Sent'' allows switching to folder "+Sent" with ''fi sent''
 + 
 +If multiple folders are configured for an account they can usually be listed using the ''folders'' command; to switch folders use ''fi <folder>'' Pretty much all mailx-style clients also support the following shortcuts: 
 + 
 +^  shortcut  ^folder description^ 
 +|  %         | system Inbox     | 
 +|  #         | previous folder 
 +|  &         | account MBOX     | 
 + 
 + 
 +To return to your default account -- the one associated with YOU -- within a S-mailx session use ''account null'' It's handy to create a command alias for this; see the ""comandalias home"" entry in the example configuration file. 
 + 
 +==== Colors and other hacks ==== 
 + 
 +S-mailx can colorize your session experience depending on your terminal's capabilities.  The default SDF TERM value may not be ideal; if you aren't seeing colors try setting TERM to //linux//
 + 
 +Example: 
 +<code file=~sdfuser/.s-nailrc> 
 +# colors: prompt & msg info=teal, headers=green, errors=red: 
 +set colour-pager 
 +if terminal && "$features" =% ,+colour, 
 +        colour iso view-msginfo fg=cyan 
 +        colour iso view-header ft=bold,fg=green (from|date|subject) # regex 
 +        colour iso view-header fg=green 
 +        colour iso mle-prompt fg=cyan 
 +        colour iso mle-error fg=red 
 +endif 
 +</code> 
 + 
 +Note european spelling -- use //colour// See //s-nail(1)// for other possibilities. 
 + 
 +Hacking the prompt: by default the S-mailx prompt is just a **//?//**.  By making use of S-mailx internal variables the prompt can be made more informative.  For example, to display the system path to the active folder: 
 + 
 +<code file=~sdfuser/.s-nailrc> 
 +set prompt='[\$mailbox-resolved] > ' 
 +</code> 
 + 
 +For a local folder, say //~sdfuser/mail/Sent// this might display as 
 + 
 +<code> [/sdf/mail/maildir/s/sdfuser/Sent] > </code> 
 + 
 +Not bad.  However, remote IMAP accounts can look a bit uglier: <code> [imaps://gmail.user%40gmail.com@imap.gmail.com/[Gmail]/Sent Mail] > </code> 
 + 
 +If you are accessing such accounts you're already aware of their type; no need to display the full path.  The following hack checks if variable //acount// is set (only set for remote accounts) and if so, uses a regex expression to filter the contents of the //mailbox-resolved// variable to just display the account and folder names: 
 + 
 +<code file=~sdfuser/.s-nailrc> 
 +# customize prompt 
 +define custom-prompt { 
 +  if -z $'\$account' 
 +    set prompt='[\$mailbox-resolved] > ' 
 +  else 
 +    vput vexpr prompt regex "$mailbox-resolved" ([^/]+)$ '[\$account]:\$1 > ' 
 +  endif 
 +  } 
 +set folder-hook=custom-prompt 
 +</code> 
 + 
 +Now when we switch to our account "gmail" we get something like the following:
  
 +<code>
 +...
 +[gmail]:INBOX > fi sent
 +...
 +[gmail]:Sent Mail > 
 +</code>
  
 +A bit nicer!  The //s-nail(1)// manpage has additional documentation on using ''vput'' and ''vexpr'' Much of S-mailx's functionality depends on the version in use AND whether //v15-compat// is set; S-mailx on another system may not appear to behave the same way.
s-mailx.1644255797.txt.gz · Last modified: 2022/02/07 17:43 by zilog