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


PHP Mail\Message类代码示例

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


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

示例1: process

 public function process(ServerRequestInterface $request, DelegateInterface $delegate) : ResponseInterface
 {
     /* @var \PSR7Session\Session\SessionInterface $session */
     $session = $request->getAttribute(SessionMiddleware::SESSION_ATTRIBUTE);
     // Generate csrf token
     if (!$session->get('csrf')) {
         $session->set('csrf', md5(random_bytes(32)));
     }
     // Generate form and inject csrf token
     $form = new FormFactory($this->template->render('app::contact-form', ['token' => $session->get('csrf')]), $this->inputFilterFactory);
     // Validate form
     $validationResult = $form->validateRequest($request);
     if ($validationResult->isValid()) {
         // Get filter submitted values
         $data = $validationResult->getValues();
         $this->logger->notice('Sending contact mail to {from} <{email}> with subject "{subject}": {body}', $data);
         // Create the message
         $message = new Message();
         $message->setFrom($this->config['from'])->setReplyTo($data['email'], $data['name'])->setTo($this->config['to'])->setSubject('[xtreamwayz-contact] ' . $data['subject'])->setBody($data['body']);
         $this->mailTransport->send($message);
         // Display thank you page
         return new HtmlResponse($this->template->render('app::contact-thank-you'), 200);
     }
     // Display form and inject error messages and submitted values
     return new HtmlResponse($this->template->render('app::contact', ['form' => $form->asString($validationResult)]), 200);
 }
开发者ID:xtreamwayz,项目名称:xtreamwayz.com,代码行数:26,代码来源:ContactAction.php

示例2: send

 function send()
 {
     //第一步: 设置相关的headers
     //1.设置邮件的Content-Type,要不然网站的消息内容里面的html标签会被当做纯文本处理
     $smtpHeaderContentType = new SmtpHeaderContentType();
     $smtpHeaderContentType->setType('text/html');
     //2.设置编码集并添加Content-Type
     $headers = new SmtpHeaders();
     $headers->setEncoding('utf-8');
     $headers->addHeader($smtpHeaderContentType);
     //第二步:设置消息的相关
     $message = new SmtpMessage();
     $message->setHeaders($headers);
     $message->addTo($this->mailTo)->addFrom($this->mailFrom)->setSubject($this->subject)->setBody($this->body);
     //邮件的内容
     //第三步:设置Smtp的相关链接参数
     $smtpOptions = new SmtpOptions();
     $smtpOptions->setHost($this->host)->setPort($this->port)->setConnectionClass('login')->setConnectionConfig(array('username' => $this->username, 'password' => $this->password, 'ssl' => 'ssl'));
     //第四步:加载配置,发送消息
     $smtpTransport = new SmtpTransport();
     $smtpTransport->setOptions($smtpOptions);
     //加载配置
     $smtpTransport->send($message);
     //发送消息
 }
开发者ID:hlkzmy,项目名称:crowdfunding,代码行数:25,代码来源:TencentSmtp.php

示例3: sendMail

 public function sendMail(MailMessage $message, string $templateName = null, array $params = [])
 {
     if (null !== $templateName) {
         $message->setBody($this->prepareBody($templateName, $params));
     }
     $this->mailer->sendMail($message);
 }
开发者ID:RiskioFr,项目名称:Mailer,代码行数:7,代码来源:TemplateMailer.php

示例4: testTrue

 public function testTrue()
 {
     $message = new Message();
     $message->setSubject('Hundur')->setBody(file_get_contents(__DIR__ . '/mail.test.01.txt'))->addFrom('ble@bla.is', 'ble')->addTo('hundur@vei.is', 'hundur');
     $attacher = new Attacher($message);
     $result = $attacher->parse();
 }
开发者ID:bix0r,项目名称:Stjornvisi,代码行数:7,代码来源:AttacherTest.php

示例5: sendMail

 /**
  * Sends a mail with the given data from the AppMailAccount
  * @param string $to
  * @param string $subject
  * @param string $content
  */
 public function sendMail(string $to, string $subject, string $content, array $files = [])
 {
     $content .= "\n\nThis is an automated mail. Please don't respond.";
     $text = new Mime\Part($content);
     $text->type = 'text/plain';
     $text->charset = 'utf-8';
     $text->disposition = Mime\Mime::DISPOSITION_INLINE;
     $parts[] = $text;
     foreach ($files as $filePath) {
         $fileContent = file_get_contents($filePath);
         $attachment = new Mime\Part($fileContent);
         $attachment->type = 'image/' . pathinfo($filePath, PATHINFO_EXTENSION);
         $attachment->filename = basename($filePath);
         $attachment->disposition = Mime\Mime::DISPOSITION_ATTACHMENT;
         $attachment->encoding = Mime\Mime::ENCODING_BASE64;
         $parts[] = $attachment;
     }
     $mime = new Mime\Message();
     $mime->setParts($parts);
     $appMailData = $this->getAppMailData();
     $message = new Message();
     $message->addTo($to)->addFrom($appMailData->getAdress())->setSubject($subject)->setBody($mime)->setEncoding('utf-8');
     $transport = new SmtpTransport();
     $options = new SmtpOptions(['name' => $appMailData->getHost(), 'host' => $appMailData->getHost(), 'connection_class' => 'login', 'connection_config' => ['username' => $appMailData->getLogin(), 'password' => $appMailData->getPassword()]]);
     $transport->setOptions($options);
     $transport->send($message);
 }
开发者ID:snowiow,项目名称:eternaldeztiny,代码行数:33,代码来源:AppMailService.php

示例6: sendRestPasswordEmail

 /**
  * send
  *
  * @param ResetPassword $resetPassword
  * @param User $user
  * @param array $mailConfig
  *
  * @return mixed
  */
 public function sendRestPasswordEmail(ResetPassword $resetPassword, User $user, $mailConfig)
 {
     $toEmail = $user->getEmail();
     $fromEmail = $mailConfig['fromEmail'];
     $fromName = $mailConfig['fromName'];
     $subject = $mailConfig['subject'];
     $bodyTemplate = $mailConfig['body'];
     //Ignore blank emails
     if (!trim($toEmail)) {
         return;
     }
     $vars = ['name' => '', 'userId' => $user->getId(), 'url' => 'https://' . $_SERVER['HTTP_HOST'] . '/reset-password?fromPasswordResetEmail=1&id=' . $resetPassword->getResetId() . '&key=' . $resetPassword->getHashKey()];
     foreach ($vars as $name => $value) {
         $bodyTemplate = str_replace('__' . $name . '__', $value, $bodyTemplate);
         // Handle BC
         $bodyTemplate = str_replace('{' . $name . '}', $value, $bodyTemplate);
     }
     try {
         $html = new MimePart($bodyTemplate);
         $html->type = "text/html";
         $body = new MimeMessage();
         $body->setParts([$html]);
         $message = new Message();
         $message->setBody($body)->setFrom($fromEmail, $fromName)->setSubject($subject);
         foreach (explode(',', $toEmail) as $email) {
             $message->addTo(trim($email));
         }
         $transport = new \Zend\Mail\Transport\Sendmail();
         $transport->send($message);
     } catch (InvalidArgumentException $e) {
         // nothing
     }
 }
开发者ID:reliv,项目名称:rcm-login,代码行数:42,代码来源:DefaultMailer.php

示例7: packData

 /**
  * pack tagged array of data to SendMessage format
  *
  *
  * @param Array $mailArray
  *
  * return array of data that will be converted to
  * send message
  *
  * @return Array
  */
 public function packData($mailArray)
 {
     $mimeMail = new Message();
     $textPart = $this->packText($mailArray['text'], $mailArray['header']['content-type']);
     unset($mailArray['header']['content-type']);
     $attachmentParts = $this->packAttachments($mailArray['link']);
     if (count($attachmentParts)) {
         $mimeMail->addPart($textPart);
         foreach ($attachmentParts as $part) {
             $mimeMail->addPart($part);
         }
     } else {
         $mimeMail->addPart($textPart);
     }
     $returnMail = new SendMessage();
     $returnMail->setBody($mimeMail);
     foreach ($mailArray['header'] as $header => $value) {
         switch ($header) {
             case 'references':
                 if (is_array($value)) {
                     $res = '';
                     foreach ($value as $reference) {
                         $res .= $reference . ' ';
                     }
                 } elseif (is_string($value)) {
                     $res = $value;
                 } else {
                     continue;
                 }
                 $headers = $returnMail->getHeaders();
                 $headers->addHeaderLine($header, $res);
                 $returnMail->setHeaders($headers);
                 break;
             case 'bcc':
                 $returnMail->addBcc($value);
                 break;
             case 'cc':
                 $returnMail->addCc($value);
                 break;
             case 'to':
                 $returnMail->addTo($value);
                 break;
             case 'from':
                 $returnMail->addFrom($value);
                 break;
             case 'reply-to':
                 $returnMail->addReplyTo($value);
                 break;
             case 'subject':
                 $returnMail->setSubject($value);
                 break;
             default:
                 $headers = $returnMail->getHeaders();
                 $headers->addHeaderLine($header, $value);
                 $returnMail->setHeaders($headers);
                 break;
         }
     }
     return $returnMail;
 }
开发者ID:modelframework,项目名称:mailservice,代码行数:71,代码来源:DefaultComposeStrategy.php

示例8: getMessage

 public function getMessage()
 {
     $message = new Message();
     $message->addTo('zf-devteam@zend.com', 'ZF DevTeam')->addCc('matthew@zend.com')->addBcc('zf-crteam@lists.zend.com', 'CR-Team, ZF Project')->addFrom(array('zf-devteam@zend.com', 'Matthew' => 'matthew@zend.com'))->setSender('ralph.schindler@zend.com', 'Ralph Schindler')->setSubject('Testing Zend\\Mail\\Transport\\Sendmail')->setBody('This is only a test.');
     $message->getHeaders()->addHeaders(array('X-Foo-Bar' => 'Matthew'));
     return $message;
 }
开发者ID:haoyanfei,项目名称:zf2,代码行数:7,代码来源:FileTest.php

示例9: sendNotificationMail

 /**
  * W momencie zapisu lokalizacji do bazy – wysyła się e-mail na stały adres administratora
  * serwisu z powiadomieniem o dodaniu nowej lokalizacji (nazwa miejsca + link do strony na froncie serwisu)
  *
  * @param Entity\Location $location
  */
 public function sendNotificationMail(Entity\Location $location)
 {
     /**
      * dane do wysylanego maila z potwierdzeniem, zdefiniowane w module.config.php
      */
     $config = $this->getServiceManager()->get('Config')['configuration']['location_mail_notification'];
     /* blokada wysylania maila (do testow) */
     if (false === $config['send_notification_mail']) {
         return false;
     }
     $uri = $this->getServiceManager()->get('request')->getUri();
     /* @var $uri \Zend\Uri\Http */
     $route = $this->getServiceManager()->get('router')->getRoute('location-details');
     /* @var $route \Zend\Mvc\Router\Http\Segment */
     /**
      * link do nowej lokalizacji
      */
     $base = sprintf('%s://%s', $uri->getScheme(), $uri->getHost());
     $url = $route->assemble(array('id' => $location->getId()));
     $mailConfig = (object) $config['message_config'];
     $html = strtr($mailConfig->message, array('%name%' => $location->getName(), '%link%' => $base . $url));
     $message = new Mime\Message();
     $message->setParts(array((new Mime\Part($html))->setType('text/html')));
     $mail = new Mail\Message();
     $mail->setBody($message)->setFrom($mailConfig->from_email, $mailConfig->from_name)->addTo($mailConfig->to_email, $mailConfig->to_name)->setSubject($mailConfig->subject);
     $transport = new Mail\Transport\Smtp(new Mail\Transport\SmtpOptions($config['smtp_config']));
     $transport->send($mail);
 }
开发者ID:krozner,项目名称:EventLocationZF2,代码行数:34,代码来源:LocationMail.php

示例10: sendMessage

 public function sendMessage(Message $message, Smtp $smtp, $recipient)
 {
     $message->addTo($recipient);
     if (!$this->config['disable_delivery']) {
         $smtp->send($message);
     }
 }
开发者ID:gdpro,项目名称:gdpro-mailer,代码行数:7,代码来源:MailerService.php

示例11: send

 /**
  * Send a mail message
  *
  * @param Mail\Message $message
  * @return array
  */
 public function send(Mail\Message $message)
 {
     $this->getMandrillClient();
     $body = $message->getBody();
     $attachments = [];
     switch (true) {
         case $body instanceof Message:
             $bodyHtml = $this->getHtmlPart($body);
             $bodyText = $this->getTextPart($body);
             $attachments = $this->getAttachments($body);
             break;
         case is_string($body):
             $bodyHtml = $body;
             $bodyText = $message->getBodyText();
             break;
         case is_object($body):
             $bodyHtml = $body->__toString();
             $bodyText = $message->getBodyText();
             break;
         default:
             throw new Exception\InvalidArgumentException(sprintf('"%s" expectes a body that is a string, an object or a Zend\\Mime\\Message; received "%s"', __METHOD__, is_object($body) ? get_class($body) : gettype($body)));
             break;
     }
     $message = ['html' => $bodyHtml, 'text' => $bodyText, 'subject' => $message->getSubject(), 'from_email' => $message->getFrom()->current()->getEmail(), 'from_name' => $message->getFrom()->current()->getName(), 'to' => array_merge($this->mapAddressListToArray($message->getTo(), 'to'), $this->mapAddressListToArray($message->getCc(), 'cc'), $this->mapAddressListToArray($message->getBcc(), 'bcc')), 'headers' => $message->getHeaders()->toArray(), 'subaccount' => $this->options->getSubAccount(), 'attachments' => $attachments];
     return $this->mandrillClient->messages->send($message);
 }
开发者ID:ripaclub,项目名称:zf2-mailman,代码行数:32,代码来源:Mandrill.php

示例12: send

 protected function send()
 {
     try {
         $message = new Message();
         $para = array_filter(explode(";", str_replace(array(" ", ","), array("", ";"), $this->dados["para"])));
         $message->addTo($para)->addFrom($this->dados["de"]["email"], $this->dados["de"]["nome"])->setSubject($this->dados["assunto"])->addReplyTo($this->dados["replay"]);
         $transport = new SmtpTransport();
         $options = new SmtpOptions(array('host' => 'mail.pessoaweb.com.br', 'connection_class' => 'login', 'connection_config' => array('username' => 'dispatch@pessoaweb.com.br', 'password' => 'd1i2s3p4atch'), 'port' => 587));
         $html = new MimePart($this->dados["body"]);
         $html->type = "text/html";
         $html->charset = "UTF-8";
         $body = new MimeMessage();
         if (isset($this->dados["attachment"])) {
             foreach ($this->dados["attachment"] as $valor) {
                 $attachment = new MimePart($valor["arquivo"]);
                 $attachment->filename = $valor["titulo"];
                 if (isset($valor["tipo"])) {
                     $attachment->type = $valor["tipo"];
                 }
                 $attachment->disposition = Mime::DISPOSITION_ATTACHMENT;
                 $attachment->encoding = Mime::ENCODING_BASE64;
                 $body->setParts(array($attachment));
             }
         }
         $body->addPart($html);
         $message->setBody($body);
         $transport->setOptions($options);
         $transport->send($message);
         return $transport;
     } catch (\Exception $e) {
         debug(array("email" => $e->getMessage()), true);
     }
 }
开发者ID:bhcosta90,项目名称:zend,代码行数:33,代码来源:EmailAbstract.php

示例13: sendEmail

 static function sendEmail($emailTo, $emailFrom, $subject, $body, $transport)
 {
     $message = new Message();
     $message->setEncoding('UTF-8')->addTo($emailTo)->addFrom($emailFrom)->setSubject($subject)->setBody($body);
     $transport->send($message);
     return;
 }
开发者ID:Nasty94,项目名称:SilmaringiEksamiKeskkond,代码行数:7,代码来源:EmailService.php

示例14: fromWrappedMessage

 /**
  * @inheritDoc
  */
 public static function fromWrappedMessage(MailWrappedMessage $wrappedMessage = null, $transport = null)
 {
     if (!$wrappedMessage instanceof MailWrappedMessage) {
         throw new MailWrapperSetupException('Not MailWrappedMessage');
     }
     $message = new 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()) {
         $html = new MimePart($wrappedMessage->getContentHtml());
         $html->type = "text/html";
         $message->setBody($body);
     }
     return $message;
 }
开发者ID:BespokeSupport,项目名称:MailWrapper,代码行数:31,代码来源:MessageTransformerZend.php

示例15: 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


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