本文整理汇总了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);
}
}