$hostname = substr($hostname, 0, strpos($hostname, ':'));
}
- $sender_email = $a->getSenderEmailAddress();
+ $sender_email = DI::emailer()->getSiteEmailAddress();
$user = DBA::selectFirst('user', ['nickname', 'page-flags'],
['uid' => $params['uid']]);
$this->baseURL->get();
}
- /**
- * Generates the site's default sender email address
- *
- * @return string
- * @throws HTTPException\InternalServerErrorException
- */
- public function getSenderEmailAddress()
- {
- $sender_email = $this->config->get('config', 'sender_email');
- if (empty($sender_email)) {
- $hostname = $this->baseURL->getHostname();
- if (strpos($hostname, ':')) {
- $hostname = substr($hostname, 0, strpos($hostname, ':'));
- }
-
- $sender_email = 'noreply@' . $hostname;
- }
-
- return $sender_email;
- }
-
/**
* Returns the current theme name. May be overriden by the mobile theme name.
*
}
$additional_headers = 'From: ' . $app->user['email'] . "\n"
- . 'Sender: ' . $app->getSenderEmailAddress() . "\n"
+ . 'Sender: ' . DI::emailer()->getSiteEmailAddress() . "\n"
. 'Content-type: text/plain; charset=UTF-8' . "\n"
. 'Content-transfer-encoding: 8bit';
/** @var string */
protected $siteAdmin;
- public function __construct(App $a, L10n $l10n, BaseURL $baseUrl, IConfig $config)
+ public function __construct(L10n $l10n, BaseURL $baseUrl, IConfig $config, string $siteEmailAddress, string $siteName)
{
parent::__construct($l10n, $baseUrl, $config);
- $siteName = $this->config->get('config', 'sitename');
-
if ($this->config->get('config', 'admin_name')) {
$this->siteAdmin = $l10n->t('%1$s, %2$s Administrator', $this->config->get('config', 'admin_name'), $siteName);
} else {
$this->siteAdmin = $l10n->t('%s Administrator', $siteName);
}
- $this->senderAddress = $a->getSenderEmailAddress();
+ // Set the system wide site address/name as sender (default for system mails)
+ $this->withSender($siteEmailAddress, $siteName);
}
/**
'$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);
- }
}
/** @var App\BaseURL */
private $baseUrl;
+ /** @var string */
+ private $siteEmailAddress;
+ /** @var string */
+ private $siteEmailName;
+
public function __construct(IConfig $config, IPConfig $pConfig, App\BaseURL $baseURL, LoggerInterface $logger)
{
$this->config = $config;
$this->pConfig = $pConfig;
$this->logger = $logger;
$this->baseUrl = $baseURL;
+
+ $this->siteEmailAddress = $this->config->get('config', 'sender_email');
+ if (empty($sysEmailAddress)) {
+ $hostname = $this->baseUrl->getHostname();
+ if (strpos($hostname, ':')) {
+ $hostname = substr($hostname, 0, strpos($hostname, ':'));
+ }
+
+ $this->siteEmailAddress = 'noreply@' . $hostname;
+ }
+
+ $this->siteEmailName = $this->config->get('config', 'sitename', 'Friendica Social Network');
+ }
+
+ /**
+ * Gets the site's default sender email address
+ *
+ * @return string
+ */
+ public function getSiteEmailAddress()
+ {
+ return $this->siteEmailAddress;
+ }
+
+ /**
+ * Gets the site's default sender name
+ *
+ * @return string
+ */
+ public function getSiteEmailName()
+ {
+ return $this->siteEmailName;
}
/**
* 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(App $a, L10n $l10n)
+ public function newSystemMail(L10n $l10n)
{
- return new SystemMailBuilder($a, $l10n, $this->baseUrl, $this->config);
+ return new SystemMailBuilder($l10n, $this->baseUrl, $this->config,
+ $this->getSiteEmailAddress(), $this->getSiteEmailName());
}
/**