smtp fixes
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user