Skip to content

Commit

Permalink
Merge pull request #475 from henrique-borba/fix-draft-default-smtp
Browse files Browse the repository at this point in the history
Fixed default SMTP server when editing a Draft
  • Loading branch information
jasonmunro authored May 20, 2021
2 parents d3ed099 + 87305bf commit 4d632ed
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions modules/smtp/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ public function process() {
$msg_struct = $imap->get_message_structure($this->request->get['uid']);
list($part, $msg_text) = $imap->get_first_message_part($this->request->get['uid'], 'text', 'plain', $msg_struct);
$msg_header = $imap->get_message_headers($this->request->get['uid']);

$imap_draft = array(
'From' => $msg_header['From'],
'To' => $msg_header['To'],
'Subject' => $msg_header['Subject'],
'Message-Id' => $msg_header['Message-Id'],
'Content-Type' => $msg_header['Content-Type'],
'Body' => $msg_text
'Body' => $msg_text,
'Reply-To' => $msg_header['Reply-To']
);

if (array_key_exists('Cc', $msg_header)) {
Expand Down Expand Up @@ -701,6 +701,11 @@ protected function output() {
$this->get('smtp_servers', array()));
}

if(!empty($imap_draft)) {
$recip = get_primary_recipient($this->get('compose_profiles', array()), $imap_draft,
$this->get('smtp_servers', array()));
}

if (!empty($draft)) {
if (array_key_exists('draft_to', $draft)) {
$to = $draft['draft_to'];
Expand Down Expand Up @@ -1168,7 +1173,7 @@ function format_attachment_row($file, $output_mod) {
if (!hm_exists('get_primary_recipient')) {
function get_primary_recipient($profiles, $headers, $smtp_servers) {
$addresses = array();
$flds = array('delivered-to', 'x-delivered-to', 'envelope-to', 'x-original-to', 'to', 'cc');
$flds = array('delivered-to', 'x-delivered-to', 'envelope-to', 'x-original-to', 'to', 'cc', 'reply-to');
$headers = lc_headers($headers);
foreach ($flds as $fld) {
if (array_key_exists($fld, $headers)) {
Expand Down

0 comments on commit 4d632ed

Please sign in to comment.