Email handling functions used by the Webasyt framework are implemented with the help of the Swift Mailer library (it is included in the standard framework distribution). The following example of creating and sending an email message illustrates all basic methods of this library:

// Creating a message object with recipient $to, sender $from,
// subject $subject, and message text $body
$mail_message = new waMailMessage($subject, $body);

// By default messages are sent in HTML.
// If a text/plain message is necessary, specify it as shown below:
$mail_message = new waMailMessage($subject, $body, 'text/plain');
// Adding the sender
$mail_message->setFrom('', 'Webasyst Robot');
// Specifying the recipient   
$mail_message->setTo('', 'John Doe');
// You can also specify several recipients in the form of an array:
$mail_message->setTo(array('' => 'John Doe'));  
// Adding other recipients
$mail_message->addTo('', 'Big Brother');
$mail_message->addCc('', 'Santa Claus');
$mail_message->addBcc('', 'Ben Johnson');

// Adding an attachment
// $path: full path to a file on the server
// $filename: optional parameter, the filename to be displayed in the message
$mail_message->addAttachment($path, $filename);

// Sending message

Transport setup (SMTP, sendmail)

By default email messages are sent by the mail() function. If you would like to use other transports; e.g., SMTP, you should create file wa-config/mail.php. You can set up use of different transports depending on the current sender (From field).

return array(
    // Specify an email address, a domain name, or default for default setup
    'default' => array(
        'type' => 'smtp',
        'host' => 'YOUR SMTP SERVER',
        'port' => 25,
        //'encryption' => 'ssl',
        //or tls — depending on SMTP server requirements
    // Setup for all based mail boxes
    '' => array(
        'type' => 'mail'
    // Setup for a certain mail box
    '' => array(
        'type' => 'smtp',
        'host' => 'YOUR SMTP SERVER',
        'port' => 25,
        'login' => 'LOGIN NAME',
        'password' => 'PASSWORD',
        //'encryption' => 'ssl',
        //or tls — depending on SMTP server requirements

For sending of email messages the appropriate transport will be automatically selected based on the current sender.