當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Smtp::setOptions方法代碼示例

本文整理匯總了PHP中Zend\Mail\Transport\Smtp::setOptions方法的典型用法代碼示例。如果您正苦於以下問題:PHP Smtp::setOptions方法的具體用法?PHP Smtp::setOptions怎麽用?PHP Smtp::setOptions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend\Mail\Transport\Smtp的用法示例。


在下文中一共展示了Smtp::setOptions方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: flush

 public function flush()
 {
     $this->transport->setOptions($this->getSmtpOptions());
     foreach ($this->queue as $message) {
         $this->transport->send($message);
     }
     $this->queue = [];
 }
開發者ID:andreas-serlo,項目名稱:athene2,代碼行數:8,代碼來源:ZendMailAdapter.php

示例2: createService

 /**
  * Create service
  *
  * @param ServiceLocatorInterface $sm Service manager
  *
  * @return mixed
  */
 public function createService(ServiceLocatorInterface $sm)
 {
     // Load configurations:
     $config = $sm->get('VuFind\\Config')->get('config');
     // Create mail transport:
     $settings = ['host' => $config->Mail->host, 'port' => $config->Mail->port];
     if (isset($config->Mail->username) && isset($config->Mail->password)) {
         $settings['connection_class'] = 'login';
         $settings['connection_config'] = ['username' => $config->Mail->username, 'password' => $config->Mail->password];
         if (isset($config->Mail->secure)) {
             // always set user defined secure connection
             $settings['connection_config']['ssl'] = $config->Mail->secure;
         } else {
             // set default secure connection based on configured port
             if ($settings['port'] == '587') {
                 $settings['connection_config']['ssl'] = 'tls';
             } elseif ($settings['port'] == '487') {
                 $settings['connection_config']['ssl'] = 'ssl';
             }
         }
     }
     $transport = new Smtp();
     $transport->setOptions(new SmtpOptions($settings));
     // Create service:
     return new \VuFind\Mailer\Mailer($transport);
 }
開發者ID:steenlibrary,項目名稱:vufind,代碼行數:33,代碼來源:Factory.php

示例3: getMailerObject

 public static function getMailerObject()
 {
     $response = array();
     $response['mail'] = new Message();
     $response['mail']->setEncoding(APP_CHARSET);
     if (strcasecmp(Config::get('concrete.mail.method'), 'smtp') == 0) {
         $config = array('host' => Config::get('concrete.mail.methods.smtp.server'));
         $username = Config::get('concrete.mail.methods.smtp.username');
         $password = Config::get('concrete.mail.methods.smtp.password');
         if ($username != '') {
             $config['connection_class'] = 'login';
             $config['connection_config'] = array();
             $config['connection_config']['username'] = $username;
             $config['connection_config']['password'] = $password;
         }
         $port = Config::get('concrete.mail.methods.smtp.port', '');
         if ($port != '') {
             $config['port'] = $port;
         }
         $encr = Config::get('concrete.mail.methods.smtp.encryption', '');
         if ($encr != '') {
             $config['connection_config']['ssl'] = $encr;
         }
         $transport = new SmtpTransport();
         $options = new SmtpOptions($config);
         $transport->setOptions($options);
         $response['transport'] = $transport;
     } else {
         $response['transport'] = new SendmailTransport();
     }
     return $response;
 }
開發者ID:WillemAnchor,項目名稱:concrete5,代碼行數:32,代碼來源:Service.php

示例4: send

 protected function send()
 {
     try {
         $message = new Message();
         $para = array_filter(explode(";", str_replace(array(" ", ","), array("", ";"), $this->dados["para"])));
         $message->addTo($para)->addFrom($this->dados["de"]["email"], $this->dados["de"]["nome"])->setSubject($this->dados["assunto"])->addReplyTo($this->dados["replay"]);
         $transport = new SmtpTransport();
         $options = new SmtpOptions(array('host' => 'mail.pessoaweb.com.br', 'connection_class' => 'login', 'connection_config' => array('username' => 'dispatch@pessoaweb.com.br', 'password' => 'd1i2s3p4atch'), 'port' => 587));
         $html = new MimePart($this->dados["body"]);
         $html->type = "text/html";
         $html->charset = "UTF-8";
         $body = new MimeMessage();
         if (isset($this->dados["attachment"])) {
             foreach ($this->dados["attachment"] as $valor) {
                 $attachment = new MimePart($valor["arquivo"]);
                 $attachment->filename = $valor["titulo"];
                 if (isset($valor["tipo"])) {
                     $attachment->type = $valor["tipo"];
                 }
                 $attachment->disposition = Mime::DISPOSITION_ATTACHMENT;
                 $attachment->encoding = Mime::ENCODING_BASE64;
                 $body->setParts(array($attachment));
             }
         }
         $body->addPart($html);
         $message->setBody($body);
         $transport->setOptions($options);
         $transport->send($message);
         return $transport;
     } catch (\Exception $e) {
         debug(array("email" => $e->getMessage()), true);
     }
 }
開發者ID:bhcosta90,項目名稱:zend,代碼行數:33,代碼來源:EmailAbstract.php

示例5: getTransport

 public function getTransport()
 {
     $transport = new SmtpTransport();
     $options = new SmtpOptions(array('name' => 'bitweb.ee', 'host' => 'smtp.gmail.com', 'port' => '25', 'connection_class' => 'login', 'connection_config' => array('ssl' => 'tls', 'username' => 'kristjan.andresson@bitweb.ee', 'password' => 'erkinool123')));
     $transport->setOptions($options);
     return $transport;
 }
開發者ID:kristjanAnd,項目名稱:SimpleIV,代碼行數:7,代碼來源:MailService.php

示例6: createService

 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('Config');
     $transport = new Smtp();
     $transport->setOptions(new SmtpOptions($config['mail']['transport']['options']));
     return $transport;
 }
開發者ID:MajorCaiger,項目名稱:MajorAppsWebsite,代碼行數:7,代碼來源:TransportFactory.php

示例7: sendMail

 /**
  * Sends a mail with the given data from the AppMailAccount
  * @param string $to
  * @param string $subject
  * @param string $content
  */
 public function sendMail(string $to, string $subject, string $content, array $files = [])
 {
     $content .= "\n\nThis is an automated mail. Please don't respond.";
     $text = new Mime\Part($content);
     $text->type = 'text/plain';
     $text->charset = 'utf-8';
     $text->disposition = Mime\Mime::DISPOSITION_INLINE;
     $parts[] = $text;
     foreach ($files as $filePath) {
         $fileContent = file_get_contents($filePath);
         $attachment = new Mime\Part($fileContent);
         $attachment->type = 'image/' . pathinfo($filePath, PATHINFO_EXTENSION);
         $attachment->filename = basename($filePath);
         $attachment->disposition = Mime\Mime::DISPOSITION_ATTACHMENT;
         $attachment->encoding = Mime\Mime::ENCODING_BASE64;
         $parts[] = $attachment;
     }
     $mime = new Mime\Message();
     $mime->setParts($parts);
     $appMailData = $this->getAppMailData();
     $message = new Message();
     $message->addTo($to)->addFrom($appMailData->getAdress())->setSubject($subject)->setBody($mime)->setEncoding('utf-8');
     $transport = new SmtpTransport();
     $options = new SmtpOptions(['name' => $appMailData->getHost(), 'host' => $appMailData->getHost(), 'connection_class' => 'login', 'connection_config' => ['username' => $appMailData->getLogin(), 'password' => $appMailData->getPassword()]]);
     $transport->setOptions($options);
     $transport->send($message);
 }
開發者ID:snowiow,項目名稱:eternaldeztiny,代碼行數:33,代碼來源:AppMailService.php

示例8: __construct

 /**
  * Prepares the \Zend\Mail module
  */
 public function __construct()
 {
     $beehubConfig = \BeeHub::config();
     $config = $beehubConfig['email'];
     if (!empty($config['host'])) {
         // Configure the transporter for sending through SMTP
         $transport = new Mail\Transport\Smtp();
         $emailConfig = array('host' => $config['host']);
         if (!empty($config['port'])) {
             $emailConfig['port'] = $config['port'];
         }
         if (!empty($config['security'])) {
             $emailConfig['connection_config'] = array();
             $emailConfig['connection_config']['ssl'] = $config['security'];
         }
         if (!empty($config['auth_method'])) {
             $emailConfig['connection_class'] = $config['auth_method'];
             if (!isset($emailConfig['connection_config'])) {
                 $emailConfig['connection_config'] = array();
             }
             $emailConfig['connection_config']['username'] = $config['username'];
             $emailConfig['connection_config']['password'] = $config['password'];
         }
         $options = new Mail\Transport\SmtpOptions($emailConfig);
         $transport->setOptions($options);
     } else {
         // Else we use the Sendmail transporter (which actually just uses mail()
         $transport = new Mail\Transport\Sendmail();
     }
     $this->emailer = $transport;
 }
開發者ID:niekbosch,項目名稱:BeeHub,代碼行數:34,代碼來源:BeeHub_Emailer.php

示例9: getTransport

 public function getTransport()
 {
     $transport = new SmtpTransport();
     $options = new SmtpOptions(array('name' => 'localhost.localdomain', 'host' => $this->smtpHost, 'connection_class' => 'login', 'connection_config' => array('username' => $this->smtpUser, 'password' => $this->smtpPass)));
     $transport->setOptions($options);
     return $transport;
 }
開發者ID:KGalley,項目名稱:whathood,代碼行數:7,代碼來源:Email.php

示例10: send

 /**
  * @param Message $message
  */
 public function send(Message $message)
 {
     if (!count($message->getFrom())) {
         $message->setFrom('no-reply@uscaninescentsports.com', 'US Canine Scent Sports');
     }
     $transport = new Transport\Smtp();
     $transport->setOptions($this->transportOptions)->send($message);
 }
開發者ID:PoetikDragon,項目名稱:USCSS,代碼行數:11,代碼來源:MailService.php

示例11: setTransport

 /**
  * set SMTP config
  *
  * @param array $config
  * @return $this
  */
 public function setTransport(array $config)
 {
     $transport = new Smtp();
     $options = new SmtpOptions(array('name' => $config['name'], 'host' => $config['host'], 'connection_class' => $config['login'], 'connection_config' => array('username' => $config['user'], 'password' => $config['pass'])));
     $transport->setOptions($options);
     $this->transport = $transport;
     return $this;
 }
開發者ID:jkhaled,項目名稱:bms,代碼行數:14,代碼來源:EmailService.php

示例12: getServiceConfig

 public function getServiceConfig()
 {
     return array('factories' => array('mail.transport' => function ($serviceManager) {
         $config = $serviceManager->get('Config');
         $transport = new SmtpTransport();
         $transport->setOptions(new SmtpOptions($config['mail']['transport']['options']));
         return $transport;
     }));
 }
開發者ID:andreaszobl,項目名稱:software,代碼行數:9,代碼來源:Module.php

示例13: getServiceConfig

 public function getServiceConfig()
 {
     return array('factories' => array('ZF2Base\\Mail\\Transport' => function ($sm) {
         $config = $sm->get('Config');
         $transport = new SmtpTransport();
         $options = new SmtpOptions($config['mail']);
         $transport->setOptions($options);
         return $transport;
     }));
 }
開發者ID:adaoex,項目名稱:zf2-base,代碼行數:10,代碼來源:Module.php

示例14: sendMail

 public function sendMail()
 {
     $message = new Message();
     $message->addTo('matthew@zend.com')->addFrom('ralph.schindler@zend.com')->setSubject('Greetings and Salutations!')->setBody("Sorry, I’m going to be late today!");
     // Setup SMTP transport using LOGIN authentication
     $transport = new SmtpTransport();
     $options = new SmtpOptions(array('name' => 'localhost.localdomain', 'host' => '127.0.0.1', 'connection_class' => 'login', 'connection_config' => array('username' => 'user', 'password' => 'pass')));
     $transport->setOptions($options);
     $transport->send($message);
 }
開發者ID:brighten01,項目名稱:zf2-openstack-api,代碼行數:10,代碼來源:EmailTool.php

示例15: setSmtp

 public function setSmtp()
 {
     $this->smtp = new Smtp();
     if ($this->checkout == true) {
         $smptOptions = array('host' => $this->config['smtp_host'], 'port' => $this->config['smtp_port'], 'connection_class' => $this->config['smtp_connection_class'], 'connection_config' => array('username' => $this->config['smtp_username'], 'password' => $this->config['smtp_password'], 'ssl' => 'tls'));
         $this->smtp->setOptions(new SmtpOptions($smptOptions));
     } else {
         $this->smtp->setOptions(new SmtpOptions($this->config['transport']['options']));
     }
 }
開發者ID:biialaborg,項目名稱:budocu.com,代碼行數:10,代碼來源:Email.php


注:本文中的Zend\Mail\Transport\Smtp::setOptions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。