本文整理汇总了PHP中Swift_RecipientList::getBcc方法的典型用法代码示例。如果您正苦于以下问题:PHP Swift_RecipientList::getBcc方法的具体用法?PHP Swift_RecipientList::getBcc怎么用?PHP Swift_RecipientList::getBcc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Swift_RecipientList
的用法示例。
在下文中一共展示了Swift_RecipientList::getBcc方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
*/
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;
}
示例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
*/
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;
}
}
示例3: testAddressesCanBeRemoved
/**
* Test that addresses can be taken back out of the list once added.
*/
public function testAddressesCanBeRemoved()
{
$list = new Swift_RecipientList();
$list->addBcc(new Swift_Address("foo@bar.com"));
$list->addBcc("joe@bloggs.com", "Joe");
$list->addBcc("jim@somewhere.co.uk");
$list->removeBcc("joe@bloggs.com");
$this->assertEqual(array("foo@bar.com", "jim@somewhere.co.uk"), array_keys($list->getBcc()));
}
示例4: send
//.........这里部分代码省略.........
while ($it->hasNext()) {
$it->next();
$address = $it->getValue();
$cc[] = $address->build();
try {
$this->command("RCPT TO: " . $address->build(true), 250);
$tmp_sent++;
} catch (Swift_BadResponseException $e) {
$failed++;
$send_event->addFailedRecipient($address->getAddress());
if ($log->hasLevel(Swift_Log::LOG_FAILURES)) {
$log->addfailedRecipient($address->getAddress());
}
}
}
if ($failed == count($to) + count($cc)) {
$this->reset();
$this->notifyListeners($send_event, "SendListener");
return 0;
}
if (!($has_to = $message->getTo()) && !empty($to)) {
$message->setTo($to);
}
if (!($has_cc = $message->getCc()) && !empty($cc)) {
$message->setCc($cc);
}
$this->command("DATA", 354);
$data = $message->build();
while (false !== ($bytes = $data->read())) {
$this->command($bytes, -1);
}
if ($log->hasLevel(Swift_Log::LOG_NETWORK)) {
$log->add("<MESSAGE DATA>", Swift_Log::COMMAND);
}
try {
$this->command("\r\n.", 250);
$sent += $tmp_sent;
} catch (Swift_BadResponseException $e) {
$failed += $tmp_sent;
}
$tmp_sent = 0;
$has_bcc = $message->getBcc();
$it = $list->getIterator("bcc");
while ($it->hasNext()) {
$it->next();
$address = $it->getValue();
if (!$has_bcc) {
$message->setBcc($address->build());
}
try {
$this->command("MAIL FROM: " . $message->getReturnPath(true), 250);
$this->command("RCPT TO: " . $address->build(true), 250);
$this->command("DATA", 354);
$data = $message->build();
while (false !== ($bytes = $data->read())) {
$this->command($bytes, -1);
}
if ($log->hasLevel(Swift_Log::LOG_NETWORK)) {
$log->add("<MESSAGE DATA>", Swift_Log::COMMAND);
}
$this->command("\r\n.", 250);
$sent++;
} catch (Swift_BadResponseException $e) {
$failed++;
$send_event->addFailedRecipient($address->getAddress());
if ($log->hasLevel(Swift_Log::LOG_FAILURES)) {
$log->addfailedRecipient($address->getAddress());
}
$this->reset();
}
}
$total = count($to) + count($cc) + count($list->getBcc());
$send_event->setNumSent($sent);
$this->notifyListeners($send_event, "SendListener");
if (!$has_return_path) {
$message->setReturnPath("");
}
if (!$has_from) {
$message->setFrom("");
}
if (!$has_to) {
$message->setTo("");
}
if (!$has_reply_to) {
$message->setReplyTo(null);
}
if (!$has_cc) {
$message->setCc(null);
}
if (!$has_bcc) {
$message->setBcc(null);
}
if (!$has_message_id) {
$message->setId(null);
}
if ($log->hasLevel(Swift_Log::LOG_NETWORK)) {
$log->add("Message sent to " . $sent . "/" . $total . " recipients", Swift_Log::NORMAL);
}
return $sent;
}