Skip to content

Commit

Permalink
Fix issue salesagility#9457 where test outbound email does not work w…
Browse files Browse the repository at this point in the history
…hen opened

If password is not set, get mailbox using smtp user email address
  • Loading branch information
JackBuchanan committed Jan 25, 2022
1 parent 8798068 commit 04d52ac
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
20 changes: 20 additions & 0 deletions include/OutboundEmail/OutboundEmail.php
Expand Up @@ -142,6 +142,26 @@ public function createUserSystemOverrideAccount($user_id, $user_name = "", $user
return $ob;
}

/**
* Get mailer by using mailboxes smtp user
*
* @param string $email
* @return OutboundEmail|false
*/
public function getMailerByEmail($email)
{
$query = "SELECT id FROM outbound_email WHERE mail_smtpuser = '{$email}' AND deleted = 0";
$rs = $this->db->query($query);
$row = $this->db->fetchByAssoc($rs);
if (!empty($row['id'])) {
$oe = new OutboundEmail();
$oe->retrieve($row['id']);
return $oe;
} else {
return null;
}
}

/**
* Determines if a user needs to set their user name/password for their system
* override account.
Expand Down
11 changes: 5 additions & 6 deletions modules/EmailMan/testOutboundEmail.php
Expand Up @@ -59,13 +59,12 @@
$pass = $_REQUEST['mail_smtppass'];
} elseif (isset($_REQUEST['mail_type'])) {
$oe = new OutboundEmail();
if (is_admin($current_user) && $_REQUEST['mail_type'] == 'system') {
$oe = $oe->getSystemMailerSettings();
} else {
$oe = $oe->getMailerByName($current_user, $_REQUEST['mail_type']);
}
if (!empty($oe)) {
if (!empty($oe) && !empty($_REQUEST["mail_smtpuser"])) {
$oe = $oe->getMailerByEmail($_REQUEST["mail_smtpuser"]);
$pass = $oe->mail_smtppass;
}else{
//if pw cannot be retrieved, use system default
$oe = $oe->getSystemMailerSettings();
}
}
$email = BeanFactory::newBean('Emails');
Expand Down

1 comment on commit 04d52ac

@pstevens71
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested on 7.13.2 and this works! Both the test email after save now works and email from email compose now works.

Please sign in to comment.