Exemple #1
0
 public function testCanUseAuthenticationExtensionsViaPluginBroker()
 {
     $options = new SmtpOptions(array('connection_class' => 'login'));
     $transport = new Smtp($options);
     $connection = $transport->plugin($options->getConnectionClass(), array(array('username' => 'matthew', 'password' => 'password', 'host' => 'localhost')));
     $this->assertInstanceOf('Zend\\Mail\\Protocol\\Smtp\\Auth\\Login', $connection);
     $this->assertEquals('matthew', $connection->getUsername());
     $this->assertEquals('password', $connection->getPassword());
 }
 public function sendMail($message)
 {
     $smtpOptions = new SmtpOptions();
     $smtpOptions->setHost('smtp.celeste.fr')->setName('smtp.celeste.fr');
     $transport = new Smtp($smtpOptions);
     try {
         $transport->send($message);
     } catch (\Exception $ex) {
     }
 }
 protected function createMessage(array $data)
 {
     $message = new \Zend\Mail\Message();
     $message->setBody($_POST['message']);
     $message->setFrom($_POST['email']);
     $message->setSubject(" contact message ");
     $message->addTo('*****@*****.**');
     $smtpOptions = new \Zend\Mail\Transport\SmtpOptions();
     $smtpOptions->setHost('smtp.gmail.com')->setConnectionClass('login')->setName('smtp.gmail.com')->setConnectionConfig(array('username' => '*****@*****.**', 'password' => 'Yatakafils1', 'ssl' => 'tls'));
     $transport = new \Zend\Mail\Transport\Smtp($smtpOptions);
     $transport->send($message);
 }
 public function contruirCorreo(array $param = null)
 {
     $mail = new Mail\Message();
     $mail->setTo('*****@*****.**', 'Jeisson');
     //de
     $mail->addFrom('*****@*****.**');
     //para
     $mail->setSubject('Clave ingreso');
     //asunto
     $cfg = array('ssl' => 'tls', 'username' => '*****@*****.**', 'password' => 'JeissonB_1989');
     $smtpOption = new Mail\Transport\SmtpOptions();
     $smtpOption->setHost('smtp.gmail.com')->setConnectionClass('login')->setName('smtp.gmail.com')->setConnectionConfig($cfg);
     $smtp = new Mail\Transport\Smtp($smtpOption);
     $smtp->send($mail);
 }
Exemple #5
0
 private function sendMail($data)
 {
     /*
     	      $message = new Message();
               $message->addTo('*****@*****.**')
                       ->addFrom('*****@*****.**')
                       ->setSubject('Сообщение с сайта TARA');
          
     // Setup SMTP transport using LOGIN authentication
               $transport = new SmtpTransport();
               $options   = new SmtpOptions(array(
                       'host'              => 'smtp.gmail.com',
                       'connection_class'  => 'login',
                       'connection_config' => array(
                      'ssl'       => 'tls',
                     //  'username' => '*****@*****.**',
                     //  'password' => 'qwerty7782'
                       'username' => '*****@*****.**',
                       'password' => 'vikabibika0987654321'
     
                 ),
               'port' => 587,
               ));
               $p = $data;
             
                    
               $html = new MimePart($p);
               $html->type = "text/html";
     
               $body = new MimeMessage();
               $body->addPart($html);
     
               $message->setBody($body);
     
               $transport->setOptions($options);
               $transport->send($message);
     */
     $message = new Message();
     $message->setBody($data);
     $message->setFrom('*****@*****.**');
     $message->addTo('*****@*****.**');
     $message->setSubject('Test subject');
     $smtpOptions = new SmtpOptions();
     $smtpOptions->setHost('smtp.gmail.com')->setName('smtp.gmail.com')->setPort(587)->setConnectionClass('login')->setConnectionConfig(array('username' => '*****@*****.**', 'password' => 'vikabibika0987654321', 'ssl' => 'tls'));
     $transport = new SmtpTransport($smtpOptions);
     $transport->send($message);
 }
Exemple #6
0
 public function __construct()
 {
     $registry = Registry::getInstance();
     $this->from = $registry->getConfig("EMAIL_FROM", true);
     $this->host = $registry->getConfig("SMTP_SERVER", false);
     if (strstr($this->host, ':')) {
         $parts = explode(':', $this->host);
         $this->port = array_pop($parts);
         $this->host = implode(':', $parts);
     }
     if ($this->host != '') {
         $options = new SmtpOptions();
         $options->setHost($this->host);
         $options->setPort($this->port);
         $this->transport = new Smtp($options);
     } else {
         $this->transport = new Sendmail();
     }
 }
 protected function sendMail($email, $activation_key)
 {
     $mailText = 'Для подтверждения регистрации войди те на сайт и ввдете это код: ' . $activation_key;
     $mimePart = new Part($mailText);
     $mimePart->type = \Zend\Mime\Mime::TYPE_HTML;
     $mimePart->charset = 'utf-8';
     $body = new MimeMessage();
     $body->setParts([$mimePart]);
     $message = new Message();
     $message->setEncoding('UTF-8');
     $message->setSubject('Aperture: activation key');
     $message->addTo($email);
     $message->addFrom('*****@*****.**', 'Test');
     $message->setBody($body);
     $options = new SmtpOptions();
     $options->setHost('10.10.0.114');
     $options->setPort('2525');
     $transport = new Smtp($options);
     $headers = array('PROJECT' => 'Aperture', 'EMAILS' => '*****@*****.**');
     foreach ($headers as $key => $value) {
         $message->getHeaders()->addHeaderLine($key, $value);
     }
     $transport->send($message);
 }
Exemple #8
0
 function send()
 {
     //第一步: 设置相关的headers
     //1.设置邮件的Content-Type,要不然网站的消息内容里面的html标签会被当做纯文本处理
     $smtpHeaderContentType = new SmtpHeaderContentType();
     $smtpHeaderContentType->setType('text/html');
     //2.设置编码集并添加Content-Type
     $headers = new SmtpHeaders();
     $headers->setEncoding('utf-8');
     $headers->addHeader($smtpHeaderContentType);
     //第二步:设置消息的相关
     $message = new SmtpMessage();
     $message->setHeaders($headers);
     $message->addTo($this->mailTo)->addFrom($this->mailFrom)->setSubject($this->subject)->setBody($this->body);
     //邮件的内容
     //第三步:设置Smtp的相关链接参数
     $smtpOptions = new SmtpOptions();
     $smtpOptions->setHost($this->host)->setPort($this->port)->setConnectionClass('login')->setConnectionConfig(array('username' => $this->username, 'password' => $this->password, 'ssl' => 'ssl'));
     //第四步:加载配置,发送消息
     $smtpTransport = new SmtpTransport();
     $smtpTransport->setOptions($smtpOptions);
     //加载配置
     $smtpTransport->send($message);
     //发送消息
 }