Mutt API
1 Install
setup-mutt!
2 API
mutt
mutt*
email?
pre-email/  c
pre-email*/  c
in-email*
attachment/  c
2.1 Options and Parameters
*mutt-default-subject*
*mutt-default-cc*
*mutt-default-bcc*
*mutt-default-attachment*
*mutt-exe-path*
mutt-logger
3 Typed API
mutt
mutt*
in-email*
email?
*mutt-default-subject*
*mutt-default-cc*
*mutt-default-bcc*
*mutt-default-attachment*
*mutt-exe-path*
Pre-Email
Pre-Email*
4 FAQ
7.0

Mutt API

 (require mutt) package: mutt

Racket API for the Mutt email client.

This package does not support Windows.

Goals:
  • Installing the package configures mutt.

  • Convenient API for sending emails.

Example:
(require mutt)
 
(parameterize ([*mutt-default-cc* '("[email protected]")])
  (mutt "can you hear me?" #:to "[email protected]" #:subject "Hello"))

1 Install

If you delete your ~/.muttrc file, running raco pkg update mutt will rebuild it interactively. Alternatively, the mutt/setup module provides a hook for reconfiguring mutt.

 (require mutt/setup) package: mutt

procedure

(setup-mutt!)  void?

Checks that the mutt utility is available and creates a default ~/.muttrc file if none exists.

This function sends prompts to current-output-port and expects responses on current-input-port.

2 API

procedure

(mutt message    
  #:to to    
  [#:subject subject    
  #:cc cc    
  #:bcc bcc    
  #:attachment attach*])  boolean?
  message : path-string?
  to : email?
  subject : string? = (*mutt-default-subject*)
  cc : pre-email*/c = (*mutt-default-cc*)
  bcc : pre-email*/c = (*mutt-default-bcc*)
  attach* : attachment/c = (*mutt-default-attachment*)
Send an email to the address to with subject subject and message body message. If message is a filename, the email contains the contents of the file. Otherwise, the email contains the string message.

Send carbon copies to the cc addresses; these are public recipients of the same message. Send blind carbon copies to the bcc addresses; the to address will not see the identity of bccs. Attach the files in the list attach*.

Examples:
> (mutt "sry"
        #:to "[email protected]"
        #:subject "We Are Never Ever Getting Back Together")

#t

> (mutt "https://www.youtube.com/watch?v=oHg5SJYRHA0"
        #:to "[email protected]"
        #:subject "10 Craziest YouTube Fails"
        #:cc "[email protected]")

#t

procedure

(mutt* message    
  #:to* to    
  [#:subject subject    
  #:cc cc    
  #:bcc bcc    
  #:attachment attach*])  boolean?
  message : path-string?
  to : pre-email*/c
  subject : string? = (*mutt-default-subject*)
  cc : pre-email*/c = (*mutt-default-cc*)
  bcc : pre-email*/c = (*mutt-default-bcc*)
  attach* : attachment/c = (*mutt-default-attachment*)
For each recipient address in to*, send an identical email message and include the same cc’s, bcc’s, and attachments.

Examples:
> (define pilots
    (for/list ([i (in-range 1 22)])
      (format "[email protected]" i)))
> (mutt* "all my friends are heathens"
         #:to* pilots
         #:subject "helpme")

#t

procedure

(email? str)  (or/c #f string)

  str : string
Returns #f if str does not match a basic regular expression for email addresses.

Examples:

Value that the API can convert to a sequence of email addresses. These are:
  • strings that pass the email? predicate

  • files that contain newline-separated email addresses

Value or sequence that the API can flatten into a sequence of email addresses.

procedure

(in-email* pre*)  (listof email?)

  pre* : pre-email*/c
Coerce a sequence of values into a flat list of email addresses. Ignores strings in pre* that do not pass the email? predicate (but prints a warning to current-output-port). Raises an argument error if pre* contains a path that does not exist on the local filesystem.

Contract for an argument that specifies a file (or files) to attach to an email.

2.1 Options and Parameters

parameter

(*mutt-default-subject*)  string?

(*mutt-default-subject* subject)  void?
  subject : string?
 = "<no-subject>"
Default subject to use in email addresses.

parameter

(*mutt-default-cc*)  (listof email?)

(*mutt-default-cc* addrs)  void?
  addrs : (listof email?)
 = '()
List of addresses to cc by default.

parameter

(*mutt-default-bcc*)  (listof email?)

(*mutt-default-bcc* addrs)  void?
  addrs : (listof email?)
 = '()
List of addresses to bcc by default.

parameter

(*mutt-default-attachment*)  (listof path-string?)

(*mutt-default-attachment* files)  void?
  files : (listof path-string?)
 = '()
List of files to attach by default.

parameter

(*mutt-exe-path*)  (or/c #f path-string?)

(*mutt-exe-path* path)  void?
  path : (or/c #f path-string?)
 = (find-executable-path "mutt")
Path to your Mutt executable. If #f, calls to mutt will never send emails. This is useful for debugging — set the parameter to #false and subscribe to the mutt-logger at the 'info level to see the system commands that would be invoked.

A logger that reports events with the topic 'mutt.

3 Typed API

 (require mutt/typed) package: mutt

Typed clients should import the mutt/typed module.

value

mutt

 : 
(->* [Path-String
      #:to String]
     [#:subject String
      #:cc Pre-Email*
      #:bcc Pre-Email*
      #:attachment (U #f Path-String (Listof Path-String))]
     Boolean)

value

mutt*

 : 
(->* [Path-String
      #:to String]
     [#:subject String
      #:cc Pre-Email*
      #:bcc Pre-Email*
      #:attachment (U #f Path-String (Listof Path-String))]
     Boolean)

value

in-email* : (-> Pre-Email* (Listof String))

value

email? : (-> String (U #f String))

value

*mutt-default-subject* : (Parameterof String)

value

*mutt-default-cc* : (Parameterof (Listof String))

value

*mutt-default-bcc* : (Parameterof (Listof String))

value

*mutt-default-attachment* : (Parameterof (Listof Path-String))

value

*mutt-exe-path* : (Parameterof Path-String)

Type signatures:

4 FAQ

Q. Can racket-mutt accept certificates on the command line?

No. Run mutt on the command line to manually approve certificates. (Make sure to "always accept" the certificate.)