Void sendmail(String from, String whoto, [Pair<String, String> ] headers, String body, String server="localhost", Int port=25)
Arguments
from: The email address to send the message fromwhoto: The email address to send the message toheaders: A list of name-value pairs for additional mail headers to send: consult RFC 2822 for further details.body: The body of the message.server: The hostname or IP address of the SMTP server (this is optional, andlocalhostwill be used if it is not specified).port: The TCP port on the server to connect to (this is optional and the standard SMTP port of 25 will be used if it is not specified).
Usage
Sends an email via SMTP as specified in the email.
body = "..."; // text of message goes here
headers = [("X-Mailer","Kaya"),
("Subject","Example Message"),
("Cc","example2@kayalang.org")];
sendmail("kaya@kayalang.org","example1@kayalang.org",headers,body);
The To, From and Date headers are set automatically and do not need adding to the headers array. Only the body parameter may contain newlines.
An Exception will be thrown if the header values are invalid, the SMTP server is unavailable, or the SMTP server rejects the message.