<?php

defined('LOC') ? null : define('LOC', dirname(__FILE__));


class mail
{


    public $to;
    public $subject;
    public $message;
    public $from;
    public $fromname;


    public function mailto($to)
    {


        require_once("phpMailer/PHPMailerAutoload.php");
//$mail->SMTPDebug = 3;                               // Enable verbose debug output
        $mail = new PHPMailer;
        $mail->isSMTP();                                      // Set mailer to use SMTP

        $mail->Host = 'mail.oscotechesaoke.edu.ng';  // Specify main and backup SMTP servers
        $mail->SMTPAuth = true;                               // Enable SMTP authentication
        $mail->Username = 'noreply@oscotechesaoke.edu.ng';                 // SMTP username
        $mail->Password = 'P@ssw0rd@2018';                           // SMTP password
        $mail->SMTPSecure = '';                            // Enable TLS encryption, `ssl` also accepted
        $mail->Port = 26;                                    // TCP port to connect to


        $mail->From = $this->from;
        $mail->FromName = $this->fromname;
        $toA = explode(",", $to);
        foreach ($toA as $t) {
            $mail->addAddress($t);               // Name is optional
        }
//        $mail->addReplyTo('info@example.com', 'Information');
//        $mail->addCC('cc@example.com');
//        $file = "../d/newsletter/" . $filename;


//        $mail->addAttachment($file);         // Add attachments
//        $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
        $mail->isHTML(true);                                  // Set email format to HTML

        $mail->Subject = $this->subject;
        $mail->Body = $this->message;
//        $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
        $res = $mail->send();
        if (!$res) {
            echo 'Mailer Error: ' . $mail->ErrorInfo;
        }
        return $res;


    }

}

$mail = new mail();