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


PHP Swift_Message::setSender方法代码示例

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


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

示例1: iSendEmailWithMessage

 /**
  * @When I send email to :email with message :body
  */
 public function iSendEmailWithMessage($email, $body)
 {
     $message = new \Swift_Message('Subject', $body);
     $message->setSender('john@example.com');
     $message->setTo($email);
     $this->sendEmail($message);
 }
开发者ID:kibao,项目名称:behat-mailcatcher-extension,代码行数:10,代码来源:FeatureContext.php

示例2: __construct

 public function __construct()
 {
     parent::__construct();
     $this->prependSiteTitle(lang('Recover log in'));
     if ($this->isPostBack()) {
         $this->post->email->addValidation(new ValidateInputNotNullOrEmpty());
         if (!$this->hasErrors()) {
             $user = ModelUser::getByUsername($this->input('email'));
             if (!$user->hasRow()) {
                 $this->setMessage('No user found', 'warning');
                 response()->refresh();
             }
             if (!$this->hasErrors()) {
                 $reset = new UserReset($user->id);
                 $reset->save();
                 // TODO: Move this shit to seperate html template
                 $text = "Dear customer!\n\nYou are receiving this mail, because you (or someone else) has requested a password reset for your user on NinjaImg.com.\n\nTo continue with the password reset, please click the link below to confirm the reset:\n\n" . sprintf('https://%s/reset/%s', $_SERVER['HTTP_HOST'], $reset->key) . "\n\nIf you have any questions, feel free to contact us any time.\n\nKind regards,\nThe NinjaImg Team";
                 $transport = \Swift_SendmailTransport::newInstance(env('MAIL_TRANSPORT') . ' -bs');
                 $swift = \Swift_Mailer::newInstance($transport);
                 $message = new \Swift_Message(lang('Confirm password reset on NinjaImg'));
                 $message->setFrom(env('MAIL_FROM'));
                 $message->setSender(env('MAIL_FROM'));
                 $message->setReplyTo(env('MAIL_FROM'));
                 $message->setBody($text, 'text/plain');
                 $message->setTo($user->username);
                 $swift->send($message);
                 $this->setMessage('A password reset link has been sent to your e-mail', 'success');
                 // Send mail to user confirming reset...
                 // Maybe show message with text that are active even when session disappear
                 response()->refresh();
             }
         }
     }
 }
开发者ID:Monori,项目名称:imgservice,代码行数:34,代码来源:UserForgot.php

示例3: __construct

 public function __construct($key)
 {
     parent::__construct();
     $newPassword = uniqid();
     $reset = \Pecee\Model\User\UserReset::confirm($key, $newPassword);
     if ($reset) {
         $user = ModelUser::getById($reset);
         if ($user->hasRow()) {
             // Send mail with new password
             // TODO: Move this shit to separate html template
             $user->setEmailConfirmed(true);
             $user->update();
             $text = "Dear customer!\n\nWe've reset your password - you can login with your e-mail and the new password provided below:\nNew password: " . $newPassword . "\n\nIf you have any questions, feel free to contact us any time.\n\nKind regards,\nThe NinjaImg Team";
             $transport = \Swift_SendmailTransport::newInstance(env('MAIL_TRANSPORT') . ' -bs');
             $swift = \Swift_Mailer::newInstance($transport);
             $message = new \Swift_Message(lang('New password for NinjaImg'));
             $message->setFrom(env('MAIL_FROM'));
             $message->setSender(env('MAIL_FROM'));
             $message->setReplyTo(env('MAIL_FROM'));
             $message->setBody($text, 'text/plain');
             $message->setTo($user->username);
             $swift->send($message);
             $this->setMessage('A new password has been sent to your e-mail.', 'success');
             redirect(url('user.login'));
         }
         redirect(url('home'));
     }
 }
开发者ID:Monori,项目名称:imgservice,代码行数:28,代码来源:UserReset.php

示例4: sendMail

function sendMail($mail, $subject, $text)
{
    $transport = \Swift_SendmailTransport::newInstance(env('MAIL_TRANSPORT') . ' -bs');
    $swift = \Swift_Mailer::newInstance($transport);
    $message = new \Swift_Message($subject);
    $message->setFrom(env('MAIL_FROM'));
    $message->setSender(env('MAIL_FROM'));
    $message->setReplyTo(env('MAIL_FROM'));
    $message->setBody($text, 'text/plain');
    $message->addTo($mail);
    $swift->send($message);
}
开发者ID:Monori,项目名称:imgservice,代码行数:12,代码来源:global_helpers.php

示例5: inviteUser

 protected function inviteUser()
 {
     if ($this->input('email')) {
         if ($this->currentUser->getRole() !== UserRole::TYPE_OWNER) {
             $this->setError(lang('You dont have permissions to invite users'));
             response()->refresh();
         }
         $this->post->email->addValidation([new ValidateInputNotNullOrEmpty(), new ValidateInputEmail()]);
         $this->post->role->addValidation(new ValidateInputNotNullOrEmpty());
         if (!$this->hasErrors()) {
             $user = ModelUser::getByUsername($this->input('email'));
             if ($user->hasRow() && $user->hasAccess($this->activeOrganisation->id)) {
                 if ($user->getRole() === $this->input('role')) {
                     $this->setMessage(lang('The user already has access to this organisation'), 'danger');
                 } else {
                     $user->setRole($this->input('role'));
                     $this->setMessage(lang('The role has been updated'), 'success');
                     // TODO: sent mail notifying about role-change
                 }
                 response()->refresh();
             }
             // Save invitation
             $invitation = new OrganisationInvite();
             $invitation->user_id = $this->currentUser->id;
             $invitation->email = $this->input('email');
             $invitation->organisation_id = $this->activeOrganisation->id;
             $invitation->role = $this->input('role');
             $invitation->save();
             // This point we send out a confirmation mail to accept the organisation invite.
             // TODO: move this shit to separate template
             $transport = \Swift_SendmailTransport::newInstance(env('MAIL_TRANSPORT') . ' -bs');
             $swift = \Swift_Mailer::newInstance($transport);
             $message = new \Swift_Message(lang('Invite to join ' . $this->activeOrganisation->name . ' on NinjaImg'));
             $message->setFrom(env('MAIL_FROM'));
             $message->setSender(env('MAIL_FROM'));
             $message->setReplyTo(env('MAIL_FROM'));
             $message->setBody("Dear customer!\n\n{$this->currentUser->data->name} has invited you to join the organisation {$this->activeOrganisation->name} on NinjaImg!\n\nClick on the link below to accept the invite:\nhttps://{$_SERVER['HTTP_HOST']}" . url('user.register') . "?email=" . $this->input('email') . "\n\nIf you have any questions, feel free to contact us any time.\n\nKind regards,\nThe NinjaImg Team", 'text/plain');
             $message->setTo($this->input('email'));
             $swift->send($message);
             $this->setMessage('An invite has been sent to the user.', 'success');
         }
     }
 }
开发者ID:Monori,项目名称:imgservice,代码行数:43,代码来源:Account.php

示例6: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var $transport \Swift_Transport */
     $transport = $this->getContainer()->get('swiftmailer.transport.real');
     if (!$transport->isStarted()) {
         $transport->start();
     }
     $spoolPath = sprintf('%s/*/', $this->getContainer()->getParameter('swiftmailer.spool.path'));
     $finder = Finder::create()->in($spoolPath)->name('*.sending');
     $parameters = $this->getContainer()->getParameter('emails');
     $parameters = $parameters['error'];
     foreach ($finder as $failedFile) {
         // rename the file, so no other process tries to find it
         $tmpFilename = $failedFile . '.finalretry';
         rename($failedFile, $tmpFilename);
         /** @var $message \Swift_Message */
         $message = unserialize(file_get_contents($tmpFilename));
         $output->writeln(sprintf('Retrying <info>%s</info> to <info>%s</info>', $message->getSubject(), implode(', ', array_keys($message->getTo()))));
         $errorContent = null;
         try {
             if ($transport->send($message)) {
                 $output->writeln('Sent!');
             } else {
                 $errorContent = sprintf("Un email n'a pas pu être envoyé aux adresses : %s\n");
             }
         } catch (\Swift_TransportException $e) {
             $errorContent = sprintf("Erreur lors de l'envoi d'un email aux adresses : %s\nErreur rencontrée : %s\n", implode(', ', $message->getTo()), $e->getMessage());
         }
         if ($errorContent) {
             $errorMessage = new \Swift_Message('[SEH Site Portail] Erreur lors de l\'envoi d\'un email', $errorContent . "Contenu du mail :\n" . $message->getBody());
             $errorMessage->setTo($parameters['to']);
             $errorMessage->setSender($parameters['sender']);
             try {
                 $transport->send($errorMessage);
             } catch (\Exception $e) {
                 $this->getContainer()->get('logger')->error($errorContent);
             }
             $output->writeln('<error>Send failed - deleting spooled message</error>');
         }
         // delete the file, either because it sent, or because it failed
         unlink($tmpFilename);
     }
 }
开发者ID:blab2015,项目名称:seh,代码行数:43,代码来源:ClearFailedSpoolCommand.php

示例7: sendCustomerMail

 protected function sendCustomerMail(OrganisationInvoice $invoice)
 {
     $users = ModelUser::getByOrganisationId($this->organisation->id, UserRole::TYPE_OWNER);
     if ($users->hasRows()) {
         foreach ($users as $user) {
             $transport = \Swift_SendmailTransport::newInstance(env('MAIL_TRANSPORT') . ' -bs');
             $swift = \Swift_Mailer::newInstance($transport);
             $message = new \Swift_Message(lang('New invoice available for ' . $this->organisation->name));
             $currency = ModelSettings::getInstance()->data->default_currency_character;
             $message->setFrom(env('MAIL_FROM'));
             $message->setSender(env('MAIL_FROM'));
             $message->setReplyTo(env('MAIL_FROM'));
             $message->setBody("Dear {$user->data->name}!\n\nAttached is the latest invoice from NinjaImg.\n\nThe amount for invoice {$invoice->invoice_id} is {$invoice->amount_total}{$currency} with payment date {$invoice->due_date}.\n\nYou can always view your invoices at your controlpanel on ninjaimg.com.\n\nThanks for supporting our service, we really appreciate it!\n\nIf you have any questions, feel free to contact us any time.\n\nKind regards,\nThe NinjaImg Team", 'text/plain');
             $message->setTo($user->username);
             $attachment = new \Swift_Attachment(file_get_contents($invoice->path), basename($invoice->path), File::getMime($invoice->path));
             $message->attach($attachment);
             $swift->send($message);
         }
     }
 }
开发者ID:Monori,项目名称:imgservice,代码行数:20,代码来源:Invoices.php

示例8: processEmail

    /**
     * Prepare the email message.
     */
    public function processEmail()
    {
        $this->count = 1;
        $mail = new Swift_Message();
        $mail->setContentType('text/plain');
        $mail->setCharset('utf-8');
        if ($this->getOption('use_complete_template', true)) {
            $mail->setBody(sprintf(<<<EOF
------
%s - %s
------
%s
------
EOF
, $this->options['name'], $this->options['email'], $this->options['message']));
        } else {
            $mail->setBody($this->options['message']);
        }
        $mail->setSender(array(sfPlop::get('sf_plop_messaging_from_email') => sfPlop::get('sf_plop_messaging_from_name')));
        $mail->setFrom(array($this->options['email'] => $this->options['name']));
        if ($this->getOption('copy')) {
            $mail->setCc(array($this->options['email'] => $this->options['name']));
            $this->count++;
        }
        if (is_integer($this->getOption('receiver'))) {
            $receiver = sfGuardUserProfilePeer::retrieveByPK($this->getOption('receiver'));
            if ($receiver) {
                $mail->setTo(array($receiver->getEmail() => $receiver->getFullName()));
            } else {
                $mail->setTo(array(sfPlop::get('sf_plop_messaging_to_email') => sfPlop::get('sf_plop_messaging_to_name')));
            }
        } else {
            $mail->setTo(array(sfPlop::get('sf_plop_messaging_to_email') => sfPlop::get('sf_plop_messaging_to_name')));
        }
        if ($this->getOption('subject')) {
            $mail->setSubject($this->getOption('subject'));
        } else {
            $mail->setSubject(sfPlop::get('sf_plop_messaging_subject'));
        }
        $this->mail = $mail;
    }
开发者ID:noreiller,项目名称:sfPlopPlugin,代码行数:44,代码来源:sfPlopMessaging.class.php

示例9: invitationAcceptedMail

 protected function invitationAcceptedMail(OrganisationInvite $invite, ModelOrganisation $organisation, ModelUser $user)
 {
     $senderUser = ModelUser::getById($invite->user_id);
     if ($senderUser->hasRow() && !$senderUser->deleted) {
         $transport = \Swift_SendmailTransport::newInstance(env('MAIL_TRANSPORT') . ' -bs');
         $swift = \Swift_Mailer::newInstance($transport);
         $message = new \Swift_Message(lang('Invitation to ' . $organisation->name . ' accepted'));
         $message->setFrom(env('MAIL_FROM'));
         $message->setSender(env('MAIL_FROM'));
         $message->setReplyTo(env('MAIL_FROM'));
         $message->setBody("Dear {$senderUser->data->name}!\n\nWe are writing to inform you, that {$user->data->name} has just accepted your invitation to join the organisation {$organisation->name} on NinjaImg.\n\nIf you have any questions, feel free to contact us any time.\n\nKind regards,\nThe NinjaImg Team", 'text/plain');
         $message->setTo($senderUser->username);
         $swift->send($message);
     }
 }
开发者ID:Monori,项目名称:imgservice,代码行数:15,代码来源:UserRegister.php

示例10: sender

 /**
  * Set the "sender" of the message.
  *
  * @param  string  $address
  * @param  string  $name
  * @return $this
  */
 public function sender($address, $name = null)
 {
     $this->swift->setSender($address, $name);
     return $this;
 }
开发者ID:nova-framework,项目名称:cms,代码行数:12,代码来源:Message.php

示例11: createFakeFailedMessageFiles

 private function createFakeFailedMessageFiles($count = 1)
 {
     $targetDir = __DIR__ . "/mock.spool.path/";
     $i = 0;
     while ($i < $count) {
         $random = md5(date('now')) . $count . rand(0, 10000000);
         $filename = $targetDir . "{$random}.sending";
         $msg = new \Swift_Message();
         $msg->setTo("test-recipient@test.com");
         $msg->setBody("random file {$random} bla bla.");
         $msg->setSubject("subject blabbla");
         $msg->setSender("test@test.com");
         $ser = serialize($msg);
         $filehandle = fopen($filename, "w");
         fwrite($filehandle, $ser);
         fclose($filehandle);
         $i++;
     }
     // make sure the right number of files has been created.
     $fileCount = 0;
     $targetDirHandle = opendir($targetDir);
     while (($file = readdir($targetDirHandle)) !== false) {
         $fileCount++;
     }
     $this->assertEquals($count + 3, $fileCount, "Exactly {$count} + 2 files (*.sending, '.', '..' and '.keepMe') expected in this directory( {$targetDir} ).");
 }
开发者ID:azine,项目名称:email-bundle,代码行数:26,代码来源:ClearAndLogFailedMailsCommandTest.php

示例12: setSender

 /**
  * {@inheritdoc}
  *
  * @return $this|self
  */
 public function setSender($address, $name = null) : self
 {
     $this->message->setSender($address, $name);
     return $this;
 }
开发者ID:cawaphp,项目名称:email,代码行数:10,代码来源:Message.php

示例13: setSender

 public function setSender(Email $sender)
 {
     $this->message->setSender($sender->email, $sender->name);
     return $this;
 }
开发者ID:Webiny,项目名称:Framework,代码行数:5,代码来源:Message.php

示例14: testEmbeddedFilesWithMultipartDataCreateMultipartRelatedContentAsAnAlternative

 public function testEmbeddedFilesWithMultipartDataCreateMultipartRelatedContentAsAnAlternative()
 {
     $message = new Swift_Message();
     $message->setCharset('utf-8');
     $message->setSubject('test subject');
     $message->addPart('plain part', 'text/plain');
     $image = new Swift_Image('<image data>', 'image.gif', 'image/gif');
     $cid = $message->embed($image);
     $message->setBody('<img src="' . $cid . '" />', 'text/html');
     $message->setTo(array('user@domain.tld' => 'User'));
     $message->setFrom(array('other@domain.tld' => 'Other'));
     $message->setSender(array('other@domain.tld' => 'Other'));
     $id = $message->getId();
     $date = preg_quote(date('r', $message->getDate()), '~');
     $boundary = $message->getBoundary();
     $cidVal = $image->getId();
     $this->assertRegExp('~^' . 'Sender: Other <other@domain.tld>' . "\r\n" . 'Message-ID: <' . $id . '>' . "\r\n" . 'Date: ' . $date . "\r\n" . 'Subject: test subject' . "\r\n" . 'From: Other <other@domain.tld>' . "\r\n" . 'To: User <user@domain.tld>' . "\r\n" . 'MIME-Version: 1.0' . "\r\n" . 'Content-Type: multipart/alternative;' . "\r\n" . ' boundary="' . $boundary . '"' . "\r\n" . "\r\n\r\n" . '--' . $boundary . "\r\n" . 'Content-Type: text/plain; charset=utf-8' . "\r\n" . 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . "\r\n" . 'plain part' . "\r\n\r\n" . '--' . $boundary . "\r\n" . 'Content-Type: multipart/related;' . "\r\n" . ' boundary="(.*?)"' . "\r\n" . "\r\n\r\n" . '--\\1' . "\r\n" . 'Content-Type: text/html; charset=utf-8' . "\r\n" . 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . "\r\n" . '<img.*?/>' . "\r\n\r\n" . '--\\1' . "\r\n" . 'Content-Type: image/gif; name=image.gif' . "\r\n" . 'Content-Transfer-Encoding: base64' . "\r\n" . 'Content-Disposition: inline; filename=image.gif' . "\r\n" . 'Content-ID: <' . $cidVal . '>' . "\r\n" . "\r\n" . preg_quote(base64_encode('<image data>'), '~') . "\r\n\r\n" . '--\\1--' . "\r\n" . "\r\n\r\n" . '--' . $boundary . '--' . "\r\n" . '$~D', $message->toString());
 }
开发者ID:Amunak,项目名称:swiftmailer,代码行数:18,代码来源:Bug34Test.php

示例15: testHTMLPartAppearsLastEvenWhenAttachmentsAdded

 public function testHTMLPartAppearsLastEvenWhenAttachmentsAdded()
 {
     $message = new Swift_Message();
     $message->setCharset('utf-8');
     $message->setSubject('test subject');
     $message->addPart('plain part', 'text/plain');
     $attachment = new Swift_Attachment('<data>', 'image.gif', 'image/gif');
     $message->attach($attachment);
     $message->setBody('HTML part', 'text/html');
     $message->setTo(array('user@domain.tld' => 'User'));
     $message->setFrom(array('other@domain.tld' => 'Other'));
     $message->setSender(array('other@domain.tld' => 'Other'));
     $id = $message->getId();
     $date = preg_quote($message->getDate()->format('r'), '~');
     $boundary = $message->getBoundary();
     $this->assertRegExp('~^' . 'Sender: Other <other@domain.tld>' . "\r\n" . 'Message-ID: <' . $id . '>' . "\r\n" . 'Date: ' . $date . "\r\n" . 'Subject: test subject' . "\r\n" . 'From: Other <other@domain.tld>' . "\r\n" . 'To: User <user@domain.tld>' . "\r\n" . 'MIME-Version: 1.0' . "\r\n" . 'Content-Type: multipart/mixed;' . "\r\n" . ' boundary="' . $boundary . '"' . "\r\n" . "\r\n\r\n" . '--' . $boundary . "\r\n" . 'Content-Type: multipart/alternative;' . "\r\n" . ' boundary="(.*?)"' . "\r\n" . "\r\n\r\n" . '--\\1' . "\r\n" . 'Content-Type: text/plain; charset=utf-8' . "\r\n" . 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . "\r\n" . 'plain part' . "\r\n\r\n" . '--\\1' . "\r\n" . 'Content-Type: text/html; charset=utf-8' . "\r\n" . 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . "\r\n" . 'HTML part' . "\r\n\r\n" . '--\\1--' . "\r\n" . "\r\n\r\n" . '--' . $boundary . "\r\n" . 'Content-Type: image/gif; name=image.gif' . "\r\n" . 'Content-Transfer-Encoding: base64' . "\r\n" . 'Content-Disposition: attachment; filename=image.gif' . "\r\n" . "\r\n" . preg_quote(base64_encode('<data>'), '~') . "\r\n\r\n" . '--' . $boundary . '--' . "\r\n" . '$~D', $message->toString());
 }
开发者ID:tweakers-dev,项目名称:swiftmailer,代码行数:17,代码来源:Bug35Test.php


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