<?php

class Mail {

    public function send($to, $text) {
        require MAINPATH . 'Swift/swift_required.php';

        $subject = "Ferchichi Seifeddine | Nouveau Message";

        $transport = Swift_SmtpTransport::newInstance('mail.ferchichi-seifeddine.tn', 26)
                ->setUsername('contact@ferchichi-seifeddine.tn')
                ->setPassword('seifou@123');

        $mailer = Swift_Mailer::newInstance($transport);

        $message = Swift_Message::newInstance($subject)
                ->setFrom(array('contact@ferchichi-seifeddine.tn' => 'Ferchichi Seifeddine'))
                ->setCharset('utf-8')
                ->setContentType('text/plain')
                ->setTo($to)
                ->setBody($text);

        if ($mailer->send($message)) {
            return true;
        }

        return false;
    }

}
