Skip to content

Commit

Permalink
Add mail transport sender option
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-lerch committed Jan 31, 2021
1 parent 4546f42 commit 945b08d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
12 changes: 9 additions & 3 deletions inc/class.rawSmtpMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ public function __construct($exceptions = false) {
$this->Username = $MAIL_TRANSPORT['auth_user'];
$this->Password = $MAIL_TRANSPORT['auth_pass'];
}
if (isset($MAIL_TRANSPORT['sender'])) {
$this->Sender = $MAIL_TRANSPORT['sender'];
}
}

/**
Expand Down Expand Up @@ -353,9 +356,12 @@ public function removeAddresses()
*/
public function setSender($address)
{
$address = trim($address);
$this->Sender = $address;
return true;
if (empty($this->Sender)) {
$this->Sender = trim($address);
return true;
} else {
return false;
}
}

/**
Expand Down
4 changes: 2 additions & 2 deletions install/default/config/ko-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright notice
*
* (c) 2003-2020 Renzo Lauper (renzo@churchtool.org)
* (c) 2019-2020 Daniel Lerch
* (c) 2019-2021 Daniel Lerch
* All rights reserved
*
* This script is part of the kOOL project. The kOOL project is
Expand Down Expand Up @@ -62,7 +62,7 @@

//Transport settings for email (using SwiftMailer)
//method can be: smtp, mail or sendmail
//$MAIL_TRANSPORT = array('method' => 'smtp', 'host' => '', 'port' => '', 'ssl' => FALSE, 'tls' => FALSE, 'auth_user' => '', 'auth_pass' => '');
//$MAIL_TRANSPORT = array('method' => 'smtp', 'host' => '', 'port' => '', 'ssl' => FALSE, 'tls' => FALSE, 'auth_user' => '', 'auth_pass' => '', 'sender' => '');

//SMS-Parameter
$SMS_PARAMETER = array('provider' => '', 'user' => '', 'pass' => '');
Expand Down
9 changes: 7 additions & 2 deletions mailing.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Copyright notice
*
* (c) 2003-2020 Renzo Lauper (renzo@churchtool.org)
* (c) 2019-2020 Daniel Lerch
* (c) 2019-2021 Daniel Lerch
* All rights reserved
*
* This script is part of the kOOL project. The kOOL project is
Expand Down Expand Up @@ -249,7 +249,7 @@ function ko_mailing_main ($test = false, $mail_id_in = null, $recipient_in = nul
if(!isset($unique_mails[$mail['message_id']])) {
//Get all recipients of this email
$header = imap_rfc822_parse_headers($rawheader);
$mail_recipients = array();
$mail_recipients = array('to' => array(), 'cc' => array());
foreach($header->to as $obj) {
$mail_recipients['to'][] = format_userinput($obj->mailbox.'@'.$obj->host, 'email');
}
Expand All @@ -260,6 +260,11 @@ function ko_mailing_main ($test = false, $mail_id_in = null, $recipient_in = nul
'mail' => $mail,
'recipients' => $mail_recipients,
);
if ($verbose) {
print "TO: " . implode(", ", $mail_recipients['to']) . PHP_EOL;
print "CC: " . implode(", ", $mail_recipients['cc']) . PHP_EOL;
print "Skipped BCCs: " . count($header->bcc) . PHP_EOL;
}
} else {
$mail_recipients = $unique_mails[$mail['message_id']];
}
Expand Down

0 comments on commit 945b08d

Please sign in to comment.