refactor smtp preferences
This commit is contained in:
@@ -25,9 +25,21 @@ namespace Espo\Entities;
|
||||
class Preferences extends \Espo\Core\ORM\Entity
|
||||
{
|
||||
|
||||
public function getSmtpSettings()
|
||||
public function getSmtpParams()
|
||||
{
|
||||
// TODO
|
||||
$smtpParams = array();
|
||||
$smtpParams['server'] = $this->get('smtpServer');
|
||||
if ($smtpParams['server']) {
|
||||
$smtpParams['port'] = $this->get('smtpPort');
|
||||
$smtpParams['server'] = $this->get('smtpServer');
|
||||
$smtpParams['auth'] = $this->get('smtpAuth');
|
||||
$smtpParams['security'] = $this->get('smtpSecurity');
|
||||
$smtpParams['username'] = $this->get('smtpUsername');
|
||||
$smtpParams['password'] = $this->get('smtpPassword');
|
||||
return $smtpParams;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class Email extends Record
|
||||
protected function getPreferences()
|
||||
{
|
||||
return $this->injections['preferences'];
|
||||
}
|
||||
}
|
||||
|
||||
public function createEntity($data)
|
||||
{
|
||||
@@ -52,18 +52,10 @@ class Email extends Record
|
||||
if ($entity && $entity->get('status') == 'Sending') {
|
||||
$emailSender = $this->getMailSender();
|
||||
|
||||
if (strtolower($this->getUser()->get('emailAddress')) == strtolower($entity->get('from'))) {
|
||||
$smtpParams = array();
|
||||
$smtpParams['server'] = $this->getPreferences()->get('smtpServer');
|
||||
if (!empty($smtpParams['server'])) {
|
||||
$smtpParams['fromName'] = $this->getUser()->get('name');
|
||||
$smtpParams['port'] = $this->getPreferences()->get('smtpPort');
|
||||
$smtpParams['server'] = $this->getPreferences()->get('smtpServer');
|
||||
$smtpParams['auth'] = $this->getPreferences()->get('smtpAuth');
|
||||
$smtpParams['security'] = $this->getPreferences()->get('smtpSecurity');
|
||||
$smtpParams['username'] = $this->getPreferences()->get('smtpUsername');
|
||||
$smtpParams['password'] = $this->getPreferences()->get('smtpPassword');
|
||||
|
||||
if (strtolower($this->getUser()->get('emailAddress')) == strtolower($entity->get('from'))) {
|
||||
$smtpParams = $this->getPreferences()->getSmtpParams();
|
||||
if ($smtpParams) {
|
||||
$smtpParams['fromName'] = $this->getUser()->get('name');
|
||||
$emailSender->useSmtp($smtpParams);
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user