当前位置: 首页>>代码示例>>PHP>>正文


PHP Message::setHeader方法代码示例

本文整理汇总了PHP中Nette\Mail\Message::setHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::setHeader方法的具体用法?PHP Message::setHeader怎么用?PHP Message::setHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nette\Mail\Message的用法示例。


在下文中一共展示了Message::setHeader方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sendMailConsumer

 public function sendMailConsumer(\PhpAmqpLib\Message\AMQPMessage $message)
 {
     $sendMail = json_decode($message->body);
     $latte = new Latte\Engine();
     $sendMail->templateArr->email = $sendMail->to;
     $sendMail->templateArr->subject = $sendMail->subject;
     if (!is_null($sendMail->unsubscribeLink)) {
         $sendMail->templateArr->unsubscribeLink = $sendMail->unsubscribeLink;
     }
     $mail = new Nette\Mail\Message();
     $mail->setFrom($sendMail->from)->addTo($sendMail->to)->setHtmlBody($latte->renderToString($this->config["appDir"] . $this->config['mailer']['templateDir'] . (is_null($sendMail->template) ? $this->config['mailer']['defaultTemplate'] : $sendMail->template), (array) $sendMail->templateArr));
     if (!is_null($sendMail->unsubscribeEmail) || !is_null($sendMail->unsubscribeLink)) {
         $mail->setHeader('List-Unsubscribe', (!is_null($sendMail->unsubscribeEmail) ? '<mailto:' . $sendMail->unsubscribeEmail . '>' : '') . (!is_null($sendMail->unsubscribeEmail) && !is_null($sendMail->unsubscribeLink) ? ", " : "") . (!is_null($sendMail->unsubscribeLink) ? '<' . $sendMail->unsubscribeLink . '>' : ''), TRUE);
     }
     $mail->setSubject($sendMail->subject);
     try {
         $mailer = $this->emailFactory->getConnection($sendMail->connection);
         $mailer->send($mail);
         dump($sendMail->to);
         if ($sendMail->imapSave) {
             $this->saveToImap($mail->generateMessage(), is_null($sendMail->imapFolder) ? $this->config['imap']['sendFolder'] : $sendMail->imapFolder, $sendMail->imapConnection);
         }
         return TRUE;
     } catch (\Exception $e) {
         return FALSE;
     }
 }
开发者ID:trejjam,项目名称:emailing,代码行数:27,代码来源:Mailer.php

示例2: __construct

 public function __construct($templateDir, IMailer $mailer, ITemplateFactory $templateFactory, LinkGenerator $linkGenerator)
 {
     $this->mailer = $mailer;
     $this->templateDir = $templateDir;
     $this->templateFactory = $templateFactory;
     $this->linkGenerator = $linkGenerator;
     $message = new Nette\Mail\Message();
     $message->setHeader('X-Mailer', NULL);
     // remove Nette Framework from header X-Mailer
     $this->message = $message;
 }
开发者ID:jedenweb,项目名称:mail,代码行数:11,代码来源:Message.php

示例3: send

 function send(Email $email)
 {
     $data = $email->get();
     $mail = new Nette\Mail\Message();
     $mail->setFrom($data->from, $data->fromName)->addReplyTo($data->replyTo, $data->replyToName)->addTo($data->to, $data->toName)->setHtmlBody($data->content);
     foreach ($data->attachments as $v) {
         call_user_func_array([$mail, 'addAttachment'], $v);
     }
     if (isset($data->unsubscribeEmail) || isset($data->unsubscribeLink)) {
         $mail->setHeader('List-Unsubscribe', (isset($data->unsubscribeEmail) ? '<mailto:' . $data->unsubscribeEmail . '>' : '') . (isset($data->unsubscribeEmail) && isset($data->unsubscribeLink) ? ", " : "") . (isset($data->unsubscribeLink) ? '<' . $data->unsubscribeLink . '>' : ''), TRUE);
     }
     $mail->setSubject($this->subjectPrefix . $data->subject);
     $this->mailer->send($mail);
 }
开发者ID:trejjam,项目名称:email,代码行数:14,代码来源:Send.php

示例4: send

 /**
  * Sends e-mail.
  *
  * Implementation of IMailer
  * @param  Message The mail to send (instance of Nette\Message)
  * @return void
  *
  * @throws InvalidStateException if something went wrong
  */
 function send(\Nette\Mail\Message $mail)
 {
     $from = $mail->getHeader('From');
     //intentionally !=
     $from = $from != NULL && !empty($from) ? array_keys($from) : NULL;
     if ($from !== NULL) {
         $this->client->setFrom($from[0]);
     }
     $to = $mail->getHeader('To');
     $cc = $mail->getHeader('Cc');
     $bcc = $mail->getHeader('Bcc');
     $mail->setHeader('Bcc', NULL);
     $recipients = array();
     //intentionally !=
     $to != NULL && !empty($to) ? $recipients = array_merge($recipients, array_keys($to)) : NULL;
     $cc != NULL && !empty($cc) ? $recipients = array_merge($recipients, array_keys($cc)) : NULL;
     $bcc != NULL && !empty($bcc) ? $recipients = array_merge($recipients, array_keys($bcc)) : NULL;
     $this->client->setRecipients($recipients);
     $this->client->setBody($mail->generateMessage());
     //throws InvalidStateException
     $this->client->send();
 }
开发者ID:NorthV,项目名称:nSMTPMailer,代码行数:31,代码来源:SmtpMailer.php


注:本文中的Nette\Mail\Message::setHeader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。