当前位置: 首页>>代码示例>>PHP>>正文


PHP Swift::isConnected方法代码示例

本文整理汇总了PHP中Swift::isConnected方法的典型用法代码示例。如果您正苦于以下问题:PHP Swift::isConnected方法的具体用法?PHP Swift::isConnected怎么用?PHP Swift::isConnected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Swift的用法示例。


在下文中一共展示了Swift::isConnected方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getMailer

 /**
  * This function will return SMTP connection. It will try to load options from 
  * config and if it fails it will use settings from php.ini
  *
  * @param void
  * @return Swift
  */
 static function getMailer()
 {
     $mail_transport_config = config_option('mail_transport', self::MAIL_TRANSPORT_MAIL);
     // Emulate mail() - use NativeMail
     if ($mail_transport_config == self::MAIL_TRANSPORT_MAIL) {
         $mailer = new Swift(new Swift_Connection_NativeMail());
         return $mailer->isConnected() ? $mailer : null;
         // Use SMTP server
     } elseif ($mail_transport_config == self::MAIL_TRANSPORT_SMTP) {
         // Load SMTP config
         $smtp_server = config_option('smtp_server');
         $smtp_port = config_option('smtp_port', 25);
         $smtp_secure_connection = config_option('smtp_secure_connection', self::SMTP_SECURE_CONNECTION_NO);
         $smtp_authenticate = config_option('smtp_authenticate', false);
         if ($smtp_authenticate) {
             $smtp_username = config_option('smtp_username');
             $smtp_password = config_option('smtp_password');
         }
         // if
         switch ($smtp_secure_connection) {
             case self::SMTP_SECURE_CONNECTION_SSL:
                 $transport = SWIFT_SSL;
                 break;
             case self::SMTP_SECURE_CONNECTION_TLS:
                 $transport = SWIFT_TLS;
                 break;
             default:
                 $transport = SWIFT_OPEN;
         }
         // switch
         $mailer = new Swift(new Swift_Connection_SMTP($smtp_server, $smtp_port, $transport));
         if (!$mailer->isConnected()) {
             return null;
         }
         // if
         $mailer->setCharset('UTF-8');
         if ($smtp_authenticate) {
             if ($mailer->authenticate($smtp_username, $smtp_password)) {
                 return $mailer;
             } else {
                 return null;
             }
             // if
         } else {
             return $mailer;
         }
         // if
         // Somethings wrong here...
     } else {
         return null;
     }
     // if
 }
开发者ID:ukd1,项目名称:Project-Pier,代码行数:60,代码来源:Notifier.class.php

示例2: getContent

 function getContent($smtp_server, $smtp_port, $transport, $smtp_username, $smtp_password, $body, $attachments)
 {
     //Load in the files we'll need
     Env::useLibrary('swift');
     switch ($transport) {
         case 'ssl':
             $transport = SWIFT_SSL;
             break;
         case 'tls':
             $transport = SWIFT_TLS;
             break;
         default:
             $transport = 0;
             break;
     }
     //Start Swift
     $mailer = new Swift(new Swift_Connection_SMTP($smtp_server, $smtp_port, $transport));
     if (!$mailer->isConnected()) {
         return false;
     }
     // if
     $mailer->setCharset('UTF-8');
     if ($smtp_username != null) {
         if (!$mailer->authenticate($smtp_username, self::ENCRYPT_DECRYPT($smtp_password))) {
             return false;
         }
     }
     if (!$mailer->isConnected()) {
         return false;
     }
     // add attachments
     $mailer->addPart($body);
     // real body
     if (is_array($attachments) && count($attachments) > 0) {
         foreach ($attachments as $att) {
             $mailer->addAttachment($att["data"], $att["name"], $att["type"]);
         }
     }
     $content = $mailer->getFullContent(false);
     $mailer->close();
     return $content;
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:42,代码来源:MailUtilities.class.php


注:本文中的Swift::isConnected方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。