public function sendMail()
{
$transport = Swift_SmtpTransport::newInstance($this->instance, $this->smtp_port);
$transport->setUsername($this->username);
$transport->setPassword($this->user_password);
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance();
$message->setFrom($this->setFrom);
$message->setTo($this->setTo);
$message->setSubject($this->subject);
$message->setBody($this->setBody, 'text/html', 'utf-8');
if (!empty($this->setfilepath)) {
$message->attach(Swift_Attachment::fromPath($this->setfilepath)->setFilename($this->aliasname));
}
/*try{
if($mailer->send($message)){
return true;
}
}
catch (Swift_ConnectionException $e){
//echo 'There was a problem communicating with SMTP: ' . $e->getMessage();
return false;
}*/
return $mailer->send($message);
}