mirror of
https://github.com/friendica/friendica
synced 2025-05-01 23:44:24 +02:00
Set Sitename / site email as sender for system emails
This commit is contained in:
parent
0966cdbb26
commit
9428466d1d
8 changed files with 27 additions and 17 deletions
|
@ -138,11 +138,7 @@ abstract class MailBuilder
|
|||
*/
|
||||
public function build(bool $raw = false)
|
||||
{
|
||||
if (empty($this->recipientAddress)) {
|
||||
throw new InternalServerErrorException('Recipient address is missing.');
|
||||
}
|
||||
|
||||
if ((empty($this->senderName) || empty($this->senderAddress)) &&
|
||||
if ((empty($this->recipientAddress)) &&
|
||||
!empty($this->recipientUid)) {
|
||||
$user = User::getById($this->recipientUid, ['username', 'email']);
|
||||
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
namespace Friendica\Util\EMailer;
|
||||
|
||||
use Exception;
|
||||
use Friendica\App;
|
||||
use Friendica\App\BaseURL;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\Config\IConfig;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||
use Friendica\Util\Emailer;
|
||||
|
||||
/**
|
||||
* Builder for system-wide emails without any dependency to concrete entities (like items, activities, ..)
|
||||
|
@ -26,7 +26,7 @@ class SystemMailBuilder extends MailBuilder
|
|||
/** @var string */
|
||||
protected $siteAdmin;
|
||||
|
||||
public function __construct(L10n $l10n, BaseURL $baseUrl, IConfig $config)
|
||||
public function __construct(App $a, L10n $l10n, BaseURL $baseUrl, IConfig $config)
|
||||
{
|
||||
parent::__construct($l10n, $baseUrl, $config);
|
||||
|
||||
|
@ -37,6 +37,8 @@ class SystemMailBuilder extends MailBuilder
|
|||
} else {
|
||||
$this->siteAdmin = $l10n->t('%s Administrator', $siteName);
|
||||
}
|
||||
|
||||
$this->senderAddress = $a->getSenderEmailAddress();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -107,4 +109,15 @@ class SystemMailBuilder extends MailBuilder
|
|||
'$textversion' => $textVersion,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function build(bool $raw = false)
|
||||
{
|
||||
// for system emails, always use the sitename/site address as the sender
|
||||
$this->withSender($this->config->get('config', 'sitename'), $this->senderAddress);
|
||||
|
||||
return parent::build($raw);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,13 +40,14 @@ class Emailer
|
|||
/**
|
||||
* Creates a new system email
|
||||
*
|
||||
* @param App $a The Friendica app
|
||||
* @param L10n $l10n The chosen language for the new email
|
||||
*
|
||||
* @return SystemMailBuilder
|
||||
*/
|
||||
public function newSystemMail(L10n $l10n)
|
||||
public function newSystemMail(App $a, L10n $l10n)
|
||||
{
|
||||
return new SystemMailBuilder($l10n, $this->baseUrl, $this->config);
|
||||
return new SystemMailBuilder($a, $l10n, $this->baseUrl, $this->config);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue