本文整理汇总了PHP中Swift_Message::addCc方法的典型用法代码示例。如果您正苦于以下问题:PHP Swift_Message::addCc方法的具体用法?PHP Swift_Message::addCc怎么用?PHP Swift_Message::addCc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Swift_Message
的用法示例。
在下文中一共展示了Swift_Message::addCc方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSend
public function testSend()
{
$message = new Swift_Message();
$message->setFrom('johnny5@example.com', 'Johnny #5');
$message->setSubject('Is alive!');
$message->addTo('you@example.com', 'A. Friend');
$message->addTo('you+two@example.com');
$message->addCc('another+1@example.com');
$message->addCc('another+2@example.com', 'Extra 2');
$message->addBcc('another+3@example.com');
$message->addBcc('another+4@example.com', 'Extra 4');
$message->addPart('<q>Help me Rhonda</q>', 'text/html');
$message->addPart('Doo-wah-ditty.', 'text/plain');
$attachment = Swift_Attachment::newInstance('This is the plain text attachment.', 'hello.txt', 'text/plain');
$attachment2 = Swift_Attachment::newInstance('This is the plain text attachment.', 'hello.txt', 'text/plain');
$attachment2->setDisposition('inline');
$message->attach($attachment);
$message->attach($attachment2);
$message->setPriority(1);
$headers = $message->getHeaders();
$headers->addTextHeader('X-PM-Tag', 'movie-quotes');
$messageId = $headers->get('Message-ID')->getId();
$transport = new PostmarkTransportStub('TESTING_SERVER');
$client = $this->getMock('GuzzleHttp\\Client', array('request'));
$transport->setHttpClient($client);
$o = PHP_OS;
$v = phpversion();
$client->expects($this->once())->method('request')->with($this->equalTo('POST'), $this->equalTo('https://api.postmarkapp.com/email'), $this->equalTo(['headers' => ['X-Postmark-Server-Token' => 'TESTING_SERVER', 'User-Agent' => "swiftmailer-postmark (PHP Version: {$v}, OS: {$o})", 'Content-Type' => 'application/json'], 'json' => ['From' => '"Johnny #5" <johnny5@example.com>', 'To' => '"A. Friend" <you@example.com>,you+two@example.com', 'Cc' => 'another+1@example.com,"Extra 2" <another+2@example.com>', 'Bcc' => 'another+3@example.com,"Extra 4" <another+4@example.com>', 'Subject' => 'Is alive!', 'Tag' => 'movie-quotes', 'TextBody' => 'Doo-wah-ditty.', 'HtmlBody' => '<q>Help me Rhonda</q>', 'Headers' => [['Name' => 'Message-ID', 'Value' => '<' . $messageId . '>'], ['Name' => 'X-PM-KeepID', 'Value' => 'true'], ['Name' => 'X-Priority', 'Value' => '1 (Highest)']], 'Attachments' => [['ContentType' => 'text/plain', 'Content' => 'VGhpcyBpcyB0aGUgcGxhaW4gdGV4dCBhdHRhY2htZW50Lg==', 'Name' => 'hello.txt'], ['ContentType' => 'text/plain', 'Content' => 'VGhpcyBpcyB0aGUgcGxhaW4gdGV4dCBhdHRhY2htZW50Lg==', 'Name' => 'hello.txt', 'ContentID' => 'cid:' . $attachment2->getId()]]]]));
$transport->send($message);
}
示例2: fromWrappedMessage
/**
* @inheritDoc
*/
public static function fromWrappedMessage(MailWrappedMessage $wrappedMessage = null, $transport = null)
{
if (!$wrappedMessage instanceof MailWrappedMessage) {
throw new MailWrapperSetupException('Not MailWrappedMessage');
}
$message = new \Swift_Message();
foreach ($wrappedMessage->getToRecipients() as $address) {
$message->addTo($address);
}
foreach ($wrappedMessage->getCcRecipients() as $address) {
$message->addCc($address);
}
foreach ($wrappedMessage->getBccRecipients() as $address) {
$message->addBcc($address);
}
$message->setReplyTo($wrappedMessage->getReplyTo());
$message->setFrom($wrappedMessage->getFrom());
$message->setSubject($wrappedMessage->getSubject());
if ($wrappedMessage->getContentText()) {
$message->setBody($wrappedMessage->getContentText());
}
if ($wrappedMessage->getContentHtml()) {
$message->setBody($wrappedMessage->getContentHtml(), 'text/html');
}
return $message;
}
示例3: addMailAddresses
/**
* Add email addresses
*
* @param Swift_Message $mail
* @param string $addresses
* @param string $field Address field, can be 'to','cc','bcc'
*/
public function addMailAddresses(&$mail, $addresses, $field = 'to')
{
if (trim($addresses) == '') {
return;
}
$addrs = explode(';', $addresses);
foreach ($addrs as $addr) {
//Reformat standar email "name" <email> to name,email
$addr = str_replace('" <', '"<', $addr);
$addr = str_replace('"<', ',', $addr);
$addr = str_replace('"', '', $addr);
$addr = str_replace('>', '', $addr);
//Fix address format: name,email
if (strpos($addr, ',') === false) {
$addr = ',' . $addr;
}
$tmp = explode(',', $addr);
switch ($field) {
case 'cc':
$mail->addCc($tmp[1], $tmp[0]);
break;
case 'bcc':
$mail->addBcc($tmp[1], $tmp[0]);
break;
default:
$mail->addTo($tmp[1], $tmp[0]);
break;
}
}
}
示例4: addCc
/**
* {@inheritdoc}
*
* @return $this|self
*/
public function addCc($address, $name = null) : self
{
return $this->message->addCc($address, $name);
}
示例5: addCc
public function addCc(Email $email)
{
$this->message->addCc($email->email, $email->name);
return $this;
}
示例6: setupMessageHeaders
/**
* @param \Swift_Message $instance
* @param array $from From addresses. An array of (email-address => name)
* @param array $to To addresses. An array of (email-address => name)
* @param array $cc Cc addresses. An array of (email-address => name) [optional]
* @param array $bcc Bcc addresses. An array of (email-address => name) [optional]
* @param array $replyTo Reply to addresses. An array of (email-address => name) [optional]
*/
protected function setupMessageHeaders($instance, $from, $to, $cc = [], $bcc = [], $replyTo = [])
{
// Add from addresses
foreach ($from as $address => $name) {
$instance->addFrom($address, $name);
}
// Add to addresses
foreach ($to as $address => $name) {
$instance->addTo($address, $name);
}
// Add cc addresses
foreach ($cc as $address => $name) {
$instance->addCc($address, $name);
}
// Add bcc addresses
foreach ($bcc as $address => $name) {
$instance->addBcc($address, $name);
}
// Add reply to addresses
foreach ($replyTo as $address => $name) {
$instance->addReplyTo($address, $name);
}
}