本文整理汇总了PHP中Swift_Mime_Message类的典型用法代码示例。如果您正苦于以下问题:PHP Swift_Mime_Message类的具体用法?PHP Swift_Mime_Message怎么用?PHP Swift_Mime_Message使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Swift_Mime_Message类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: send
public function send(\Swift_Mime_Message $message, &$failedRecipients = null)
{
if (in_array('[email protected]', array_keys($message->getTo()))) {
return 0;
}
return 1;
}
开发者ID:modera,项目名称:foundation,代码行数:7,代码来源:MailServiceTest.php
示例2: preSend
/**
* {@inheritDoc}
*/
protected function preSend(\Swift_Mime_Message $message)
{
if (!$message instanceof TemplateMailInterface) {
throw new \RuntimeException('The message must implement the interface Template');
}
$message->setParametersFromMailer($this->getParameters());
$this->generateMessageContent($message);
}
开发者ID:snoob,项目名称:mailer,代码行数:11,代码来源:TemplateMailer.php
示例3: send
public function send(Swift_Mime_Message $message, &$failedRecipients = null)
{
if (!$message->getFrom()) {
if ($from = self::getDefaultFrom()) {
$message->setFrom($from);
}
}
if ($this->wa_set_transport) {
$this->_transport = self::getTransportByEmail(key($message->getFrom()));
}
return parent::send($message, $failedRecipients);
}
开发者ID:Lazary,项目名称:webasyst,代码行数:12,代码来源:waMail.class.php
示例4: send
public function send(\Swift_Mime_Message $message, &$failedRecipients = null)
{
if (!empty(\GO::config()->disable_mail)) {
throw new \Exception("E-mail sending is disabled!");
}
if (\GO::config()->debug) {
$getTo = $message->getTo();
if (!empty($getTo)) {
$getTo = implode(",", array_keys($getTo));
} else {
$getTo = '';
}
\GO::debug("Sending e-mail to " . $getTo);
}
if (\GO::modules()->isInstalled("log")) {
$str = "";
$from = $message->getFrom();
if (!empty($from)) {
$str .= implode(",", array_keys($from));
} else {
$str .= "unknown";
}
$str .= " -> ";
$to = $message->getTo();
if (!empty($to)) {
$str .= implode(",", array_keys($to));
}
$to = $message->getCc();
if (!empty($to)) {
$str .= implode(",", array_keys($to));
}
$to = $message->getBcc();
if (!empty($to)) {
$str .= implode(",", array_keys($to));
}
\GO\Log\Model\Log::create("email", $str);
}
// debug_print_backtrace();
// exit("NO MAIL");
//workaround https://github.com/swiftmailer/swiftmailer/issues/335
$messageId = $message->getId();
$count = parent::send($message, $failedRecipients);
$message->setId($messageId);
// Check if a tmp dir is created to store attachments.
// If so, then remove the tmp dir if the mail is send successfully.
$tmpDir = $message->getTmpDir();
if (!empty($tmpDir)) {
$folder = new \GO\Base\Fs\Folder($tmpDir);
// Check if folder is deleted successfully
if ($folder->delete()) {
\GO::debug('Clear attachments tmp directory: ' . $tmpDir);
} else {
\GO::debug('Failed to clear attachments tmp directory: ' . $tmpDir);
}
}
return $count;
}
开发者ID:ajaboa,项目名称:crmpuan,代码行数:57,代码来源:Mailer.php
示例5: getMIMEPart
/**
* Gets MIME parts that match the message type.
* Excludes parts of type \Swift_Mime_Attachment as those
* are handled later.
*
* @param Swift_Mime_Message $message
* @param string $mimeType
* @return Swift_Mime_MimePart
*/
private function getMIMEPart(\Swift_Mime_Message $message, $mimeType)
{
foreach ($message->getChildren() as $part) {
if (strpos($part->getContentType(), $mimeType) === 0 && !$part instanceof \Swift_Mime_Attachment) {
return $part;
}
}
}
开发者ID:wildbit,项目名称:swiftmailer-postmark,代码行数:17,代码来源:Transport.php
示例6: _restoreMessage
private function _restoreMessage(Swift_Mime_Message $message)
{
// restore original headers
$headers = $message->getHeaders();
if ($headers->has('X-Swift-To')) {
$message->setTo($headers->get('X-Swift-To')->getNameAddresses());
$headers->removeAll('X-Swift-To');
}
if ($headers->has('X-Swift-Cc')) {
$message->setCc($headers->get('X-Swift-Cc')->getNameAddresses());
$headers->removeAll('X-Swift-Cc');
}
if ($headers->has('X-Swift-Bcc')) {
$message->setBcc($headers->get('X-Swift-Bcc')->getNameAddresses());
$headers->removeAll('X-Swift-Bcc');
}
}
开发者ID:JamesLinus,项目名称:platform,代码行数:17,代码来源:RedirectingPlugin.php
示例7: _logSendError
/**
* @param Swift_Mime_Message $message
* @param array|null $failedRecipients
* @param Exception|null $exception
*/
protected function _logSendError(Swift_Mime_Message $message, array $failedRecipients = null, Exception $exception = null)
{
$context = new CM_Log_Context();
$context->setExtra(['message' => ['subject' => $message->getSubject(), 'from' => $message->getFrom(), 'to' => $message->getTo(), 'cc' => $message->getCc(), 'bcc' => $message->getBcc()], 'failedRecipients' => $failedRecipients]);
if ($exception) {
$context->setException($exception);
}
$this->getServiceManager()->getLogger()->error('Failed to send email', $context);
}
开发者ID:cargomedia,项目名称:cm,代码行数:14,代码来源:Mailer.php
示例8: saveToFile
/**
* Save the complete message to the filesystem for testing and debugging
*
* @param Swift_Mime_Message $message the email message to log
* @throws CException if the file system is not writeable
*/
protected function saveToFile(Swift_Mime_Message $message)
{
if (!$this->logDirectory) {
$this->logDirectory = Yii::app()->getRuntimePath() . DIRECTORY_SEPARATOR . "email";
}
if (($logPath = realpath($this->logDirectory)) === false || !is_dir($logPath) || !is_writable($logPath)) {
mkdir($this->logDirectory, 0777, true);
}
$fileName = 'SwiftMailer_' . $_SERVER['REQUEST_TIME'] . '_' . mt_rand() . '.tmp';
$file = $this->logDirectory . DIRECTORY_SEPARATOR . $fileName;
if (!is_writable(dirname($file))) {
throw new CException('Email log directory "' . dirname($file) . '" does not exist or is not writable');
}
if (!file_put_contents($file, quoted_printable_decode($message->toString()))) {
throw new CException('Unable to log mail');
}
}
开发者ID:narwold,项目名称:Small-Potatoes,代码行数:23,代码来源:SYiiMail.php
示例9: restoreMessage
/** Restore a changed message back to its original state */
private function restoreMessage(Swift_Mime_Message $message)
{
if ($this->lastMessage === $message) {
if (isset($this->originalBody)) {
$message->setBody($this->originalBody);
$this->originalBody = null;
}
if (!empty($this->originalHeaders)) {
foreach ($message->getHeaders()->getAll() as $header) {
if (array_key_exists($header->getFieldName(), $this->originalHeaders)) {
$header->setFieldBodyModel($this->originalHeaders[$header->getFieldName()]);
}
}
$this->originalHeaders = array();
}
if (!empty($this->originalChildBodies)) {
$children = (array) $message->getChildren();
foreach ($children as $child) {
$id = $child->getId();
if (array_key_exists($id, $this->originalChildBodies)) {
$child->setBody($this->originalChildBodies[$id]);
}
}
$this->originalChildBodies = array();
}
$this->lastMessage = null;
}
}
开发者ID:tweakers-dev,项目名称:swiftmailer,代码行数:29,代码来源:DecoratorPlugin.php
示例10: send
public function send(Swift_Mime_Message $message, &$failedRecipients = null)
{
$failedRecipients = (array) $failedRecipients;
$msg = '* ' . $message->getSubject() . ' *' . PHP_EOL . PHP_EOL;
if ($message instanceof CM_Mail_Message) {
$msg .= $message->getText() . PHP_EOL;
} else {
$msg .= $message->getBody() . PHP_EOL;
}
$logger = $this->getLogger();
$context = new CM_Log_Context();
$context->setExtra(['type' => CM_Paging_Log_Mail::getTypeStatic(), 'sender' => $message->getSender(), 'replyTo' => $message->getReplyTo(), 'to' => $message->getTo(), 'cc' => $message->getCc(), 'bcc' => $message->getBcc()]);
$logger->addMessage($msg, $this->_logLevel, $context);
return count($message->getTo()) + count($message->getCc()) + count($message->getBcc());
}
开发者ID:cargomedia,项目名称:cm,代码行数:15,代码来源:Log.php
示例11: _doSend
/**
* do send through the API
*
* @param Swift_Mime_Message $message
* @param string[] &$failedRecipients to collect failures by-reference
* @return AWSResponse
*/
protected function _doSend(Swift_Mime_Message $message, &$failedRecipients = null)
{
$date = date('D, j F Y H:i:s O');
if (function_exists('hash_hmac') and in_array('sha1', hash_algos())) {
$hmac = base64_encode(hash_hmac('sha1', $date, $this->AWSSecretKey, true));
} else {
$hmac = $this->calculate_RFC2104HMAC($date, $this->AWSSecretKey);
}
$auth = "AWS3-HTTPS AWSAccessKeyId=" . $this->AWSAccessKeyId . ", Algorithm=HmacSHA1, Signature=" . $hmac;
$host = parse_url($this->endpoint, PHP_URL_HOST);
$path = parse_url($this->endpoint, PHP_URL_PATH);
$fp = fsockopen('ssl://' . $host, 443, $errno, $errstr, 30);
if (!$fp) {
throw new AWSConnectionError("{$errstr} ({$errno})");
}
$socket = new ChunkedTransferSocket($fp, $host, $path);
$socket->header("Date", $date);
$socket->header("X-Amzn-Authorization", $auth);
$socket->write("Action=SendRawEmail&RawMessage.Data=");
$ais = new Swift_AWSInputByteStream($socket);
$message->toByteStream($ais);
$ais->flushBuffers();
$result = $socket->read();
return $result;
}
开发者ID:rhymix,项目名称:rhymix,代码行数:32,代码来源:AWSTransport.php
示例12: getReversePath
/** Determine the best-use reverse path for this message */
private function getReversePath(Swift_Mime_Message $message)
{
$return = $message->getReturnPath();
$sender = $message->getSender();
$from = $message->getFrom();
$path = null;
if (!empty($return)) {
$path = $return;
} elseif (!empty($sender)) {
$keys = array_keys($sender);
$path = array_shift($keys);
} elseif (!empty($from)) {
$keys = array_keys($from);
$path = array_shift($keys);
}
return $path;
}
开发者ID:swiftmailer,项目名称:swiftmailer,代码行数:18,代码来源:MailTransport.php
示例13: send
/**
* Sends the given message.
*
* @param \Swift_Mime_Message $message
* @param string[] $failedRecipients An array of failures by-reference
*
* @return int The number of sent emails
*/
public function send(\Swift_Mime_Message $message, &$failedRecipients = null)
{
$count = count((array) $message->getTo()) + count((array) $message->getCc()) + count((array) $message->getBcc());
return $count;
}
开发者ID:r3h6,项目名称:TYPO3.EXT.mail_spool,代码行数:13,代码来源:TestTransport.php
示例14: _restoreMessage
/** Restore a changed message back to its original state */
private function _restoreMessage(Swift_Mime_Message $message)
{
if ($this->_lastMessage === $message)
{
if (isset($this->_originalBody))
{
$message->setBody($this->_originalBody);
$this->_originalBody = null;
}
if (isset($this->_originalSubject))
{
$message->setSubject($this->_originalSubject);
$this->_originalSubject = null;
}
if (!empty($this->_originalChildBodies))
{
$children = (array) $message->getChildren();
foreach ($children as $child)
{
$id = $child->getId();
if (array_key_exists($id, $this->_originalChildBodies))
{
$child->setBody($this->_originalChildBodies[$id]);
}
}
$this->_originalChildBodies = array();
}
$this->_lastMessage = null;
}
}
开发者ID:nationalfield,项目名称:symfony,代码行数:31,代码来源:DecoratorPlugin.php
示例15: send
/**
* Sends the given message.
*
* @param Swift_Mime_Message $message
* @param string[] $failedRecipients An array of failures by-reference
*
* @return int The number of sent emails
*/
public function send(Swift_Mime_Message $message, &$failedRecipients = null)
{
$hFile = @fopen($this->sLogFile, 'a');
if ($hFile) {
$sTxt = "================== " . date('Y-m-d H:i:s') . " ==================\n";
$sTxt .= $message->toString() . "\n";
@fwrite($hFile, $sTxt);
@fclose($hFile);
}
return parent::send($message, $failedRecipients);
}
开发者ID:leandroborgeseng,项目名称:bhtm,代码行数:19,代码来源:email.class.inc.php
示例16: send
/**
* "Send" the given Message. This transport will add it to a stored collection of sent messages
* for testing purposes and log the message to the system logger.
*
* @param \Swift_Mime_Message $message The message to send
* @param array &$failedRecipients Failed recipients
* @return integer
*/
public function send(\Swift_Mime_Message $message, &$failedRecipients = null)
{
self::$deliveredMessages[] = $message;
$this->systemLogger->log('Sent email to ' . $this->buildStringFromEmailAndNameArray($message->getTo()), LOG_DEBUG, array('message' => $message->toString()));
return count((array) $message->getTo()) + count((array) $message->getCc()) + count((array) $message->getBcc());
}
开发者ID:neos,项目名称:swiftmailer,代码行数:14,代码来源:LoggingTransport.php
示例17: getToAddress
protected function getToAddress(\Swift_Mime_Message $message)
{
return join(',', array_keys($message->getTo()));
}
开发者ID:hyancat,项目名称:aliyun-direct-mail,代码行数:4,代码来源:DirectMailTransport.php
示例18: getMIMEPart
/**
* @param Swift_Mime_Message $message
* @param string $mimeType
* @return Swift_Mime_MimePart
*/
protected function getMIMEPart(\Swift_Mime_Message $message, $mimeType)
{
foreach ($message->getChildren() as $part) {
if (strpos($part->getContentType(), $mimeType) === 0) {
return $part;
}
}
}
开发者ID:gitter-badger,项目名称:postmark,代码行数:13,代码来源:Swift_Transport_PostmarkTransport.php
示例19: restoreMessage
/**
* Restore a changed message back to its original state
*
* @param \Swift_Mime_Message $message
*/
protected function restoreMessage(\Swift_Mime_Message $message)
{
if (count($this->attachments) > 0) {
foreach ($this->attachments as $attachment) {
$message->detach($attachment);
}
$this->attachments = array();
}
}
开发者ID:rollerworks,项目名称:RollerworksMailBundle,代码行数:14,代码来源:AttachmentDecorator.php
示例20: returnZeroWithFailedAddress
public function returnZeroWithFailedAddress(\Swift_Mime_Message $message, &$failedRecipients = null)
{
$failedRecipients[] = $message->getTo();
return 0;
}
开发者ID:azine,项目名称:email-bundle,代码行数:5,代码来源:AzineTwigSwiftMailerTest.php
注:本文中的Swift_Mime_Message类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论