當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。