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


PHP Swift_Mailer::newInstance方法代码示例

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


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

示例1: __construct

 /**
  * Direct invocation of the constructor is not permitted.
  */
 protected function __construct(array $config)
 {
     $transport = \Swift_AWSTransport::newInstance($config['api_user'], $config['api_pass']);
     $transport->setDebug(array($this, 'debugCallback'));
     $transport->setEndpoint('https://email.' . strtolower($config['api_type']) . '.amazonaws.com/');
     $this->mailer = \Swift_Mailer::newInstance($transport);
 }
开发者ID:rhymix,项目名称:rhymix,代码行数:10,代码来源:ses.php

示例2: __construct

 public function __construct()
 {
     // 设置邮件系统服务器、端口、加密方式以及用户账号信息
     $this->transport = \Swift_SmtpTransport::newInstance($this->host, $this->port, $this->encryption)->setUsername($this->username)->setPassword($this->password);
     // 传入上面配置好的参数用以得到一个Swift_Mailer实例化对象
     $this->mailer = \Swift_Mailer::newInstance($this->transport);
 }
开发者ID:tiandongxiao,项目名称:test,代码行数:7,代码来源:QQMailer.php

示例3: __construct

    /**
     * Base constructor.
     * In the base constructor the bridge gets the mailer configuration.
     *
     * @param ConfigObject $config The base configuration.
     *
     * @throws SwiftMailerException
     */
    public function __construct($config)
    {
        $this->config = $config;
        $transportType = strtolower($config->get('Transport.Type', 'mail'));
        $disableDelivery = $config->get('DisableDelivery', false);
        if ($disableDelivery) {
            $transportType = 'null';
        }
        // create Transport instance
        switch ($transportType) {
            case 'smtp':
                $transport = \Swift_SmtpTransport::newInstance($config->get('Transport.Host', 'localhost'), $config->get('Transport.Port', 25), $config->get('Transport.AuthMode', null));
                $transport->setUsername($config->get('Transport.Username', ''));
                $transport->setPassword($config->get('Transport.Password', ''));
                $transport->setEncryption($config->get('Transport.Encryption', null));
                break;
            case 'mail':
                $transport = \Swift_MailTransport::newInstance();
                break;
            case 'sendmail':
                $transport = \Swift_SendmailTransport::newInstance($config->get('Transport.Command', '/usr/sbin/sendmail -bs'));
                break;
            case 'null':
                $transport = \Swift_NullTransport::newInstance();
                break;
            default:
                throw new SwiftMailerException('Invalid transport.type provided.
												Supported types are [smtp, mail, sendmail, null].');
                break;
        }
        // create Mailer instance
        $this->mailer = \Swift_Mailer::newInstance($transport);
        // register plugins
        $this->registerPlugins($config);
    }
开发者ID:Nkelliny,项目名称:Framework,代码行数:43,代码来源:Transport.php

示例4: send

 public static function send()
 {
     $transport = \Swift_SmtpTransport::newInstance('smtp.mail.ru', 465, 'ssl')->setUsername('ist70@mail.ru')->setPassword('');
     $mailer = \Swift_Mailer::newInstance($transport);
     $messages = \Swift_Message::newInstance('Wonderful Subject')->setFrom('my@example.com')->setTo(['eva@prokma.ru' => 'Работа'])->setContentType("text/html; charset=UTF-8")->setBody('Тестовое сообщение о БД', 'text/html');
     $result = $mailer->send($messages);
 }
开发者ID:eropkinvitaliy,项目名称:PHP-2-profit,代码行数:7,代码来源:SenderMail.php

示例5: getMailer

 /**
  * get the SwiftMailer object with the configured transport
  *
  */
 protected function getMailer()
 {
     if (!$this->_mailer) {
         $this->_mailer = Swift_Mailer::newInstance($this->getTransport());
     }
     return $this->_mailer;
 }
开发者ID:openeyeswales,项目名称:OpenEyes,代码行数:11,代码来源:Mailer.php

示例6: sendEmail

 public function sendEmail() {
     $this->emailConfig = $this->getEmailConfiguration();
     $this->setMailer();
     $mailerObject = Swift_Mailer::newInstance($this->transport);
     #$mailerObject = sfContext::getInstance()->getMailer();
     $message = Swift_Message::newInstance()
         ->setFrom($this->sender)
         ->setTo($this->receiver)
         ->setSubject($this->subject)
         ->setContentType($this->contentType)
         ->setBody($this->body);
     if(isset($this->attachments)) {
         foreach($this->attachments as $file) {
             $fileObj = new File();
             $filecontent = $fileObj->getFileContent($file['filepath']);
             $message->attach(Swift_Attachment::newInstance($filecontent, $file['filename']));
         }
     }
     try {
         if($this->emailConfig['allowemailtransport'] == 1) {
             $mailerObject->send($message);
         }
     }
     catch (Exception $e) {
         
     }
     
 }
开发者ID:rlauenroth,项目名称:cuteflow_v3,代码行数:28,代码来源:EmailSettings.class.php

示例7: setup

 /**
  * Sets up the Aimeos environemnt
  *
  * @param string $extdir Absolute or relative path to the Aimeos extension directory
  * @return \Aimeos\Slim\Bootstrap Self instance
  */
 public function setup($extdir = '../ext')
 {
     $container = $this->app->getContainer();
     $container['router'] = function ($c) {
         return new \Aimeos\Slim\Router();
     };
     $container['mailer'] = function ($c) {
         return \Swift_Mailer::newInstance(\Swift_SendmailTransport::newInstance());
     };
     $default = (require __DIR__ . DIRECTORY_SEPARATOR . 'aimeos-default.php');
     $settings = array_replace_recursive($default, $this->settings);
     $container['aimeos'] = function ($c) use($extdir) {
         return new \Aimeos\Bootstrap((array) $extdir, false);
     };
     $container['aimeos_config'] = function ($c) use($settings) {
         return new \Aimeos\Slim\Base\Config($c, $settings);
     };
     $container['aimeos_context'] = function ($c) {
         return new \Aimeos\Slim\Base\Context($c);
     };
     $container['aimeos_i18n'] = function ($c) {
         return new \Aimeos\Slim\Base\I18n($c);
     };
     $container['aimeos_locale'] = function ($c) {
         return new \Aimeos\Slim\Base\Locale($c);
     };
     $container['aimeos_page'] = function ($c) {
         return new \Aimeos\Slim\Base\Page($c);
     };
     $container['aimeos_view'] = function ($c) {
         return new \Aimeos\Slim\Base\View($c);
     };
     return $this;
 }
开发者ID:aimeos,项目名称:aimeos-slim,代码行数:40,代码来源:Bootstrap.php

示例8: send

 /**
  * Sends the digest
  */
 public function send()
 {
     $lastMonths = new \DateTime();
     $lastMonths->modify('-6 month');
     $parameters = array('modified_at >= ?0 AND digest = "Y" AND notifications <> "N"', 'bind' => array($lastMonths->getTimestamp()));
     $users = array();
     foreach (Users::find($parameters) as $user) {
         if ($user->email && strpos($user->email, '@') !== false && strpos($user->email, '@users.noreply.github.com') === false) {
             $users[trim($user->email)] = $user->name;
         }
     }
     $fromName = $this->config->mail->fromName;
     $fromEmail = $this->config->mail->fromEmail;
     $url = $this->config->site->url;
     $subject = 'Top Stories from Phosphorum ' . date('d/m/y');
     $lastWeek = new \DateTime();
     $lastWeek->modify('-1 week');
     $order = 'number_views + ' . '((IF(votes_up IS NOT NULL, votes_up, 0) - ' . 'IF(votes_down IS NOT NULL, votes_down, 0)) * 4) + ' . 'number_replies + IF(accepted_answer = "Y", 10, 0) DESC';
     $parameters = array('created_at >= ?0 AND deleted != 1 AND categories_id <> 4', 'bind' => array($lastWeek->getTimestamp()), 'order' => $order, 'limit' => 10);
     $e = $this->escaper;
     $content = '<html><head></head><body><p><h1 style="font-size:22px;color:#333;letter-spacing:-0.5px;line-height:1.25;font-weight:normal;padding:16px 0;border-bottom:1px solid #e2e2e2">Top Stories from Phosphorum</h1></p>';
     foreach (Posts::find($parameters) as $post) {
         $user = $post->user;
         if ($user == false) {
             continue;
         }
         $content .= '<p><a style="text-decoration:none;display:block;font-size:20px;color:#333;letter-spacing:-0.5px;line-height:1.25;font-weight:normal;color:#155fad" href="' . $url . '/discussion/' . $post->id . '/' . $post->slug . '">' . $e->escapeHtml($post->title) . '</a></p>';
         $content .= '<p><table width="100%"><td><table><tr><td>' . '<img src="https://secure.gravatar.com/avatar/' . $user->gravatar_id . '?s=32&amp;r=pg&amp;d=identicon" width="32" height="32" alt="' . $user->name . ' icon">' . '</td><td><a style="text-decoration:none;color:#155fad" href="' . $url . '/user/' . $user->id . '/' . $user->login . '">' . $user->name . '<br><span style="text-decoration:none;color:#999;text-decoration:none">' . $user->getHumanKarma() . '</span></a></td></tr></table></td><td align="right"><table style="border: 1px solid #dadada;" cellspacing=5>' . '<td align="center"><label style="color:#999;margin:0px;font-weight:normal;">Created</label><br>' . $post->getHumanCreatedAt() . '</td>' . '<td align="center"><label style="color:#999;margin:0px;font-weight:normal;">Replies</label><br>' . $post->number_replies . '</td>' . '<td align="center"><label style="color:#999;margin:0px;font-weight:normal;">Views</label><br>' . $post->number_views . '</td>' . '<td align="center"><label style="color:#999;margin:0px;font-weight:normal;">Votes</label><br>' . ($post->votes_up - $post->votes_down) . '</td>' . '</tr></table></td></tr></table></p>';
         $content .= $this->markdown->render($e->escapeHtml($post->content));
         $content .= '<p><a style="color:#155fad" href="' . $url . '/discussion/' . $post->id . '/' . $post->slug . '">Read more</a></p>';
         $content .= '<hr style="border: 1px solid #dadada">';
     }
     $textContent = strip_tags($content);
     $htmlContent = $content . '<p style="font-size:small;-webkit-text-size-adjust:none;color:#717171;">';
     $htmlContent .= PHP_EOL . 'This email was sent by Phalcon Framework. Change your e-mail preferences <a href="' . $url . '/settings">here</a></p>';
     foreach ($users as $email => $name) {
         try {
             $message = new \Swift_Message('[Phalcon Forum] ' . $subject);
             $message->setTo(array($email => $name));
             $message->setFrom(array($fromEmail => $fromName));
             $bodyMessage = new \Swift_MimePart($htmlContent, 'text/html');
             $bodyMessage->setCharset('UTF-8');
             $message->attach($bodyMessage);
             $bodyMessage = new \Swift_MimePart($textContent, 'text/plain');
             $bodyMessage->setCharset('UTF-8');
             $message->attach($bodyMessage);
             if (!$this->transport) {
                 $this->transport = \Swift_SmtpTransport::newInstance($this->config->smtp->host, $this->config->smtp->port, $this->config->smtp->security);
                 $this->transport->setUsername($this->config->smtp->username);
                 $this->transport->setPassword($this->config->smtp->password);
             }
             if (!$this->mailer) {
                 $this->mailer = \Swift_Mailer::newInstance($this->transport);
             }
             $this->mailer->send($message);
         } catch (\Exception $e) {
             echo $e->getMessage(), PHP_EOL;
         }
     }
 }
开发者ID:woyifang,项目名称:forum,代码行数:63,代码来源:Digest.php

示例9: executeEmailExpirationNotice

 public function executeEmailExpirationNotice(sfWebRequest $request)
 {
     $notices = $request->getParameter('expired');
     $mail_count = 0;
     // prepare swift mailer
     require_once sfConfig::get('sf_lib_dir') . '/vendor/swift/swift_required.php';
     # needed due to symfony autoloader
     $mailer = Swift_Mailer::newInstance(Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -t'));
     foreach ($notices as $emp_id => $notices) {
         $employee = EmployeePeer::retrieveByPK($emp_id);
         if ($employee) {
             foreach ($notices as $notice => $expired) {
                 // queue an email of type $notice with this $employee's info
                 switch ($notice) {
                     case 'tb_date':
                         $type = 'Tb';
                         break;
                     case 'physical_date':
                         $type = 'Physical';
                         break;
                 }
                 $mailBody = $this->getPartial('employee/emailExpired' . $type, array('name' => $employee->getFullname(), 'expiration' => $expired));
                 $to_address = $employee->getCompanyEmail() ? $employee->getCompanyEmail() : $employee->getPersonalEmail();
                 $message = Swift_Message::newInstance('Expired ' . $type . ' Notice')->setFrom(array('noreply@nckidsinc.com' => 'North Country Kids, Inc.'))->setTo(array($to_address, 'm.decker@nckidsinc.com'))->setBody($mailBody, 'text/html');
                 // queue it up
                 $mailer->send($message);
                 $mail_count++;
             }
         }
     }
     return $this->renderText($mail_count . ' messages have been sent.');
 }
开发者ID:anvaya,项目名称:nckids,代码行数:32,代码来源:actions.class.php

示例10: getMailer

 /**
  * @return \Swift_Mailer
  */
 protected function getMailer()
 {
     if (null === $this->mailer) {
         $this->mailer = \Swift_Mailer::newInstance($this->transport);
     }
     return $this->mailer;
 }
开发者ID:TransformCore,项目名称:HayPersistenceApi,代码行数:10,代码来源:EmailService.php

示例11: send

 /**
  * Send an email
  * @param SwiftMessage $message
  * @return mixed - TRUE on success, or an array of failed addresses on error.
  */
 static function send($message)
 {
     try {
         require_once 'include/swiftmailer/swift_required.php';
         if (defined('SMTP_SERVER')) {
             $port = defined('SMTP_PORT') ? SMTP_PORT : 25;
             $transport = Swift_SmtpTransport::newInstance(SMTP_SERVER, $port);
             if (defined('SMTP_USERNAME') && SMTP_USERNAME) {
                 $transport->setUsername(SMTP_USERNAME);
             }
             if (defined('SMTP_PASSWORD') && SMTP_PASSWORD) {
                 $transport->setPassword(SMTP_PASSWORD);
             }
             if (defined('SMTP_ENCRYPTION') && SMTP_ENCRYPTION) {
                 $transport->setEncryption(SMTP_ENCRYPTION);
             }
         } else {
             $transport = Swift_MailTransport::newInstance();
         }
         $mailer = Swift_Mailer::newInstance($transport);
         $failures = array();
         $numSent = $mailer->send($message, $failures);
         if (empty($failures) && $numSent) {
             return TRUE;
         }
         return $failures;
     } catch (Exception $e) {
         trigger_error("Could not send email: " . $e->getMessage(), E_USER_WARNING);
         return FALSE;
     }
 }
开发者ID:vanoudt,项目名称:jethro-pmm,代码行数:36,代码来源:emailer.class.php

示例12: initialize

 public function initialize()
 {
     require_once TD_INC . 'swift/swift_required.php';
     if ($this->config['transport'] == 'smtp') {
         $this->transport = Swift_SmtpTransport::newInstance($this->config['smtp_host']);
         if ($this->config['smtp_port']) {
             $this->transport->setPort($this->config['smtp_port']);
         }
         if ($this->config['smtp_encryption']) {
             $this->transport->setEncryption($this->config['smtp_encryption']);
         }
         if ($this->config['smtp_user']) {
             $this->transport->setUsername($this->config['smtp_user']);
         }
         if ($this->config['smtp_pass']) {
             $this->transport->setPassword($this->config['smtp_pass']);
         }
         if ($this->config['smtp_timeout']) {
             $this->transport->setTimeout($this->config['smtp_timeout']);
         }
     } elseif ($this->config['transport'] == 'sendmail') {
         $this->transport = Swift_SendmailTransport::newInstance();
         if ($this->config['sendmail_command']) {
             $this->transport->setCommand($this->config['sendmail_command']);
         }
     } elseif ($this->config['transport'] == 'mail') {
         $this->transport = Swift_MailTransport::newInstance();
     }
     $this->mailer = Swift_Mailer::newInstance($this->transport);
 }
开发者ID:purna89,项目名称:TrellisDesk,代码行数:30,代码来源:class_email.php

示例13: send

 /**
  * Send a mail
  *
  * @param string $subject
  * @param string $content
  * @return bool|string false is everything was fine, or error string
  */
 public function send($subject, $content)
 {
     try {
         // Test with custom SMTP connection
         if ($this->smtp_checked) {
             // Retrocompatibility
             if (Tools::strtolower($this->encryption) === 'off') {
                 $this->encryption = false;
             }
             $smtp = Swift_SmtpTransport::newInstance($this->server, $this->port, $this->encryption);
             $smtp->setUsername($this->login);
             $smtp->setpassword($this->password);
             $smtp->setTimeout(5);
             $swift = Swift_Mailer::newInstance($smtp);
         } else {
             // Test with normal PHP mail() call
             $swift = Swift_Mailer::newInstance(Swift_MailTransport::newInstance());
         }
         $message = Swift_Message::newInstance();
         $message->setFrom($this->email)->setTo('no-reply@' . Tools::getHttpHost(false, false, true))->setSubject($subject)->setBody($content);
         $message = new Swift_Message($subject, $content, 'text/html');
         if (@$swift->send($message)) {
             $result = true;
         } else {
             $result = 'Could not send message';
         }
         $swift->disconnect();
     } catch (Swift_SwiftException $e) {
         $result = $e->getMessage();
     }
     return $result;
 }
开发者ID:prestanesia,项目名称:PrestaShop,代码行数:39,代码来源:mail.php

示例14: index

 function index()
 {
     //Create the Transport
     $transport = Swift_MailTransport::newInstance();
     /*
     You could alternatively use a different transport such as Sendmail or Mail:
     
     //Sendmail
     $transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');
     
     //Mail
     $transport = Swift_MailTransport::newInstance();
     */
     //Create the message
     $message = Swift_Message::newInstance();
     //Give the message a subject
     $message->setSubject('Account Verification')->setFrom(array('noreply@domain.com' => 'CHH IT Team'))->setTo(array('iamremiel@gmail.com' => 'Remmar'))->setBody('Here is the message itself')->addPart('<q>Here is the message itself</q>', 'text/html');
     //Create the Mailer using your created Transport
     $mailer = Swift_Mailer::newInstance($transport);
     //Send the message
     $result = $mailer->send($message);
     if ($result) {
         echo "Email sent successfully";
     } else {
         echo "Email failed to send";
     }
 }
开发者ID:iamremiel,项目名称:hello-there,代码行数:27,代码来源:Swiftmail.php

示例15: sendAppointmentNotif

    public function sendAppointmentNotif($lead)
    {
    	$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')
		->setUsername('dexter.loor@gmail.com')
		->setPassword('rocketman88')
		;

		$mailer = Swift_Mailer::newInstance($transport);

		$body = "Howdy! \n\n" .
		"A new appointment request has been recorded. \n".
		"Below are the details: \n\n".
		"Preferred Date: ".$lead['date']."\n".
		"Preferred Time: ".$lead['time']."\n".
		"Name: ".$lead['fname']." ".$lead['lname']."\n".
		"Email: ".$lead['email']."\n".
		"Contact Number: ".$lead['contact']."\n".
		"Present Country: ".$lead['country']."\n".
		"Nationality: ".$lead['nationality']."\n".
		"Unit Interested in: ".$lead['unit']."\n".
		"Notes: ".$lead['notes']."\n\n".
		"This message was generated at DMCI Leasing Website.";

		$message = Swift_Message::newInstance('New Appointment Request Submitted in Leasing Website')
		->setFrom(array('webmail@leasing.dmcihomes.com' => 'DMCI Leasing Webmaster'))
		->setTo(array('leasing@dmcihomes.com' => 'DMCI Leasing Services'))
		->setBcc(array('dexter.loor@searchoptmedia.com', 'angelo@searchoptmedia.com', 'john.hernandez@searchoptmedia.com'))
		->setBody($body)
		;

		$result = $mailer->send($message);

		return $result;
    }
开发者ID:somidex,项目名称:leasing2016,代码行数:34,代码来源:MailerHandler.php


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