我正在使用swiftmailer在symfony中創建一個郵件類。我寫郵件類如下:symfony 2沒有找到錯誤類
<?php
namespace Ens\NewBundle\Controller\Services;
class MyMailers
{
public $setTovar='';
public function setToloc($name)
{
$this->setTovar=$name;
}
public function mail()
{
date_default_timezone_set('Asia/Kolkata');
$transport = \Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')
->setUsername('[email protected]')
->setPassword('scientech');
$mailer = \Swift_Mailer::newInstance($transport);
$message = \Swift_Message::newInstance('Wonderful Subject');
$message->setFrom('[email protected]');
$message->setTo($this->setTovar);
$message->setBody('Here is the message itself');
$numSent = $mailer->send($message);
return $numSent;
}
}
和Notification.php
我寫的代碼如下:
//require_once('MyMailers.php');
use Ens\NewBundle\contrller\Services\MyMailers;
function NotificationOnSignUp($z)
{
// echo $z;die;
// $y=unserialize($z);
echo $z;
echo "<pre>";
print_r($z);
echo "</pre>";
$x=new MyMailers;
$x->setToloc($z['to']);
$z=$x->mail();
if($z==1)
$name='success';
else
$name='failed';
當我運行此代碼,然後我得到的錯誤:
Fatal error: Class 'Ens\NewBundle\contrller\Services\MyMailers' not found in /var/www/Symfony/src/Ens/NewBundle/Controller/Services/Notification.php on line 13
我該怎麼辦 ??
錯別字? Ens \ NewBundle \ << < contrller > >> \ Services \ MyMailers – madflow 2012-08-17 09:21:04