Swift_SmtpTransport::newInstance PHP 메소드

newInstance() 공개 정적인 메소드

Create a new SmtpTransport instance.
public static newInstance ( string $host = 'localhost', integer $port = 25, string $security = null ) : Swift_SmtpTransport
$host string
$port integer
$security string
리턴 Swift_SmtpTransport
    public static function newInstance($host = 'localhost', $port = 25, $security = null)
    {
        return new self($host, $port, $security);
    }

Usage Example

예제 #1
0
 /**
  * Creates a new Mensaje entity.
  *
  */
 public function createAction(Request $request)
 {
     $entity = new Mensaje();
     $form = $this->createCreateForm($entity);
     $form->handleRequest($request);
     $em = $this->getDoctrine()->getManager();
     $categorias = $em->getRepository('GulloaStoreBackendBundle:Categoria')->findAll();
     if ($form->isValid()) {
         $emailname = 'no.reply.gulloadev';
         $emailpass = '******';
         $transport = \Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, "ssl")->setUsername($emailname)->setPassword($emailpass)->setSourceIp('0.0.0.0');
         $asunto = $entity->getAsunto();
         $datos = $em->getRepository('GulloaStoreBackendBundle:Datos')->find(1);
         $mensaje = $this->renderView('GulloaStoreBackendBundle:Mail:mensaje.html.twig', array('entity' => $entity));
         $message = \Swift_Message::newInstance()->setSubject('[GulloaStore] ' . $asunto)->setFrom('*****@*****.**')->setTo($datos->getEmail())->setBody($mensaje, 'text/html');
         $mailer = \Swift_Mailer::newInstance($transport);
         $mailer->send($message);
         $this->addFlash('mailing', 'Mensaje enviado correctamente');
         $entity->setLeido(0)->setFecha(new \DateTime('now'));
         $em->persist($entity);
         $em->flush();
         return $this->redirect($this->generateUrl('mensaje'));
     }
     return $this->render('GulloaStoreBackendBundle:Tipo:new.html.twig', array('entity' => $entity, 'form' => $form->createView(), 'categorias' => $categorias));
 }
All Usage Examples Of Swift_SmtpTransport::newInstance
Swift_SmtpTransport