Send email: Difference between revisions

added Fantom example
(added Fantom example)
Line 64:
swap >>body
send-email ;</lang>
 
=={{header|Fantom}}==
 
There's a built-in Email library, which will work on the JVM, CLR and Javascript runtimes. Errors are thrown if there is a problem with the protocol or the network.
 
<lang fantom>
using email
 
class Mail
{
// create a client for sending email - add your own host/username/password
static SmtpClient makeClient ()
{
client := SmtpClient
{
host = "yourhost"
username = "yourusername"
password = "yourpassword"
}
return client
}
 
public static Void main()
{
// create email
email := Email
{
to = ["to@addr"]
from = "from@addr"
cc = ["cc@addr"]
subject = test"
body = TextPart { text = "test email" }
}
 
// create client and send email
makeClient.send (email)
}
}
</lang>
 
=={{header|Java}}==
342

edits