本文整理匯總了PHP中Swift_Mailer::sendBatch方法的典型用法代碼示例。如果您正苦於以下問題:PHP Swift_Mailer::sendBatch方法的具體用法?PHP Swift_Mailer::sendBatch怎麽用?PHP Swift_Mailer::sendBatch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Swift_Mailer
的用法示例。
在下文中一共展示了Swift_Mailer::sendBatch方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: send
/**
* Send mail.
*
* @param array $from From address array('john@doe.com' => 'John Doe').
* @param array $to To address 'receiver@domain.org' or array('other@domain.org' => 'A name').
* @param string $subject Subject.
* @param string $body Content body.
* @param array $contentType Content type for body, default 'text/plain'.
* @param array $cc CC to, array('receiver@domain.org', 'other@domain.org' => 'A name').
* @param array $bcc BCC to, array('receiver@domain.org', 'other@domain.org' => 'A name').
* @param array $replyTo Reply to, array('receiver@domain.org', 'other@domain.org' => 'A name').
* @param mixed $altBody Alternate body.
* @param string $altBodyContentType Alternate content type default 'text/html'.
* @param array $header Associative array of headers array('header1' => 'value1', 'header2' => 'value2').
* @param array &$failedRecipients Array.
* @param string $charset Null means leave at default.
* @param array $attachments Array of files.
*
* @return integet
*/
function send(array $from, array $to, $subject, $body, $contentType = 'text/plain', array $cc=null, array $bcc=null, array $replyTo=null, $altBody = null, $altBodyContentType = 'text/html', array $header = array(), &$failedRecipients = array(), $charset=null, array $attachments=array())
{
$message = new Swift_Message($subject, $body, $contentType);
$message->setTo($to);
$message->setFrom($from);
if ($attachments) {
foreach ($attachments as $attachment) {
$message->attach(Swift_Attachment::fromPath($attachment));
}
}
if ($cc) {
$message->setCc($cc);
}
if ($bcc) {
$message->setBcc($bcc);
}
if ($replyTo) {
$message->setReplyTo($replyTo);
}
if ($charset) {
$message->setCharset($charset);
}
if ($altBody) {
$message->addPart($altBody, $altBodyContentType);
}
if ($headers) {
$headers = $message->getHeaders();
foreach ($headers as $key => $value) {
$headers->addTextHeader($key, $value);
}
}
if ($this->serviceManager['swiftmailer.preferences.sendmethod'] == 'normal') {
return $this->mailer->send($message, $failedRecipients);
} else if ($this->serviceManager['swiftmailer.preferences.sendmethod'] == 'single_recipient') {
return $this->mailer->sendBatch($message, $failedRecipients);
}
}