public function testSmtpPortGetterAndSetter() { $origin = new UserEmailOrigin(); $this->assertEquals(null, $origin->getSmtpPort()); $origin->setSmtpPort(123); $this->assertEquals(123, $origin->getSmtpPort()); }
/** * Set SmtpTransport instance or create a new if default mailer transport is not smtp * * @param UserEmailOrigin $userEmailOrigin */ public function prepareSmtpTransport($userEmailOrigin) { if (!$this->smtpTransport) { $username = $userEmailOrigin->getUser(); /** @var Mcrypt $encoder */ $encoder = $this->container->get('oro_security.encoder.mcrypt'); $password = $encoder->decryptData($userEmailOrigin->getPassword()); $host = $userEmailOrigin->getSmtpHost(); $port = $userEmailOrigin->getSmtpPort(); $security = $userEmailOrigin->getSmtpEncryption(); $accessToken = $this->imapEmailGoogleOauth2Manager->getAccessTokenWithCheckingExpiration($userEmailOrigin); $transport = $this->getTransport(); if ($transport instanceof \Swift_SmtpTransport || $transport instanceof \Swift_Transport_EsmtpTransport) { $transport->setHost($host); $transport->setPort($port); $transport->setEncryption($security); } else { $transport = \Swift_SmtpTransport::newInstance($host, $port, $security); } $transport->setUsername($username); if ($accessToken === null) { $transport->setPassword($password); } else { $transport->setAuthMode('XOAUTH2'); $transport->setPassword($accessToken); } $this->smtpTransport = $transport; } }
/** * Set SmtpTransport instance or create a new if default mailer transport is not smtp * * @param UserEmailOrigin $userEmailOrigin */ public function prepareSmtpTransport($userEmailOrigin) { if (!$this->smtpTransport) { $username = $userEmailOrigin->getUser(); /** @var Mcrypt $encoder */ $encoder = $this->container->get('oro_security.encoder.mcrypt'); $password = $encoder->decryptData($userEmailOrigin->getPassword()); $host = $userEmailOrigin->getSmtpHost(); $port = $userEmailOrigin->getSmtpPort(); $security = $userEmailOrigin->getSmtpEncryption(); $transport = $this->getTransport(); if ($transport instanceof \Swift_SmtpTransport || $transport instanceof \Swift_Transport_EsmtpTransport) { $transport->setHost($host); $transport->setPort($port); $transport->setEncryption($security); } else { $transport = \Swift_SmtpTransport::newInstance($host, $port, $security); } $transport->setUsername($username); $transport->setPassword($password); $this->smtpTransport = $transport; } }
/** * Modify transport smtp settings * * @param UserEmailOrigin $userEmailOrigin */ protected function modifySmtpSettings(UserEmailOrigin $userEmailOrigin) { $transport = $this->mailer->getTransport(); if ($transport instanceof \Swift_Transport_EsmtpTransport) { $transport->setHost($userEmailOrigin->getSmtpHost()); $transport->setPort($userEmailOrigin->getSmtpPort()); $transport->setUsername($userEmailOrigin->getUser()); $transport->setPassword($this->encryptor->decryptData($userEmailOrigin->getPassword())); if ($userEmailOrigin->getSmtpEncryption()) { $transport->setEncryption($userEmailOrigin->getSmtpEncryption()); } } }