---
name: "Mail.sendmail"
section: "3kaya"
platform: "linux"
package: "kaya"
version: "0.4.4-6.2"
release: "Debian 8 (Jessie)"
platforms: ["linux"]
url: "https://new.carta.tech/Mail.sendmail"
---

# Mail.sendmail(3kaya)

Send a mail via SMTP

## NAME

Mail::sendmail - Send a mail via SMTP

## SYNOPSIS

**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 from

**whoto** The email address to send the message to

**headers** 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, and **localhost**  will 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).

## DESCRIPTION

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.

## AUTHORS

Kaya standard library by Edwin Brady, Chris Morris and others (kaya@kayalang.org). For further information see http://kayalang.org/

## LICENSE

The Kaya standard library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (version 2.1 or any later version) as published by the Free Software Foundation.
