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

Help links in emails (ex.: to unsubscribe from a mailing list) start email from current account #463

Merged
merged 2 commits into from
Apr 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/imap/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,7 @@ function format_list_headers($mod) {
$section = ' '.$mod->html_safe($name).': ';
foreach ($vals['email'] as $v) {
$sources[] = '<a href="?page=compose&compose_to='.urlencode($mod->html_safe($v)).
'&compose_from='.$mod->get('msg_headers')['Delivered-To'].
'">'.$mod->trans('email').'</a>';
}
foreach ($vals['links'] as $v) {
Expand Down
25 changes: 23 additions & 2 deletions modules/smtp/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,6 @@ public function process() {
*/
class Hm_Handler_process_compose_form_submit extends Hm_Handler_Module {
public function process() {

/* not sending */
if (!array_key_exists('smtp_send', $this->request->post)) {
return;
Expand Down Expand Up @@ -511,6 +510,19 @@ public function process() {
}
}

/**
* Determine if composer_from is set
* @subpackage smtp/handler
*/
class Hm_Handler_smtp_from_replace extends Hm_Handler_Module {
public function process()
{
if (array_key_exists('compose_from', $this->request->get)) {
$this->out('compose_from', $this->request->get['compose_from']);
}
}
}

/**
* Determine if auto-bcc is active
* @subpackage smtp/handler
Expand Down Expand Up @@ -611,6 +623,8 @@ protected function output() {
$html = $this->get('smtp_compose_type', 0);
$msg_path = $this->get('list_path', '');
$msg_uid = $this->get('uid', '');
$from = $this->get('compose_from');

if (!$msg_path) {
$msg_path = $this->get('compose_msg_path', '');
}
Expand Down Expand Up @@ -693,6 +707,13 @@ protected function output() {
foreach ($files as $file) {
$res .= format_attachment_row($file, $this);
}

// If compose_from GET parameter is set, force $recip replacement.
// This ensures any module can force the selected dropdown SMTP server
if ($from) {
$recip = $from;
}

$res .= '</table>'.
smtp_server_dropdown($this->module_output(), $this, $recip, $smtp_id).
'<input class="smtp_send" type="submit" value="'.$this->trans('Send').'" name="smtp_send" '.$send_disabled.'/>'.
Expand Down Expand Up @@ -910,7 +931,7 @@ function smtp_server_dropdown($data, $output_mod, $recip, $selected_id=false) {
if (!$selected && $selected_id !== false && $id == $selected_id) {
$selected = $id;
}
elseif (!$selected && $recip && trim($recip) == trim($vals['user'])) {
if (!$selected && $recip && trim($recip) == trim($vals['user'])) {
$selected = $id;
}
}
Expand Down
2 changes: 2 additions & 0 deletions modules/smtp/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

add_module_to_all_pages('handler', 'smtp_default_server', true, 'smtp', 'load_user_data', 'after');
add_handler('compose', 'load_smtp_reply_to_details', true, 'smtp', 'load_user_data', 'after');
add_handler('compose', 'smtp_from_replace', true, 'smtp', 'load_user_data', 'after');
add_handler('compose', 'load_smtp_servers_from_config', true, 'smtp', 'load_smtp_reply_to_details', 'after');
add_handler('compose', 'add_smtp_servers_to_page_data', true, 'smtp', 'load_smtp_servers_from_config', 'after');
add_handler('compose', 'process_compose_form_submit', true, 'smtp', 'load_smtp_servers_from_config', 'after');
Expand Down Expand Up @@ -97,6 +98,7 @@
'draft_id' => FILTER_VALIDATE_INT,
'compose_to' => FILTER_SANITIZE_STRING,
'mailto_uri' => FILTER_SANITIZE_STRING,
'compose_from' => FILTER_SANITIZE_STRING
),
'allowed_output' => array(
'file_details' => array(FILTER_UNSAFE_RAW, false),
Expand Down