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)




 
text$       = "This is a simple text message."
 
from$       = "user@diga.me.es"
username$   = "me@diga.me.es"
'password$   = "***********"
recipient$  = "somebody@gmail.com"
server$     = "auth.smtp.1and1.co.uk:25"
subject$    = chr$( 34) +text$          +chr$( 34)  '   Use quotes to allow spaces in text.
message$    = chr$( 34) +"Hello world." +chr$( 34)
attach$     = "a.txt"
logfile$    = "sendemail.log"
 
cmd$ = " -f ";  from$;_             'from
       " -t ";  recipient$;_        'to
       " -u ";  subject$;_          'subject
       " -s ";  server$;_           'server
       " -m ";  message$;_          'message
       " -a ";  attach$;_           'file to attach
       " -l ";  logfile$;_          'file to log result in
       " -xu "; username$         'smtp user name
       '" -xp "; password$           'smtp password not given so will ask in a CMD window
 
run "sendEmail.exe "; cmd$, HIDE
 
end
 