2020-01-26 20:23:58 +01:00
|
|
|
<?php
|
2020-02-09 15:45:35 +01:00
|
|
|
/**
|
|
|
|
* @copyright Copyright (C) 2020, Friendica
|
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
2020-01-26 20:23:58 +01:00
|
|
|
|
|
|
|
namespace Friendica\Addon\securemail;
|
|
|
|
|
|
|
|
use Friendica\App;
|
|
|
|
use Friendica\App\BaseURL;
|
2021-10-26 21:44:28 +02:00
|
|
|
use Friendica\Core\Config\Capability\IManageConfigValues;
|
|
|
|
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
2022-10-18 22:42:46 +02:00
|
|
|
use Friendica\Core\Session;
|
2021-08-08 19:10:04 +02:00
|
|
|
use Friendica\Model\User;
|
2020-01-26 23:47:15 +01:00
|
|
|
use Friendica\Object\Email;
|
2020-01-26 20:23:58 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class for creating a Test email for the securemail addon
|
|
|
|
*/
|
2020-01-26 23:47:15 +01:00
|
|
|
class SecureTestEmail extends Email
|
2020-01-26 20:23:58 +01:00
|
|
|
{
|
2021-10-26 21:44:28 +02:00
|
|
|
public function __construct(App $a, IManageConfigValues $config, IManagePersonalConfigValues $pConfig, BaseURL $baseUrl)
|
2020-01-26 20:23:58 +01:00
|
|
|
{
|
|
|
|
$sitename = $config->get('config', 'sitename');
|
|
|
|
|
|
|
|
$hostname = $baseUrl->getHostname();
|
|
|
|
if (strpos($hostname, ':')) {
|
|
|
|
$hostname = substr($hostname, 0, strpos($hostname, ':'));
|
|
|
|
}
|
|
|
|
|
|
|
|
$sender_email = $config->get('config', 'sender_email');
|
|
|
|
if (empty($sender_email)) {
|
|
|
|
$sender_email = 'noreply@' . $hostname;
|
|
|
|
}
|
|
|
|
|
2022-10-18 22:42:46 +02:00
|
|
|
$user = User::getById(Session::getLocalUser());
|
2021-08-08 19:10:04 +02:00
|
|
|
|
2020-01-26 20:23:58 +01:00
|
|
|
$subject = 'Friendica - Secure Mail - Test';
|
|
|
|
$message = 'This is a test message from your Friendica Secure Mail addon.';
|
|
|
|
|
|
|
|
// enable addon for test
|
2022-10-18 22:42:46 +02:00
|
|
|
$pConfig->set(Session::getLocalUser(), 'securemail', 'enable', 1);
|
2020-01-26 20:23:58 +01:00
|
|
|
|
2021-08-08 19:10:04 +02:00
|
|
|
parent::__construct($sitename, $sender_email, $sender_email, $user['email'],
|
2020-01-26 20:23:58 +01:00
|
|
|
$subject, "<p>{$message}</p>", $message,
|
2022-10-18 22:42:46 +02:00
|
|
|
[], Session::getLocalUser());
|
2020-01-26 20:23:58 +01:00
|
|
|
}
|
|
|
|
}
|