本文整理汇总了PHP中Swift_Events_SendEvent类的典型用法代码示例。如果您正苦于以下问题:PHP Swift_Events_SendEvent类的具体用法?PHP Swift_Events_SendEvent怎么用?PHP Swift_Events_SendEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Swift_Events_SendEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBeforeSendPerformedWithInvalidMessage
public function testBeforeSendPerformedWithInvalidMessage()
{
$this->event = $this->getMockBuilder(\Swift_Events_SendEvent::class)->disableOriginalConstructor()->getMock();
$this->event->expects($this->any())->method('getMessage')->will($this->returnValue(new \stdClass()));
$this->message->expects($this->never())->method('attachSigner');
$this->plugin->beforeSendPerformed($this->event);
}
示例2: beforeSendPerformed
/**
* @param \Swift_Events_SendEvent $evt
*/
public function beforeSendPerformed(\Swift_Events_SendEvent $evt)
{
$message = $evt->getMessage();
$this->convert($message);
$children = $message->getChildren();
array_walk($children, array($this, 'convert'));
}
示例3: sendPerformed
/**
* Part of the interface which is notified when a message has been sent.
* @param Swift_Events_SendEvent
*/
public function sendPerformed(Swift_Events_SendEvent $e)
{
$recipients = $e->getRecipients();
$failed = $e->getFailedRecipients();
$it = $recipients->getIterator("to");
while ($it->hasNext()) {
$it->next();
$address = $it->getValue();
$pass = !in_array($address->getAddress(), $failed);
$this->getView()->paintResult($address->getAddress(), $pass);
}
$it = $recipients->getIterator("cc");
while ($it->hasNext()) {
$it->next();
$address = $it->getValue();
$pass = !in_array($address->getAddress(), $failed);
$this->getView()->paintResult($address->getAddress(), $pass);
}
$it = $recipients->getIterator("bcc");
while ($it->hasNext()) {
$it->next();
$address = $it->getValue();
$pass = !in_array($address->getAddress(), $failed);
$this->getView()->paintResult($address->getAddress(), $pass);
}
}
示例4: beforeSendPerformed
/**
* Invoked immediately before the Message is sent.
*
* @param Swift_Events_SendEvent $evt
*/
public function beforeSendPerformed(Swift_Events_SendEvent $evt)
{
$this->messages[] = $message = clone $evt->getMessage();
$to = null === $message->getTo() ? '' : implode(', ', array_keys($message->getTo()));
$this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Sending email "%s" to "%s"', $message->getSubject(), $to))));
}
示例5: sendPerformed
public function sendPerformed(\Swift_Events_SendEvent $event)
{
// If this was sent through SES, retrieve the data
if (config('mail.driver') == 'ses') {
$message = $event->getMessage();
$this->updateSesMessageId($message);
}
}
示例6: sendPerformed
/**
* Gestion des messages apres leur envoi
* @param Swift_Events_SendEvent $event [description]
* @return [type] [description]
*/
public function sendPerformed(\Swift_Events_SendEvent $evt)
{
if ($evt->getResult() === \Swift_Events_SendEvent::RESULT_SUCCESS && $this->enabled == true) {
// Création de l'activity
$activity = $this->createActivity($evt->getMessage());
$this->dm->persist($activity);
$this->dm->flush();
}
}
示例7: beforeSendPerformed
/**
* {@inheritdoc}
*/
public function beforeSendPerformed(\Swift_Events_SendEvent $event)
{
$message = $event->getMessage();
if (!$this->isEnabled() || !$message instanceof \Swift_Message || in_array($message->getId(), $this->performed)) {
return;
}
$signature = new \Swift_Signers_DKIMSigner($this->getPrivateKey(), $this->domain, $this->selector);
$message->attachSigner($signature);
$this->performed[] = $message->getId();
}
示例8: sendPerformed
/**
* Invoked immediately after the Message is sent.
*
* @param Swift_Events_SendEvent $evt
*/
public function sendPerformed(Swift_Events_SendEvent $evt)
{
$message = $evt->getMessage();
// restore original headers
$headers = $message->getHeaders();
if ($headers->has('X-Swift-Return-Path')) {
$message->setReturnPath($headers->get('X-Swift-Return-Path')->getAddress());
$headers->removeAll('X-Swift-Return-Path');
}
}
示例9: beforeSendPerformed
/**
* @param \Swift_Events_SendEvent $evt
*/
public function beforeSendPerformed(\Swift_Events_SendEvent $evt)
{
$message = $evt->getMessage();
if ($message->getContentType() === 'text/html' || $message->getContentType() === 'multipart/alternative' && $message->getBody() || $message->getContentType() === 'multipart/mixed' && $message->getBody()) {
$message->setBody($this->converter->convert($message->getBody(), $this->css));
}
foreach ($message->getChildren() as $part) {
if (strpos($part->getContentType(), 'text/html') === 0) {
$part->setBody($this->converter->convert($part->getBody(), $this->css));
}
}
}
示例10: sendPerformed
/**
* Invoked immediately after the Message is sent.
*
* @param \Swift_Events_SendEvent $evt
*/
public function sendPerformed(\Swift_Events_SendEvent $evt)
{
$result = $evt->getResult();
$failed_recipients = $evt->getFailedRecipients();
$message = $evt->getMessage();
if ($result === \Swift_Events_SendEvent::RESULT_SUCCESS) {
$level = $this->levels['sendPerformed.SUCCESS'];
} else {
$level = $this->levels['sendPerformed.NOT_SUCCESS'];
}
$this->log($level, 'MESSAGE (sendPerformed): ', array('result' => $result, 'failed_recipients' => $failed_recipients, 'message' => $message->toString()));
}
示例11: beforeSendPerformed
/**
* Inline the CSS before an email is sent.
*
* @param \Swift_Events_SendEvent $evt
*/
public function beforeSendPerformed(\Swift_Events_SendEvent $evt)
{
$message = $evt->getMessage();
$properTypes = ['text/html', 'multipart/alternative', 'multipart/mixed'];
if ($message->getBody() && in_array($message->getContentType(), $properTypes)) {
$this->inliner->setHtml($message->getBody());
$message->setBody($this->inliner->emogrify());
}
foreach ($message->getChildren() as $part) {
if (strpos($part->getContentType(), 'text/html') === 0) {
$this->inliner->setHtml($part->getBody());
$message->setBody($this->inliner->emogrify());
}
}
}
示例12: beforeSendPerformed
/**
* @param Swift_Events_SendEvent $evt
*/
public function beforeSendPerformed(\Swift_Events_SendEvent $evt)
{
$message = $evt->getMessage();
$converter = new CssToInlineStyles();
$converter->setEncoding($message->getCharset());
$converter->setUseInlineStylesBlock();
$converter->setCleanup();
if ($message->getContentType() === 'text/html' || $message->getContentType() === 'multipart/alternative' && $message->getBody() || $message->getContentType() === 'multipart/mixed' && $message->getBody()) {
$converter->setHTML($message->getBody());
$message->setBody($converter->convert());
}
foreach ($message->getChildren() as $part) {
if (strpos($part->getContentType(), 'text/html') === 0) {
$converter->setHTML($part->getBody());
$part->setBody($converter->convert());
}
}
}
示例13: beforeSendPerformed
/**
* {@inheritdoc}
*/
public function beforeSendPerformed(\Swift_Events_SendEvent $event)
{
$message = $event->getMessage();
if (!$this->isEnabled() || !$message instanceof \Swift_Message || in_array($message->getId(), $this->performed) || null === $message->getBody()) {
return;
}
$dom = new \DOMDocument('1.0', 'utf-8');
$internalErrors = libxml_use_internal_errors(true);
$dom->loadHTML($message->getBody());
libxml_use_internal_errors($internalErrors);
$xpath = new \DOMXPath($dom);
$nodes = $xpath->query('//img/@src');
$images = array();
foreach ($nodes as $node) {
$this->embedImage($message, $node, $images);
}
$message->setBody($dom->saveHTML(), 'text/html');
$this->performed[] = $message->getId();
}
示例14: sendPerformed
/**
* Swift's SendEvent listener.
* Invoked when Swift sends a message
* @param Swift_Events_SendEvent The event information
* @throws Swift_ConnectionException If the connection cannot be rotated
*/
public function sendPerformed(Swift_Events_SendEvent $e)
{
if (!method_exists($e->getSwift()->connection, "nextConnection")) {
throw new Swift_ConnectionException("The ConnectionRotator plugin cannot be used with connections other than Swift_Connection_Rotator.");
}
if (!$this->called) {
$this->used[] = $e->getSwift()->connection->getActive();
}
$this->count++;
if ($this->count >= $this->getThreshold()) {
$e->getSwift()->connection->nextConnection();
if (!in_array($id = $e->getSwift()->connection->getActive(), $this->used)) {
$e->getSwift()->connect();
$this->used[] = $id;
}
$this->count = 0;
}
$this->called = true;
}
示例15: sendPerformed
/**
* Invoked immediately after the Message is sent.
*
* @param Swift_Events_SendEvent $evt
*/
public function sendPerformed(Swift_Events_SendEvent $evt)
{
$this->_restoreMessage($evt->getMessage());
}