smtp fixes

This commit is contained in:
yuri
2019-03-05 18:16:21 +02:00
parent e91184064c
commit bc397f9dcf
2 changed files with 23 additions and 5 deletions
+21 -4
View File
@@ -813,24 +813,41 @@ class Email extends Record
}
}
return array(
return [
'ids' => $ids,
'names' => $names
);
];
}
public function sendTestEmail($data)
{
$smtpParams = $data;
$userId = $data['userId'] ?? null;
$fromAddress = $data['fromAddress'] ?? null;
if ($userId) {
if ($userId !== $this->getUser()->id && !$this->getUser()->isAdmin()) {
throw new Forbidden();
}
}
$email = $this->getEntityManager()->getEntity('Email');
$email->set([
'subject' => 'EspoCRM: Test Email',
'isHtml' => false,
'to' => $data['emailAddress']
'to' => $data['emailAddress'],
]);
if ($userId) {
if ($fromAddress) {
$this->applySmtpHandler($userId, $fromAddress, $smtpParams);
}
}
$emailSender = $this->getMailSender();
$emailSender->useSmtp($data)->send($email);
$emailSender->useSmtp($smtpParams)->send($email);
return true;
}
@@ -58,7 +58,8 @@ Espo.define('views/email-account/fields/test-send', 'views/outbound-email/fields
'fromName': this.getUser().get('name'),
'fromAddress': this.model.get('emailAddress'),
'type': 'emailAccount',
'id': this.model.id
'id': this.model.id,
'userId': this.model.get('assignedUserId'),
};
return data;
}