當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Swift_SmtpTransport類代碼示例

本文整理匯總了PHP中Swift_SmtpTransport的典型用法代碼示例。如果您正苦於以下問題:PHP Swift_SmtpTransport類的具體用法?PHP Swift_SmtpTransport怎麽用?PHP Swift_SmtpTransport使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Swift_SmtpTransport類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getErrors

 public function getErrors(Config $cfg)
 {
     $i18n = Localization::getTranslator();
     $walletSettings = [];
     $emailSettings = [];
     $providerClass = '';
     try {
         $provider = $cfg->getWalletProvider();
         $providerClass = get_class($provider);
         $provider->verifyOwnership();
     } catch (Exception $e) {
         if (strpos($providerClass, 'CoinbaseWallet') !== false) {
             $walletSettings[] = ['id' => '#wallet-coinbaseApiKey-error', 'error' => $e->getMessage()];
         } else {
             $walletSettings[] = ['id' => '#wallet-id-error', 'error' => $e->getMessage()];
         }
     }
     try {
         $t = new Swift_SmtpTransport('smtp.gmail.com', 465, 'ssl');
         $t->setUsername($cfg->getEmailUsername())->setPassword($cfg->getEmailPassword())->start();
     } catch (Exception $e) {
         $emailSettings[] = ['id' => '#email-username-error', 'error' => $e->getMessage()];
     }
     $errors = [];
     if (!empty($pricingSettings)) {
         $errors['#pricing-settings'] = self::getPricingErrorsFromConfig($cfg);
     }
     if (!empty($walletSettings)) {
         $errors['#wallet-settings'] = $walletSettings;
     }
     if (!empty($emailSettings)) {
         $errors['#email-settings'] = $emailSettings;
     }
     return $errors;
 }
開發者ID:kryptoc,項目名稱:skyhook,代碼行數:35,代碼來源:ConfigVerifier.php

示例2: send

 public function send()
 {
     $smtpTransport = new \Swift_SmtpTransport($this->spoolMailerParam('host'), $this->spoolMailerParam('port'));
     $smtpTransport->setUsername($this->spoolMailerParam('username'));
     $smtpTransport->setPassword($this->spoolMailerParam('password'));
     $this->spool->flushQueue($smtpTransport);
 }
開發者ID:vodas,項目名稱:praktykirepofinito,代碼行數:7,代碼來源:SpoolMailer.php

示例3: init

 /**
  * Initialize the component
  */
 public function init()
 {
     $this->initAutoloader($this->swiftBasePath);
     $this->transport = Swift_SmtpTransport::newInstance($this->host, $this->port, $this->security);
     $this->transport->setUsername($this->username)->setPassword($this->password);
     parent::init();
 }
開發者ID:sobit,項目名稱:swiftmailer-component,代碼行數:10,代碼來源:SwiftMailerComponent.php

示例4: testReport

 public function testReport()
 {
     //  Arrange.
     $transport = new \Swift_SmtpTransport();
     $transport->setHost('mailtrap.io');
     $transport->setPort(2525);
     $transport->setUsername(getenv('MAILTRAP_USERNAME'));
     $transport->setPassword(getenv('MAILTRAP_PASSWORD'));
     $mailer = new Swift_Mailer($transport);
     $message = new Swift_Message();
     $message->addTo('craig.michael.morris@gmail.com');
     $message->setFrom('craig.michael.morris@gmail.com');
     $body = new Body(new VarCloner(), new CliDumper());
     $compiler = new Compiler(new CommonMarkConverter(), new CssToInlineStyles());
     $email = new Email($mailer, $message, $body, $compiler);
     $exception = new DomainException('Testing a domain exception');
     $extra = ['only' => 'testing12321'];
     // Act.
     $email->report($exception, $extra);
     // Assert.
     $message = $this->mailtrap->get('inboxes/' . getenv('MAILTRAP_INBOX') . '/messages')->json()[0];
     $this->assertSame('Exception: Testing a domain exception', $message['subject']);
     $this->assertContains('$email->report($exception, $extra);', $message['text_body']);
     $this->assertContains("exception 'DomainException' with message 'Testing a domain exception'", $message['text_body']);
     $this->assertContains('{main}', $message['text_body']);
     $this->assertContains('"only" => "testing12321"', $message['text_body']);
     $this->assertContains('_SERVER', $message['text_body']);
 }
開發者ID:morrislaptop,項目名稱:error-tracker-adapter-email,代碼行數:28,代碼來源:EmailTest.php

示例5: init

 protected function init($config = array())
 {
     $transport = new \Swift_SmtpTransport($this->smtpHost, $this->smtpPort, $this->smtpSecure);
     $transport->setUsername($this->smtpUser);
     $transport->setPassword($this->smtpPassword);
     $this->mailer = new \Swift_Mailer($transport);
     return parent::init();
 }
開發者ID:mpf-soft,項目名稱:app-basic,代碼行數:8,代碼來源:SwiftMailer.php

示例6: connect

 /**
  * Connect to Mail server
  *
  * @param array $config
  * @return boolean
  */
 public function connect(array $config)
 {
     // Create the Transport
     $this->mailer = new \Swift_SmtpTransport($config['server'], $config['port'], sizeof($config['secure']) > 0 ? $config['secure'] : null);
     $this->mailer->setUsername($config['username']);
     $this->mailer->setPassword($config['password']);
     $this->mailer->start();
     return $this->mailer->isStarted();
 }
開發者ID:stanislav-web,項目名稱:express-mailer,代碼行數:15,代碼來源:LocalDomain.php

示例7: __construct

 /**
  * Mailer constructor.
  * @param $configuration
  */
 public function __construct($configuration)
 {
     $transport = new \Swift_SmtpTransport($configuration["host"], $configuration["port"]);
     $transport->setUsername($configuration["username"]);
     $transport->setPassword($configuration["password"]);
     $transport->setAuthMode($configuration["auth_mode"]);
     $transport->setEncryption($configuration["encryption"]);
     $this->mailer = new \Swift_Mailer($transport);
     $this->debugMail = isset($configuration["debug_email"]) ? $configuration["debug_email"] : null;
 }
開發者ID:nagyatka,項目名稱:kodiapp,代碼行數:14,代碼來源:Mailer.php

示例8: send_breakin_alert

 function send_breakin_alert($email, $password)
 {
     $transporter = new Swift_SmtpTransport('smtp.gmail.com', 465, 'ssl');
     $transporter->setUsername('');
     $transporter->setPassword('');
     $message = new Swift_Message($transporter);
     $message->setTo(array($email => $email));
     $message->setSubject("Note to Myself - Break-in Attempt");
     $message->addPart("Your password has been reset after 3 failed log-in attempts.</br>Your new password is <strong>{$password}</strong>", 'text/html');
     $message->setFrom("", "");
     $mailer = new Swift_Mailer($transporter);
     $mailer->send($message);
 }
開發者ID:TrevorBroderick,項目名稱:bcit-courses,代碼行數:13,代碼來源:Mailer.php

示例9: __getSwiftMailer

 /**
  * @param $from
  * @return \Swift_Mailer
  */
 protected function __getSwiftMailer($from)
 {
     if (!isset($this->swiftMailers[$hash = md5(json_encode($from))])) {
         $transport = new \Swift_SmtpTransport(isset($from['smtpHost']) ? $from['smtpHost'] : '127.0.0.1', isset($from['smtpPort']) ? $from['smtpPort'] : 25, isset($from['smtpSecure']) ? $from['smtpSecure'] : false);
         if (isset($from['smtpUser'])) {
             $transport->setUsername($from['smtpUser']);
         }
         if (isset($from['smtpPassword'])) {
             $transport->setPassword($from['smtpPassword']);
         }
         $this->swiftMailers[$hash] = new \Swift_Mailer($transport);
     }
     return $this->swiftMailers[$hash];
 }
開發者ID:mpf-soft,項目名稱:mpf,代碼行數:18,代碼來源:MailHelper.php

示例10: createSmtpMailer

 /**
  * @param string|null $host
  * @param int|null    $port
  * @param array|null  $headers
  * @param string|null $username
  * @param string|null $password
  * @param string|null $security
  * @return CM_Mail_Mailer
  */
 public function createSmtpMailer($host = null, $port = null, array $headers = null, $username = null, $password = null, $security = null)
 {
     $host = null !== $host ? (string) $host : 'localhost';
     $port = null !== $port ? (int) $port : 25;
     $headers = null !== $headers ? (array) $headers : [];
     $security = null !== $security ? (string) $security : null;
     $transport = new Swift_SmtpTransport($host, $port, $security);
     if (null !== $username) {
         $transport->setUsername((string) $username);
     }
     if (null !== $password) {
         $transport->setPassword((string) $password);
     }
     return new CM_Mail_Mailer($transport, $headers);
 }
開發者ID:cargomedia,項目名稱:cm,代碼行數:24,代碼來源:MailerFactory.php

示例11: __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

示例12: __construct

 function __construct()
 {
     // include swift mailer
     require ENGINE_PATH . 'swiftmailer/classes/Swift.php';
     Swift::init();
     Swift::registerAutoload();
     //Yii::import('system.vendors.swiftMailer.classes.Swift', true);
     //Yii::registerAutoloader(array('Swift','autoload'));
     require_once ENGINE_PATH . 'swiftmailer/swift_init.php';
     //Yii::import('system.vendors.swiftMailer.swift_init', true);
     switch ($this->params['transportType']) {
         case 'smtp':
             $transport = Swift_SmtpTransport::newInstance($this->params['smtpServer'], $this->params['smtpPort'], $this->params['smtpSequre'])->setUsername($this->params['smtpUsername'])->setPassword($this->params['smtpPassword']);
             break;
         case 'sendmail':
             $transport = Swift_SendmailTransport::newInstance($this->params['sendmailCommand']);
             break;
         default:
         case 'mail':
             $transport = Swift_MailTransport::newInstance();
             break;
     }
     $this->toEmail = 'noreplay@' . $_SERVER['HTTP_HOST'];
     $this->fromEmail = 'noreplay@' . $_SERVER['HTTP_HOST'];
     $this->path = "http://" . $_SERVER['HTTP_HOST'] . "/submit/mailtpl/";
     $this->mailer = Swift_Mailer::newInstance($transport);
     $this->mes = Swift_Message::newInstance();
 }
開發者ID:rjon76,項目名稱:netspotapp,代碼行數:28,代碼來源:classEmailReporter.php

示例13: __invoke

 /**
  * Create an object
  *
  * @param  ContainerInterface $container
  * @param  string $requestedName
  * @param  null|array $options
  * @return object|\Swift_Mailer
  * @throws ServiceNotFoundException if unable to resolve the service.
  * @throws ServiceNotCreatedException if an exception is raised when
  *     creating a service.
  * @throws ContainerException if any other error occurs
  */
 public function __invoke(ContainerInterface $container, $requestedName, array $options = null) : \Swift_Mailer
 {
     $mailConfig = $container->get('config')['mail'];
     $smtp = $mailConfig['smtp'];
     $transport = \Swift_SmtpTransport::newInstance($smtp['server'], $smtp['port'], $smtp['ssl'])->setUsername($smtp['username'])->setPassword($smtp['password']);
     return new \Swift_Mailer($transport);
 }
開發者ID:acelaya,項目名稱:alejandrocelaya.com,代碼行數:19,代碼來源:SwiftMailerFactory.php

示例14: respond

 public function respond(array $communication, \stdClass $msg)
 {
     $result = $this->generateResponse($communication);
     if (preg_match('/^\\s*re:/', $msg->subject)) {
         $subject = $msg->subject;
     } else {
         $subject = 'Re: ' . $msg->subject;
     }
     if (isset($this->config['name'])) {
         $from = array($this->config['email_address'] => $this->config['name']);
     } else {
         $from = array($this->config['email_address']);
     }
     $to = array($msg->from_email);
     if (isset($msg->headers->{'Message-Id'})) {
         $message_id = $msg->headers->{'Message-Id'};
     } else {
         $message_id = false;
     }
     // TODO - set reply to id
     $transport = \Swift_SmtpTransport::newInstance('smtp.mandrillapp.com', 587);
     $transport->setUsername($this->config['mandrill_username']);
     $transport->setPassword($this->config['mandrill_password']);
     $swift = \Swift_Mailer::newInstance($transport);
     $message = new \Swift_Message($subject);
     $message->setFrom($from);
     $message->setBody($result);
     $message->setTo($to);
     $result = $swift->send($message);
 }
開發者ID:sriramsv,項目名稱:jarvis,代碼行數:30,代碼來源:MandrillBot.php

示例15: loadConfig

 /**
  * Parse the configuration file
  *
  * @param array $parsedConfig
  */
 private function loadConfig($parsedConfig)
 {
     if (isset($parsedConfig['moduleConf']['Type']) && $parsedConfig['moduleConf']['Type'] == "smtp") {
         $this->transport = \Swift_SmtpTransport::newInstance();
         if (isset($parsedConfig['moduleConf']['Host']) && $parsedConfig['moduleConf']['Host'] != "") {
             $this->transport->setHost($parsedConfig['moduleConf']['Host']);
         }
         if (isset($parsedConfig['moduleConf']['Port']) && $parsedConfig['moduleConf']['Port'] != "") {
             $this->transport->setPort($parsedConfig['moduleConf']['Port']);
         }
         if (isset($parsedConfig['moduleConf']['Username']) && $parsedConfig['moduleConf']['Username'] != "") {
             $this->transport->setUsername($parsedConfig['moduleConf']['Username']);
         }
         if (isset($parsedConfig['moduleConf']['Password']) && $parsedConfig['moduleConf']['Password'] != "") {
             $this->transport->setPassword($parsedConfig['moduleConf']['Password']);
         }
         if (isset($parsedConfig['moduleConf']['Encryption']) && $parsedConfig['moduleConf']['Encryption'] != "") {
             $this->transport->setEncryption($parsedConfig['moduleConf']['Encryption']);
         }
     } elseif (isset($parsedConfig['moduleConf']['Type']) && $parsedConfig['moduleConf']['Type'] == "sendmail") {
         $this->transport = \Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');
     } else {
         $this->transport = \Swift_MailTransport::newInstance();
     }
 }
開發者ID:stonedz,項目名稱:pff2,代碼行數:30,代碼來源:Mail.php


注:本文中的Swift_SmtpTransport類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。