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


PHP Message::getFrom方法代码示例

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


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

示例1: send

 /**
  * Send a mail message
  *
  * @param \Zend\Mail\Message $message
  * @return array
  */
 public function send(Mail\Message $message)
 {
     $consumer = new Consumer();
     $consumer->setUrl($this->config['url']);
     $params = array('to' => urlencode($this->config['to']), 'subject' => urlencode($message->getSubject()), 'from' => urlencode($message->getFrom()->current()->getEmail()), 'fromname' => urlencode($message->getFrom()->current()->getName()), 'text' => urlencode($message->getBodyText()), 'api_user' => urlencode($this->config['user']), 'api_key' => urlencode($this->config['key']));
     $bcc = $message->getBcc()->current();
     if ($bcc) {
         $params['bcc'] = $bcc->getEmail();
     }
     $consumer->setParams($params);
     $consumer->setResponseType('json');
     $consumer->setCallType('get');
     return $consumer->doApiCall();
 }
开发者ID:sunshinephp,项目名称:ssp-contact,代码行数:20,代码来源:SspSendGridTransport.php

示例2: add

 /**
  * @param string $queue_name
  * @param \Zend\Mail\Message $mail
  */
 public function add($queue_name, \Zend\Mail\Message $message)
 {
     if (!count($message->getFrom())) {
         $message->addFrom($this->config['default_from']);
     }
     $this->table->add($queue_name, $message);
 }
开发者ID:cobyl,项目名称:ppmodulemailer,代码行数:11,代码来源:Service.php

示例3: sendMail

 public function sendMail(MailMessage $message)
 {
     $from = $message->getFrom();
     if (count($from) == 0) {
         $message->addFrom($this->createSenderAddress());
     }
     $this->transport->send($message);
 }
开发者ID:RiskioFr,项目名称:Mailer,代码行数:8,代码来源:Mailer.php

示例4: send

 /**
  * @param Message $message
  */
 public function send(Message $message)
 {
     if (!count($message->getFrom())) {
         $message->setFrom('no-reply@uscaninescentsports.com', 'US Canine Scent Sports');
     }
     $transport = new Transport\Smtp();
     $transport->setOptions($this->transportOptions)->send($message);
 }
开发者ID:PoetikDragon,项目名称:USCSS,代码行数:11,代码来源:MailService.php

示例5: testCanSetFromListFromAddressList

 public function testCanSetFromListFromAddressList()
 {
     $list = new AddressList();
     $list->add('zf-devteam@zend.com');
     $this->message->addFrom('fw-announce@lists.zend.com');
     $this->message->setFrom($list);
     $from = $this->message->getFrom();
     $this->assertEquals(1, count($from));
     $this->assertFalse($from->has('fw-announce@lists.zend.com'));
     $this->assertTrue($from->has('zf-devteam@zend.com'));
 }
开发者ID:nuklehed,项目名称:zf2,代码行数:11,代码来源:MessageTest.php

示例6: send

 /**
  * {@inheritDoc}
  * @link http://help.postageapp.com/kb/api/send_message
  * @throws Exception\RuntimeException if the mail is sent to more than 50 recipients (Amazon SES limit)
  * @return array The id and UID of the sent message (if sent correctly)
  */
 public function send(Message $message)
 {
     $from = $message->getFrom();
     if (count($from) !== 1) {
         throw new Exception\RuntimeException('Amazon SES requires exactly one from sender');
     }
     $parameters = array('Source' => $from->rewind()->toString(), 'Message' => array('Subject' => array('Data' => $message->getSubject())));
     $textContent = $this->extractText($message);
     if (!empty($textContent)) {
         $parameters['Message']['Body']['Text']['Data'] = $textContent;
     }
     $htmlContent = $this->extractHtml($message);
     if (!empty($htmlContent)) {
         $parameters['Message']['Body']['Html']['Data'] = $htmlContent;
     }
     $countRecipients = count($message->getTo());
     $to = array();
     foreach ($message->getTo() as $address) {
         $to[] = $address->toString();
     }
     $parameters['Destination']['ToAddresses'] = $to;
     $countRecipients += count($message->getCc());
     $cc = array();
     foreach ($message->getCc() as $address) {
         $cc[] = $address->toString();
     }
     $parameters['Destination']['CcAddresses'] = $cc;
     $countRecipients += count($message->getBcc());
     $bcc = array();
     foreach ($message->getBcc() as $address) {
         $bcc[] = $address->toString();
     }
     $parameters['Destination']['BccAddresses'] = $bcc;
     if ($countRecipients > self::RECIPIENT_LIMIT) {
         throw new Exception\RuntimeException(sprintf('You have exceeded limitation for Amazon SES count recipients (%s maximum, %s given)', self::RECIPIENT_LIMIT, $countRecipients));
     }
     $replyTo = array();
     foreach ($message->getReplyTo() as $address) {
         $replyTo[] = $address->toString();
     }
     $parameters['ReplyToAddresses'] = $replyTo;
     try {
         return $this->client->sendEmail($this->filterParameters($parameters))->toArray();
     } catch (SesException $exception) {
         $this->parseException($exception);
     }
 }
开发者ID:misarji,项目名称:ez-mail,代码行数:53,代码来源:SesService.php

示例7: send

 /**
  * {@inheritDoc}
  * @link http://help.postageapp.com/kb/api/send_message
  * @return array The id and UID of the sent message (if sent correctly)
  */
 public function send(Message $message)
 {
     $from = $message->getFrom();
     if (count($from) !== 1) {
         throw new Exception\RuntimeException('Postage API requires exactly one from sender');
     }
     if (count($message->getCc())) {
         throw new Exception\RuntimeException('Postage does not support CC addresses');
     }
     if (count($message->getBcc())) {
         throw new Exception\RuntimeException('Postage does not support BCC addresses');
     }
     $parameters = array('uid' => sha1(json_encode(uniqid())), 'arguments' => array('headers' => array('subject' => $message->getSubject(), 'from' => $from->rewind()->toString()), 'content' => array('text/plain' => $this->extractText($message), 'text/html' => $this->extractHtml($message))));
     $to = array();
     foreach ($message->getTo() as $address) {
         $to[] = $address->toString();
     }
     $parameters['arguments']['recipients'] = implode(',', $to);
     $replyTo = $message->getReplyTo();
     if (count($replyTo) > 1) {
         throw new Exception\RuntimeException('Postage has only support for one Reply-To address');
     } elseif (count($replyTo)) {
         $parameters['headers']['reply-to'] = $replyTo->rewind()->toString();
     }
     if ($message instanceof PostageMessage) {
         if ($message->getTemplate() !== '') {
             $parameters['arguments']['template'] = $message->getTemplate();
             $parameters['arguments']['variables'] = $message->getVariables();
         }
     }
     $attachments = $this->extractAttachments($message);
     foreach ($attachments as $attachment) {
         $parameters['arguments']['attachments'][$attachment->filename] = array('content_type' => $attachment->type, 'content' => base64_encode($attachment->getRawContent()));
     }
     $response = $this->prepareHttpClient('/send_message.json', $parameters)->send();
     $data = $this->parseResponse($response);
     return array('uid' => $parameters['uid'], 'id' => $data['message']['id']);
 }
开发者ID:erik-maas,项目名称:SlmMail,代码行数:43,代码来源:PostageService.php

示例8: send

 /**
  * {@inheritDoc}
  * @link   http://elasticemail.com/api-documentation/send
  * @return string The transaction id of the email
  */
 public function send(Message $message)
 {
     $from = $message->getFrom();
     if (count($from) !== 1) {
         throw new Exception\RuntimeException('Elastic Email API requires exactly one from sender');
     }
     $parameters = array('from' => $from->rewind()->getEmail(), 'from_name' => $from->rewind()->getName(), 'subject' => $message->getSubject(), 'body_text' => $this->extractText($message), 'body_html' => $this->extractHtml($message));
     $to = array();
     foreach ($message->getTo() as $address) {
         $to[] = $address->toString();
     }
     foreach ($message->getCc() as $address) {
         $to[] = $address->toString();
     }
     // Elastic Email treats Bcc exactly as To addresses (they are treated separately)
     foreach ($message->getBcc() as $address) {
         $to[] = $address->toString();
     }
     $parameters['to'] = implode(';', $to);
     $replyTo = $message->getReplyTo();
     if (count($replyTo) > 1) {
         throw new Exception\RuntimeException('Elastic Email has only support for one Reply-To address');
     } elseif (count($replyTo)) {
         $parameters['reply_to'] = $replyTo->rewind()->getEmail();
         $parameters['reply_to_name'] = $replyTo->rewind()->getName();
     }
     if ($message instanceof ElasticEmailMessage) {
         $parameters['channel'] = $message->getChannel();
         $parameters['template'] = $message->getTemplate();
     }
     // Attachments are handled using a very strange way in Elastic Email. They must first be uploaded
     // to their API and THEN appended here. Therefore, you should limit how many attachments you have
     $attachmentIds = array();
     $attachments = $this->extractAttachments($message);
     foreach ($attachments as $attachment) {
         $attachmentIds[] = $this->uploadAttachment($attachment);
     }
     if (count($attachmentIds)) {
         $parameters['attachments'] = implode(';', $attachmentIds);
     }
     $response = $this->prepareHttpClient('/mailer/send', $parameters)->send();
     return $this->parseResponse($response);
 }
开发者ID:misarji,项目名称:ez-mail,代码行数:48,代码来源:ElasticEmailService.php

示例9: send

 /**
  * {@inheritDoc}
  * @link http://developer.postmarkapp.com/developer-build.html
  * @throws Exception\RuntimeException if the mail is sent to more than 20 recipients (Postmark limit)
  * @return array The id and UID of the sent message (if sent correctly)
  */
 public function send(Message $message)
 {
     $from = $message->getFrom();
     if (count($from) !== 1) {
         throw new Exception\RuntimeException('Postmark API requires exactly one from sender');
     }
     $parameters = array('From' => $from->rewind()->toString(), 'Subject' => $message->getSubject(), 'TextBody' => $this->extractText($message), 'HtmlBody' => $this->extractHtml($message));
     $countRecipients = count($message->getTo());
     $to = array();
     foreach ($message->getTo() as $address) {
         $to[] = $address->toString();
     }
     $parameters['To'] = implode(',', $to);
     $countRecipients += count($message->getCc());
     $cc = array();
     foreach ($message->getCc() as $address) {
         $cc[] = $address->toString();
     }
     $parameters['Cc'] = implode(',', $cc);
     $countRecipients += count($message->getBcc());
     $bcc = array();
     foreach ($message->getBcc() as $address) {
         $bcc[] = $address->toString();
     }
     $parameters['Bcc'] = implode(',', $bcc);
     if ($countRecipients > self::RECIPIENT_LIMIT) {
         throw new Exception\RuntimeException(sprintf('You have exceeded limitation for Postmark count recipients (%s maximum, %s given)', self::RECIPIENT_LIMIT, $countRecipients));
     }
     $replyTo = $message->getReplyTo();
     if (count($replyTo) > 1) {
         throw new Exception\RuntimeException('Postmark has only support for one Reply-To address');
     } elseif (count($replyTo)) {
         $parameters['ReplyTo'] = $replyTo->rewind()->toString();
     }
     if ($message instanceof PostmarkMessage) {
         if ($message->getTag()) {
             $parameters['Tag'] = $message->getTag();
         }
     }
     $attachments = $this->extractAttachments($message);
     foreach ($attachments as $attachment) {
         $parameters['Attachments'][] = array('Name' => $attachment->filename, 'ContentType' => $attachment->type, 'Content' => base64_encode($attachment->getRawContent()));
     }
     $response = $this->prepareHttpClient('/email')->setMethod(HttpRequest::METHOD_POST)->setRawBody(json_encode($this->filterParameters($parameters)))->send();
     return $this->parseResponse($response);
 }
开发者ID:erik-maas,项目名称:SlmMail,代码行数:52,代码来源:PostmarkService.php

示例10: prepareParameters

 /**
  * Prepare additional_parameters argument
  *
  * Basically, overrides the MAIL FROM envelope with either the Sender or
  * From address.
  *
  * @param  \Zend\Mail\Message $message
  * @return string
  */
 protected function prepareParameters(Mail\Message $message)
 {
     if ($this->isWindowsOs()) {
         return null;
     }
     $parameters = (string) $this->parameters;
     $sender = $message->getSender();
     if ($sender instanceof AddressInterface) {
         $parameters .= ' -f ' . $sender->getEmail();
         return $parameters;
     }
     $from = $message->getFrom();
     if (count($from)) {
         $from->rewind();
         $sender = $from->current();
         $parameters .= ' -f ' . $sender->getEmail();
         return $parameters;
     }
     return $parameters;
 }
开发者ID:eltondias,项目名称:Relogio,代码行数:29,代码来源:Sendmail.php

示例11: parseMessage

 /**
  * @param  Message       $message
  * @param  DateTime|null $sendAt
  * @throws Exception\RuntimeException
  * @return array
  */
 private function parseMessage(Message $message, DateTime $sendAt = null)
 {
     $hasTemplate = $message instanceof MandrillMessage && null !== $message->getTemplate();
     $from = $message->getFrom();
     if ($hasTemplate && count($from) > 1 || !$hasTemplate && count($from) !== 1) {
         throw new Exception\RuntimeException('Mandrill API requires exactly one from sender (or none if send with a template)');
     }
     $from = $from->rewind();
     $parameters['message'] = array('subject' => $message->getSubject(), 'text' => $this->extractText($message), 'html' => $this->extractHtml($message), 'from_email' => $from ? $from->getEmail() : '', 'from_name' => $from ? $from->getName() : '');
     foreach ($message->getTo() as $to) {
         $parameters['message']['to'][] = array('email' => $to->getEmail(), 'name' => $to->getName(), 'type' => 'to');
     }
     foreach ($message->getCc() as $cc) {
         $parameters['message']['to'][] = array('email' => $cc->getEmail(), 'name' => $cc->getName(), 'type' => 'cc');
     }
     foreach ($message->getBcc() as $bcc) {
         $parameters['message']['to'][] = array('email' => $bcc->getEmail(), 'name' => $bcc->getName(), 'type' => 'bcc');
     }
     $replyTo = $message->getReplyTo();
     if (count($replyTo) > 1) {
         throw new Exception\RuntimeException('Mandrill has only support for one Reply-To address');
     } elseif (count($replyTo)) {
         $parameters['message']['headers']['Reply-To'] = $replyTo->rewind()->toString();
     }
     if ($message instanceof MandrillMessage) {
         if ($hasTemplate) {
             $parameters['template_name'] = $message->getTemplate();
             foreach ($message->getTemplateContent() as $key => $value) {
                 $parameters['template_content'][] = array('name' => $key, 'content' => $value);
             }
             // Currently, Mandrill API requires a content for template_content, even if it is an
             // empty array
             if (!isset($parameters['template_content'])) {
                 $parameters['template_content'] = array();
             }
         }
         foreach ($message->getGlobalVariables() as $key => $value) {
             $parameters['message']['global_merge_vars'][] = array('name' => $key, 'content' => $value);
         }
         foreach ($message->getVariables() as $recipient => $variables) {
             $recipientVariables = array();
             foreach ($variables as $key => $value) {
                 $recipientVariables[] = array('name' => $key, 'content' => $value);
             }
             $parameters['message']['merge_vars'][] = array('rcpt' => $recipient, 'vars' => $recipientVariables);
         }
         $parameters['message']['metadata'] = $message->getGlobalMetadata();
         foreach ($message->getMetadata() as $recipient => $variables) {
             $parameters['message']['recipient_metadata'][] = array('rcpt' => $recipient, 'values' => $variables);
         }
         foreach ($message->getOptions() as $key => $value) {
             $parameters['message'][$key] = $value;
         }
         foreach ($message->getTags() as $tag) {
             $parameters['message']['tags'][] = $tag;
         }
         foreach ($message->getImages() as $image) {
             $parameters['message']['images'][] = array('type' => $image->type, 'name' => $image->filename, 'content' => base64_encode($image->getRawContent()));
         }
     }
     $attachments = $this->extractAttachments($message);
     foreach ($attachments as $attachment) {
         $parameters['message']['attachments'][] = array('type' => $attachment->type, 'name' => $attachment->filename, 'content' => base64_encode($attachment->getRawContent()));
     }
     if (null !== $sendAt) {
         // Mandrill needs to have date in UTC, using this format
         $sendAt->setTimezone(new DateTimeZone('UTC'));
         $parameters['send_at'] = $sendAt->format('Y-m-d H:i:s');
     }
     return $parameters;
 }
开发者ID:roelvanduijnhoven,项目名称:SlmMail,代码行数:77,代码来源:MandrillService.php

示例12: prepareFromAddress

 /**
  * Retrieve email address for envelope FROM
  *
  * @param  Message $message
  * @throws Exception\RuntimeException
  * @return string
  */
 protected function prepareFromAddress(Message $message)
 {
     $sender = $message->getSender();
     if ($sender instanceof Address\AddressInterface) {
         return $sender->getEmail();
     }
     $from = $message->getFrom();
     if (!count($from)) {
         // Per RFC 2822 3.6
         throw new Exception\RuntimeException(sprintf('%s transport expects either a Sender or at least one From address in the Message; none provided', __CLASS__));
     }
     $from->rewind();
     $sender = $from->current();
     return $sender->getEmail();
 }
开发者ID:Baft,项目名称:Zend-Form,代码行数:22,代码来源:Smtp.php

示例13: send

 /**
  * @param Message $message
  * @return bool
  */
 public function send(Message $message)
 {
     $this->email->addTo($message->getTo()->current()->getEmail(), $message->getTo()->current()->getName())->setFrom($message->getFrom()->current()->getEmail(), $message->getFrom()->current()->getName())->setSubject($message->getSubject())->setHtml($message->getBodyText());
     $this->sendGrid->send($this->email);
     return true;
 }
开发者ID:andrebian,项目名称:sendgrid-transport-module,代码行数:10,代码来源:SendGridTransport.php

示例14: send

 /**
  * {@inheritDoc}
  * @link http://sendgrid.com/docs/API_Reference/Web_API/mail.html
  * @return mixed
  */
 public function send(Message $message)
 {
     $from = $message->getFrom();
     if (count($from) !== 1) {
         throw new Exception\RuntimeException('SendGrid API requires exactly one from sender');
     }
     if (count($message->getCc())) {
         throw new Exception\RuntimeException('SendGrid does not support CC addresses');
     }
     $parameters = array('from' => $from->rewind()->getEmail(), 'fromname' => $from->rewind()->getName(), 'subject' => $message->getSubject(), 'text' => $this->extractText($message), 'html' => $this->extractHtml($message));
     foreach ($message->getTo() as $address) {
         $parameters['to'][] = $address->getEmail();
     }
     foreach ($message->getBcc() as $address) {
         $parameters['bcc'][] = $address->getEmail();
     }
     $replyTo = $message->getReplyTo();
     if (count($replyTo) > 1) {
         throw new Exception\RuntimeException('SendGrid has only support for one Reply-To address');
     } elseif (count($replyTo)) {
         $parameters['replyto'] = $replyTo->rewind()->getEmail();
     }
     $client = $this->prepareHttpClient('/mail.send.json');
     // Set Parameters as POST, since prepareHttpClient() put only GET parameters
     $client->setParameterPost($parameters);
     // Eventually add files. This cannot be done before prepareHttpClient call because prepareHttpClient
     // reset all parameters (response, request...), therefore we would loose the file upload
     $post = $client->getRequest()->getPost();
     $attachments = $this->extractAttachments($message);
     foreach ($attachments as $attachment) {
         $post->set('files[' . $attachment->filename . ']', $attachment->getRawContent());
     }
     $response = $client->setMethod(HttpRequest::METHOD_POST)->setEncType(HttpClient::ENC_FORMDATA)->send();
     return $this->parseResponse($response);
 }
开发者ID:erik-maas,项目名称:SlmMail,代码行数:40,代码来源:SendGridService.php

示例15: send

 /**
  * {@inheritDoc}
  * @link http://documentation.mailgun.com/api-sending.html
  * @return string id of message (if sent correctly)
  */
 public function send(Message $message)
 {
     $from = $message->getFrom();
     if (count($from) !== 1) {
         throw new Exception\RuntimeException('Postage API requires exactly one from sender');
     }
     $parameters = array('from' => $from->rewind()->toString(), 'subject' => $message->getSubject(), 'text' => $this->extractText($message), 'html' => $this->extractHtml($message));
     $to = array();
     foreach ($message->getTo() as $address) {
         $to[] = $address->toString();
     }
     $parameters['to'] = implode(',', $to);
     $cc = array();
     foreach ($message->getCc() as $address) {
         $cc[] = $address->toString();
     }
     $parameters['cc'] = implode(',', $cc);
     $bcc = array();
     foreach ($message->getBcc() as $address) {
         $bcc[] = $address->toString();
     }
     $parameters['bcc'] = implode(',', $bcc);
     $attachments = $this->extractAttachments($message);
     foreach ($attachments as $attachment) {
         $parameters['attachment'][] = $attachment->filename;
     }
     if ($message instanceof MailgunMessage) {
         $options = $message->getValidOptions();
         foreach ($message->getOptions() as $key => $value) {
             $parameters[$options[$key]] = $value;
         }
         $tags = $message->getTags();
         if (count($tags) > 0) {
             $parameters['o:tag'] = $tags;
         }
         $variables = $message->getRecipientVariables();
         if (count($variables)) {
             // It is only possible to add variables for recipients that exist in the To: field
             foreach ($variables as $recipient => $variable) {
                 if (!$message->getTo()->has($recipient)) {
                     throw new Exception\RuntimeException(sprintf('The email "%s" must be added as a receiver before you can add recipient variables', $recipient));
                 }
             }
             $parameters['recipient-variables'] = json_encode($variables);
         }
     }
     $client = $this->prepareHttpClient('/messages', $parameters);
     // Eventually add files. This cannot be done before prepareHttpClient call because prepareHttpClient
     // reset all parameters (response, request...), therefore we would loose the file upload
     $attachments = $this->extractAttachments($message);
     foreach ($attachments as $attachment) {
         $client->setFileUpload($attachment->filename, 'attachment', $attachment->getRawContent(), $attachment->type);
     }
     $client->setEncType(HttpClient::ENC_FORMDATA);
     $response = $client->send();
     $result = $this->parseResponse($response);
     return $result['id'];
 }
开发者ID:erik-maas,项目名称:SlmMail,代码行数:63,代码来源:MailgunService.php


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