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


PHP Swift::batchSend方法代码示例

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


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

示例1: send

 /**
  * Send an email to a number of recipients
  * Returns the number of successful recipients, or FALSE on failure
  * @param mixed The recipients to send to.  One of string, array, 2-dimensional array or Swift_Address
  * @param mixed The address to send from. string or Swift_Address
  * @param string The message subject
  * @param string The message body, optional
  * @return int
  */
 public function send($recipients, $from, $subject, $body = null)
 {
     $this->addTo($recipients);
     $sender = false;
     if (is_string($from)) {
         $sender = $this->stringToAddress($from);
     } elseif ($from instanceof Swift_Address) {
         $sender = $from;
     }
     if (!$sender) {
         return false;
     }
     $this->message->setSubject($subject);
     if ($body) {
         $this->message->setBody($body);
     }
     try {
         if (!$this->exactCopy && !$this->recipients->getCc() && !$this->recipients->getBcc()) {
             $sent = $this->swift->batchSend($this->message, $this->recipients, $sender);
         } else {
             $sent = $this->swift->send($this->message, $this->recipients, $sender);
         }
         if ($this->autoFlush) {
             $this->flush();
         }
         return $sent;
     } catch (Swift_ConnectionException $e) {
         $this->setError("Sending failed:<br />" . $e->getMessage());
         return false;
     }
 }
开发者ID:darkcolonist,项目名称:kohana234-doctrine115,代码行数:40,代码来源:EasySwift.php

示例2: send

 /**
  * Send an email to a number of recipients
  * Returns the number of successful recipients, or FALSE on failure
  * @param mixed The recipients to send to.  One of string, array, 2-dimensional array or Swift_Address
  * @param mixed The address to send from. string or Swift_Address
  * @param string The message subject
  * @param string The message body, optional
  * @return int
  */
 function send($recipients, $from, $subject, $body = null)
 {
     $this->addTo($recipients);
     $sender = false;
     if (is_string($from)) {
         $sender = $this->stringToAddress($from);
     } elseif (is_a($from, "Swift_Address")) {
         $sender =& $from;
     }
     if (!$sender) {
         return false;
     }
     $this->message->setSubject($subject);
     if ($body) {
         $this->message->setBody($body);
     }
     $sent = 0;
     Swift_Errors::expect($e, "Swift_ConnectionException");
     if (!$this->exactCopy && !$this->recipients->getCc() && !$this->recipients->getBcc()) {
         $sent = $this->swift->batchSend($this->message, $this->recipients, $sender);
     } else {
         $sent = $this->swift->send($this->message, $this->recipients, $sender);
     }
     if (!$e) {
         Swift_Errors::clear("Swift_ConnectionException");
         if ($this->autoFlush) {
             $this->flush();
         }
         return $sent;
     }
     $this->setError("Sending failed:<br />" . $e->getMessage());
     return false;
 }
开发者ID:jeffthestampede,项目名称:excelsior,代码行数:42,代码来源:EasySwift.php

示例3: array


//.........这里部分代码省略.........
         Swift_ClassLoader::load('Swift_Connection_Multi');
         Swift_ClassLoader::load('Swift_Connection_SMTP');
         $pool = new Swift_Connection_Multi();
         // first choose method
         if ($fs->prefs['smtp_server']) {
             $split = explode(':', $fs->prefs['smtp_server']);
             $port = null;
             if (count($split) == 2) {
                 $fs->prefs['smtp_server'] = $split[0];
                 $port = $split[1];
             }
             // connection... SSL, TLS or none
             if ($fs->prefs['email_ssl']) {
                 $smtp = new Swift_Connection_SMTP($fs->prefs['smtp_server'], $port ? $port : SWIFT_SMTP_PORT_SECURE, SWIFT_SMTP_ENC_SSL);
             } else {
                 if ($fs->prefs['email_tls']) {
                     $smtp = new Swift_Connection_SMTP($fs->prefs['smtp_server'], $port ? $port : SWIFT_SMTP_PORT_SECURE, SWIFT_SMTP_ENC_TLS);
                 } else {
                     $smtp = new Swift_Connection_SMTP($fs->prefs['smtp_server'], $port);
                 }
             }
             if ($fs->prefs['smtp_user']) {
                 $smtp->setUsername($fs->prefs['smtp_user']);
                 $smtp->setPassword($fs->prefs['smtp_pass']);
             }
             if (defined('FS_SMTP_TIMEOUT')) {
                 $smtp->setTimeout(FS_SMTP_TIMEOUT);
             }
             $pool->addConnection($smtp);
         } else {
             Swift_ClassLoader::load('Swift_Connection_NativeMail');
             // a connection to localhost smtp server as fallback, discarded if there is no such thing available.
             $pool->addConnection(new Swift_Connection_SMTP());
             $pool->addConnection(new Swift_Connection_NativeMail());
         }
         $swift = new Swift($pool);
         if (isset($data['task_id'])) {
             $swift->attachPlugin(new NotificationsThread($data['task_id'], $emails, $db), 'MessageThread');
         }
         if (defined('FS_MAIL_DEBUG')) {
             $swift->log->enable();
             Swift_ClassLoader::load('Swift_Plugin_VerboseSending');
             $view = new Swift_Plugin_VerboseSending_DefaultView();
             $swift->attachPlugin(new Swift_Plugin_VerboseSending($view), "verbose");
         }
         $message = new Swift_Message($subject, $body);
         // check for reply-to
         if (isset($data['project']) && $data['project']->prefs['notify_reply']) {
             $message->setReplyTo($data['project']->prefs['notify_reply']);
         }
         if (isset($data['project']) && isset($data['project']->prefs['bounce_address'])) {
             $message->setReturnPath($data['project']->prefs['bounce_address']);
         }
         $message->headers->setCharset('utf-8');
         $message->headers->set('Precedence', 'list');
         $message->headers->set('X-Mailer', 'Flyspray');
         // Add custom headers, possibly
         if (isset($data['headers'])) {
             $headers = array_map('trim', explode("\n", $data['headers']));
             if ($headers = array_filter($headers)) {
                 foreach ($headers as $header) {
                     list($name, $value) = explode(':', $header);
                     $message->headers->set(sprintf('X-Flyspray-%s', $name), $value);
                 }
             }
         }
         $recipients = new Swift_RecipientList();
         $recipients->addTo($emails);
         // && $result purpose: if this has been set to false before, it should never become true again
         // to indicate an error
         $result = $swift->batchSend($message, $recipients, $fs->prefs['admin_email']) === count($emails) && $result;
         if (isset($data['task_id'])) {
             $plugin =& $swift->getPlugin('MessageThread');
             if (count($plugin->thread_info)) {
                 $stmt = $db->x->autoPrepare('{notification_threads}', array('task_id', 'recipient_id', 'message_id'));
                 $db->x->executeMultiple($stmt, $plugin->thread_info);
                 $stmt->free();
             }
         }
         $swift->disconnect();
     }
     if (count($jids)) {
         $jids = array_unique($jids);
         if (!$fs->prefs['jabber_username'] || !$fs->prefs['jabber_password']) {
             return $result;
         }
         // nothing that can't be guessed correctly ^^
         if (!$fs->prefs['jabber_port']) {
             $fs->prefs['jabber_port'] = 5222;
         }
         require_once 'class.jabber2.php';
         $jabber = new Jabber($fs->prefs['jabber_username'], $fs->prefs['jabber_password'], $fs->prefs['jabber_security'], $fs->prefs['jabber_port'], $fs->prefs['jabber_server']);
         $jabber->SetResource('flyspray');
         $jabber->login();
         foreach ($jids as $jid) {
             $result = $jabber->send_message($jid, $body, $subject, 'normal') && $result;
         }
     }
     return $result;
 }
开发者ID:negram,项目名称:flyspray,代码行数:101,代码来源:class.notify.php

示例4: send


//.........这里部分代码省略.........
                 						$add_to_subject .= $priority_desc . 'Action Request';
                 						
                 					}
                 					if ($flag_fyi=='1'){
                 						if (!empty($add_to_subject)){
                 							$add_to_subject .= '/';
                 						}
                 						$add_to_subject .= 'FYI';
                 						$body = '<a href="' . assemble_url('project_comment_fyi_read', array('project_id' => $info['project_id'], 'comment_id' => $replacements['comment_id'])) . '">Mark this FYI Notification as Read</a>' . "<br>\n" . $body;
                 					}
                 					if (!empty($add_to_subject)){
                 						$add_to_subject .= ' - ';
                 					}
                 				}
                 				mysql_close($link);
                 	            $subject =  $add_to_subject . $subject;
                 }
                 //EOF:mod
                 //BOF:mod 20111101
                 */
                 //EOF:mod 20111101
                 //BOF:mod 20111110 #493
                 if ($tpl == 'resources/new_comment') {
                     $subject .= ' [CID' . $replacements['comment_id'] . ']';
                 }
                 //EOF:mod 20111110 #493
                 event_trigger('on_prepare_email', array($tpl, $recipient_email, $context, &$body, &$subject, &$attachments, &$language, $replacements['subscribers_name']));
                 // if files need to be attached, message will be multipart
                 if (is_foreachable($attachments)) {
                     $message = new Swift_Message($subject);
                     $message->attach(new Swift_Message_Part($body, 'text/html', EMAIL_ENCODING, EMAIL_CHARSET));
                     foreach ($attachments as $attachment) {
                         $file_path = array_var($attachment, 'path', null);
                         if (file_exists($file_path)) {
                             $message->attach(new Swift_Message_Attachment(new Swift_File($file_path), array_var($attachment, 'name', basename($file_path)), array_var($attachment, 'mime_type', mime_content_type($file_path))));
                         }
                     }
                     // if
                 } else {
                     $message = new Swift_Message($subject, $body, 'text/html', EMAIL_ENCODING, EMAIL_CHARSET);
                 }
                 // if
                 // Load values...
                 if ($mark_as_bulk === null || $empty_return_path === null) {
                     $mark_as_bulk = (bool) ConfigOptions::getValue('mailing_mark_as_bulk');
                     $empty_return_path = (bool) ConfigOptions::getValue('mailing_empty_return_path');
                 }
                 // if
                 // Custom headers (to prevent auto responders)
                 if ($mark_as_bulk) {
                     $message->headers->set('Auto-Submitted', 'auto-generated');
                     $message->headers->set('Precedence', 'bulk');
                 }
                 // if
                 if ($empty_return_path) {
                     $message->headers->set('Return-Path', '<>');
                 } else {
                     $message->headers->set('Return-Path', "<{$from_email}>");
                 }
                 // if
                 if (!isset($to_send[$locale])) {
                     $to_send[$locale] = array('recipients' => new Swift_RecipientList(), 'message' => $message);
                 }
                 //BOF:mod
                 //BOF:mod 20111101
                 /*
                 //EOF:mod 20111101
                 if ($tpl=='resources/new_comment'){
                     $to_send[$locale]['modified_subject'][$recipient_email] =  $subject;
                 }
                 //BOF:mod 20111101
                 */
                 //EOF:mod 20111101
                 //EOF:mod
                 $to_send[$locale]['recipients']->add($recipient_email, $recipient_name);
             }
             // if
         }
         // foreach
         if (is_foreachable($to_send)) {
             foreach ($to_send as $locale => $message_data) {
                 //BOF:mod 20111101
                 /*
                 //EOF:mod 20111101
                 $this->swift->batchSend($message_data['message'], $message_data['recipients'], new Swift_Address($from_email, $from_name), $message_data['modified_subject']);
                 //BOF:mod 20111101
                 */
                 $this->swift->batchSend($message_data['message'], $message_data['recipients'], new Swift_Address($from_email, $from_name));
                 //EOF:mod 20111101
             }
             // foreach
         }
         // if
         return true;
     } else {
         $instance =& ApplicationMailer::instance();
         return $instance->send($to, $tpl, $replacements, $context, $attachments);
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:101,代码来源:ApplicationMailer.class.php

示例5: testBatchSendingDoesNotCopyAllRecipientsInOnASingleEmail

 public function testBatchSendingDoesNotCopyAllRecipientsInOnASingleEmail()
 {
     //Most of this test has been removed due to complexity working out when the commands when be issued. Sorry.
     $conn = new FullMockConnection();
     $conn->setReturnValueAt(0, "read", "220 xxx ESMTP");
     $conn->setReturnValueAt(1, "read", "250-Hello xxx\r\n250 HELP");
     $conn->setReturnValueAt(2, "read", "250 Ok");
     $conn->setReturnValueAt(3, "read", "250 Ok");
     $conn->setReturnValueAt(4, "read", "354 Go ahead");
     $conn->setReturnValueAt(5, "read", "250 ok");
     $conn->setReturnValueAt(6, "read", "250 Ok");
     $conn->setReturnValueAt(7, "read", "250 Ok");
     $conn->setReturnValueAt(8, "read", "354 Go ahead");
     $conn->setReturnValueAt(9, "read", "250 ok");
     $message = new Swift_Message("My Subject", "my body");
     $message->setEncoding("8bit");
     $swift = new Swift($conn, "abc", Swift::ENABLE_LOGGING);
     $recipients = new Swift_RecipientList();
     $recipients->addTo("xxx@yyy.tld", "XXX YYY");
     $recipients->addTo("someone@somewhere.tld");
     $this->assertEqual(2, $swift->batchSend($message, $recipients, new Swift_Address("foo@bar.tld", "Foo Bar")));
 }
开发者ID:Esleelkartea,项目名称:legedia-ESLE,代码行数:22,代码来源:TestOfSwiftCore.php


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