Is this a right way to use/implement an external library into a project? If it's not how do you do it?
class Mail {
protected $mail;
public function __construct(PHPMailer $mail) {
$this->mail = $mail;
$this->mail->isHTML(Config::read('mail.isHtml'));
$this->mail->setFrom(Config::read('mail.fromEmail'), Config::read('mail.fromName'));
}
public function sendMail ( $to, $subject, $body, $plainText ) {
$this->mail->addAddress($to);
$this->mail->Subject = $subject;
$this->mail->Body = $body;
$this->mail->AltBody = $plainText;
$this->mail->send();
}
}
and use it in anywhere in your app like this?
$test = new lib\Mail(new PHPMailer);
$test->sendMail('[email protected]', 'Subject', '<html>Hello username</html>', 'Hello username' );