Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#4111 - Problem sending emails from group accounts when inbound email… #4168

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 40 additions & 1 deletion include/OutboundEmail/OutboundEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,13 @@ function getInboundMailerSettings($user, $mailer_id='', $ieId='') {

if(isset($opts['outbound_email'])) {
$mailer = "id = '{$opts['outbound_email']}'";
} else {
}
elseif( isset($opts['from_addr']) ){
// Lookup outbound email settings for this account
$account = $this->getOutgoingMailerSettingsForSpecificAccount( $opts['from_addr'] );
$mailer = "id = '{$account->id}'";
}
else {
$mailer = "id = '{$ieId}'";
}
} else {
Expand Down Expand Up @@ -416,6 +422,39 @@ function getSystemMailerSettings() {
return $ret;
}

/**
*
* Retrieves the system's Outbound options for a specified email address
*/
function getOutgoingMailerSettingsForSpecificAccount($email_account_address) {
$q = "SELECT id FROM outbound_email WHERE deleted = 0 and mail_smtpuser = '$email_account_address'";
$r = $this->db->query($q);
$a = $this->db->fetchByAssoc($r);

if(empty($a)) {
$this->id = "";
$this->name = 'system';
$this->type = 'system';
$this->user_id = '1';
$this->mail_sendtype = 'SMTP';
$this->mail_smtptype = 'other';
$this->mail_smtpserver = '';
$this->mail_smtpport = 25;
$this->mail_smtpuser = '';
$this->mail_smtppass = '';
$this->mail_smtpauth_req = 1;
$this->mail_smtpssl = 0;
$this->mail_smtpdisplay = $this->_getOutboundServerDisplay($this->mail_smtptype,$this->mail_smtpserver);
$this->save();
$ret = $this;
} else {
$ret = $this->retrieve($a['id']);
}

return $ret;
}


/**
* Populates this instance
* @param string $id
Expand Down
9 changes: 6 additions & 3 deletions modules/Emails/EmailsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ public function action_send()

// parse and replace bean variables
$this->bean = $this->replaceEmailVariables($this->bean, $request);


$this->bean->reply_to_name = $inboundEmailAccount->name;
$this->bean->from_name = $inboundEmailAccount->name;

if ($this->bean->send()) {
$this->bean->status = 'sent';
$this->bean->save();
Expand Down Expand Up @@ -369,7 +372,7 @@ public function action_GetFromFields()

$data = array();
foreach ($accounts as $inboundEmailId => $inboundEmail) {
if(in_array($inboundEmail->id, $showFolders)) {
// if(in_array($inboundEmail->id, $showFolders)) {
$storedOptions = unserialize(base64_decode($inboundEmail->stored_options));
$isGroupEmailAccount = $inboundEmail->isGroupEmailAccount();
$isPersonalEmailAccount = $inboundEmail->isPersonalEmailAccount();
Expand Down Expand Up @@ -411,7 +414,7 @@ public function action_GetFromFields()
}

$data[] = $dataAddress;
}
// }
}

$dataEncoded = json_encode(array('data' => $data));
Expand Down
1 change: 1 addition & 0 deletions modules/Emails/views/view.compose.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
die ('Not A Valid Entry Point');
}

require_once('include/OutboundEmail/OutboundEmail.php');

class EmailsViewCompose extends ViewEdit {

Expand Down