Task

Write a function to send an email.

The function should have parameters for setting From, To and Cc addresses; the Subject, and the message text, and optionally fields for the server name and login details.

 If appropriate, explain what notifications of problems/success are given.
 Solutions using libraries or functions from the language are preferred, but failing that, external programs can be used with an explanation.
 Note how portable the solution given is between operating systems when multi-OS languages are used.


(Remember to obfuscate any sensitive data used in examples)




 
#lang racket
 
;; using sendmail:
(require net/sendmail)
(send-mail-message
 "sender@somewhere.com" "Some Subject"
 '("recipient@elsewhere.com" "recipient2@elsewhere.com")
 '("cc@elsewhere.com")
 '("bcc@elsewhere.com")
 (list "Some lines of text" "go here."))
 
;; and using smtp (and adding more headers here):
(require net/head net/smtp)
(smtp-send-message 
 "192.168.0.1"
 "Sender <sender@somewhere.com>"
 '("Recipient <recipient@elsewhere.com>")
 (standard-message-header
  "Sender <sender@somewhere.com>"
  '("Recipient <recipient@elsewhere.com>")
  '() ; CC
  '() ; BCC
  "Subject")
 '("Hello World!"))
 