@Thien i got some warning message on my screen when sending email and i cannot figure out whats causing it.
Warning: Phalcon\DI\Injectable::__get(): Access to undefined property AppMail::_transport in C:\Users\spilagan20140973\Desktop\xammp1\htdocs\PHALCON\app\mail\AppMail.php on line 30
AppMail.php
<?php
require_once __DIR__ . '/SwiftMail/swift_required.php';
use \Phalcon\Mvc\User\Component,
\Phalcon\Mvc\View;
class AppMail extends Component{
/*
* sends email after register
*
* @param string $to
* @param string $subject
* @param string $message
*
*/
public function sendMail($to, $subject, $message){
$mailSettings = $this->config->mail;
// Create the message
$message = Swift_Message::newInstance()
->setSubject($subject)
->setTo($to)
->setFrom(array(
$mailSettings->fromEmail => $mailSettings->fromName
))
->setBody($message, 'text/html');
if (!$this->_transport) {
$this->_transport = Swift_SmtpTransport::newInstance(
$mailSettings->smtp->server,
$mailSettings->smtp->port,
$mailSettings->smtp->security
)
->setUsername($mailSettings->smtp->username)
->setPassword($mailSettings->smtp->password);
}
// Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($this->_transport);
return $mailer->send($message);
}
}
i dont know where to find the _transport
method or object and the wierd part is it send the email twice