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


PHP email::mail方法代码示例

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


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

示例1: config

 public static function config($config = array())
 {
     if (!is_array($config)) {
         return false;
     }
     self::$config = $config;
     self::$mail = System::load_sys_class("phpmailer");
     self::$mail->IsSMTP();
     // 启用SMTP
     self::$mail->Host = $config['stmp_host'];
     //SMTP服务器
     self::$mail->SMTPAuth = true;
     //开启SMTP认证
     self::$mail->Username = $config['user'];
     // SMTP用户名
     self::$mail->Password = $config['pass'];
     // SMTP密码
     self::$mail->From = $config['from'];
     //发件人地址
     self::$mail->FromName = $config['fromName'];
     //发件人
     self::$mail->AddReplyTo($config['from'], $config['fromName']);
     //回复地址
     self::$mail->WordWrap = 50;
     //设置每行字符长度
 }
开发者ID:ping199143,项目名称:1ydb,代码行数:26,代码来源:email.class.php

示例2: connect

 /**
  * Creates a SwiftMailer instance.
  *
  * @param   string  DSN connection string
  * @return  object  Swift object
  */
 public static function connect($config = NULL)
 {
     if (!class_exists('Swift', FALSE)) {
         // Load SwiftMailer
         require_once Kohana::find_file('vendor', 'swiftmailer/swift_required');
     }
     // Load default configuration
     $config === NULL and $config = Kohana::config('email');
     switch ($config['driver']) {
         case 'smtp':
             // Set port
             $port = empty($config['options']['port']) ? NULL : (int) $config['options']['port'];
             // Create a SMTP connection
             $connection = Swift_SmtpTransport::newInstance($config['options']['hostname'], $port);
             if (!empty($config['options']['encryption'])) {
                 // Set encryption
                 switch (strtolower($config['options']['encryption'])) {
                     case 'tls':
                     case 'ssl':
                         $connection->setEncryption($config['options']['encryption']);
                         break;
                 }
             }
             // Do authentication, if part of the DSN
             empty($config['options']['username']) or $connection->setUsername($config['options']['username']);
             empty($config['options']['password']) or $connection->setPassword($config['options']['password']);
             if (!empty($config['options']['auth'])) {
                 // Get the class name and params
                 list($class, $params) = arr::callback_string($config['options']['auth']);
                 if ($class === 'PopB4Smtp') {
                     // Load the PopB4Smtp class manually, due to its odd filename
                     require Kohana::find_file('vendor', 'swift/Swift/Authenticator/$PopB4Smtp$');
                 }
                 // Prepare the class name for auto-loading
                 $class = 'Swift_Authenticator_' . $class;
                 // Attach the authenticator
                 $connection->attachAuthenticator($params === NULL ? new $class() : new $class($params[0]));
             }
             // Set the timeout to 5 seconds
             $connection->setTimeout(empty($config['options']['timeout']) ? 5 : (int) $config['options']['timeout']);
             break;
         case 'sendmail':
             // Create a sendmail connection
             $connection = Swift_SendmailTransport::newInstance($config['options']);
             break;
         default:
             // Use the native connection
             $connection = Swift_MailTransport::newInstance();
             break;
     }
     // Create the SwiftMailer instance
     return email::$mail = Swift_Mailer::newInstance($connection);
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:59,代码来源:email.php

示例3: connect

 /**
  * Creates a SwiftMailer instance.
  *
  * @param   string  Config array mirroring format as described in config file
  * @return  object  Swift object
  */
 public static function connect($config = NULL)
 {
     if (!class_exists('Swift', FALSE)) {
         // Load SwiftMailer
         require Kohana::find_file('vendor', 'swift4/lib/swift_required');
         // Register the Swift ClassLoader as an autoload
         Swift::registerAutoload();
     }
     // Load default configuration
     $config === NULL and $config = Kohana::config('email');
     switch ($config['driver']) {
         case 'smtp':
             // Set port
             $port = empty($config['options']['port']) ? NULL : (int) $config['options']['port'];
             //Set host
             $transport = Swift_SmtpTransport::newInstance()->setHost($config['options']['hostname']);
             //Set port if defined
             if ($port) {
                 $transport->setPort($port);
             }
             //Set encryption if defined
             if (!empty($config['options']['encryption'])) {
                 $enc = strtolower($config['options']['encryption']);
                 $transport->setEncryption($enc);
             }
             empty($config['options']['username']) or $transport->setUsername($config['options']['username']);
             empty($config['options']['password']) or $transport->setPassword($config['options']['password']);
             // Set the timeout to 5 seconds
             $mailer = Swift_Mailer::newInstance($transport);
             break;
             //Sendmail
         //Sendmail
         case 'sendmail':
             $op = empty($config['options']) ? null : $config['options'];
             $transport = Swift_SendmailTransport::newInstance($op);
             break;
             //PHP mail :(
         //PHP mail :(
         default:
             $transport = Swift_MailTransport::newInstance();
             break;
     }
     // Create the SwiftMailer instance
     return email::$mail = $mailer;
 }
开发者ID:ninjapenguin,项目名称:Kohana-Swift4-Module,代码行数:51,代码来源:email.php

示例4: connect

 /**
  * Creates a SwiftMailer instance.
  *
  * @param   string  DSN connection string
  * @return  object  Swift object
  */
 public static function connect($config = NULL)
 {
     if (!class_exists('Swift', FALSE)) {
         // Load SwiftMailer
         require Kohana::find_file('vendor', 'swift/Swift');
         // Register the Swift ClassLoader as an autoload
         spl_autoload_register(array('Swift_ClassLoader', 'load'));
     }
     // Load default configuration
     $config === NULL and $config = Kohana::config('email');
     switch ($config['driver']) {
         case 'smtp':
             // Set port
             $port = empty($config['options']['port']) ? NULL : (int) $config['options']['port'];
             if (empty($config['options']['encryption'])) {
                 // No encryption
                 $encryption = Swift_Connection_SMTP::ENC_OFF;
             } else {
                 // Set encryption
                 switch (strtolower($config['options']['encryption'])) {
                     case 'tls':
                         $encryption = Swift_Connection_SMTP::ENC_TLS;
                         break;
                     case 'ssl':
                         $encryption = Swift_Connection_SMTP::ENC_SSL;
                         break;
                 }
             }
             // Create a SMTP connection
             $connection = new Swift_Connection_SMTP($config['options']['hostname'], $port, $encryption);
             // Do authentication, if part of the DSN
             empty($config['options']['username']) or $connection->setUsername($config['options']['username']);
             empty($config['options']['password']) or $connection->setPassword($config['options']['password']);
             if (!empty($config['options']['auth'])) {
                 // Get the class name and params
                 list($class, $params) = arr::callback_string($config['options']['auth']);
                 if ($class === 'PopB4Smtp') {
                     // Load the PopB4Smtp class manually, due to its odd filename
                     require Kohana::find_file('vendor', 'swift/Swift/Authenticator/$PopB4Smtp$');
                 }
                 // Prepare the class name for auto-loading
                 $class = 'Swift_Authenticator_' . $class;
                 // Attach the authenticator
                 $connection->attachAuthenticator($params === NULL ? new $class() : new $class($params[0]));
             }
             // Set the timeout to 5 seconds
             $connection->setTimeout(empty($config['options']['timeout']) ? 5 : (int) $config['options']['timeout']);
             break;
         case 'sendmail':
             // Create a sendmail connection
             $connection = new Swift_Connection_Sendmail(empty($config['options']) ? Swift_Connection_Sendmail::AUTO_DETECT : $config['options']);
             // Set the timeout to 5 seconds
             $connection->setTimeout(5);
             break;
         default:
             // Use the native connection
             $connection = new Swift_Connection_NativeMail($config['options']);
             break;
     }
     // Create the SwiftMailer instance
     return email::$mail = new Swift($connection);
 }
开发者ID:sydlawrence,项目名称:SocialFeed,代码行数:68,代码来源:email.php


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