Module System.Mail

This library contains operations for sending emails. The implementation might need to be adapted to the local environment.

Author: Michael Hanus

Version: June 2023

Summary of exported operations:

sendMail :: String -> String -> String -> String -> IO ()  Non-deterministic 
Sends an email via mailx command.
sendMailWithOptions :: String -> String -> [MailOption] -> String -> IO ()  Non-deterministic 
Sends an email via mailx command and various options.
showSendMail :: String -> String -> String -> String -> String  Deterministic 
Shows the text (wth subject, sender, and recipient) of an email to be sent with the command sendMailWithOptions but actually does not send it.
showSendMailWithOptions :: String -> String -> [MailOption] -> String -> String  Deterministic 
Shows the text (wth subject, sender, and recipient) of an email to be sent with the command sendMailWithOptions but actually does not send it.

Exported datatypes:


MailOption

Options for sending emails.

Constructors:

  • CC :: String -> MailOption : recipient of a carbon copy
  • BCC :: String -> MailOption : recipient of a blind carbon copy
  • TO :: String -> MailOption : recipient of the email

Exported operations:

sendMail :: String -> String -> String -> String -> IO ()  Non-deterministic 

Sends an email via mailx command.

Example call:
(sendMail from to subject contents)
Parameters:
  • from : the email address of the sender
  • to : the email address of the recipient
  • subject : the subject of the email
  • contents : the contents of the email

sendMailWithOptions :: String -> String -> [MailOption] -> String -> IO ()  Non-deterministic 

Sends an email via mailx command and various options. Note that multiple options are allowed, e.g., more than one CC option for multiple recipient of carbon copies.

Important note: The implementation of this operation is based on the command "mailx" and must be adapted according to your local environment!

Example call:
(sendMailWithOptions from subject options contents)
Parameters:
  • from : the email address of the sender
  • subject : the subject of the email
  • options : send options, e.g., multiple recipients
  • contents : the contents of the email

showSendMail :: String -> String -> String -> String -> String  Deterministic 

Shows the text (wth subject, sender, and recipient) of an email to be sent with the command sendMailWithOptions but actually does not send it. This is useful for debugging or testing before really sending emails.

Example call:
(showSendMail from to subject contents)
Parameters:
  • from : the email address of the sender
  • to : the email address of the recipient
  • subject : the subject of the email
  • contents : the contents of the email

showSendMailWithOptions :: String -> String -> [MailOption] -> String -> String  Deterministic 

Shows the text (wth subject, sender, and recipient) of an email to be sent with the command sendMailWithOptions but actually does not send it. This is useful for debugging or testing before really sending emails.

Example call:
(showSendMailWithOptions from subject options contents)
Parameters:
  • from : the email address of the sender
  • subject : the subject of the email
  • options : send options, e.g., multiple recipients
  • contents : the contents of the email