mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-07-07 00:48:55 +00:00
Introduce interface for emailing and create email classes
This commit is contained in:
parent
b828762910
commit
49254a8307
4 changed files with 91 additions and 49 deletions
40
securemail/SecureTestEMail.php
Normal file
40
securemail/SecureTestEMail.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Addon\securemail;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\App\BaseURL;
|
||||
use Friendica\Core\Config\IConfig;
|
||||
use Friendica\Core\PConfig\IPConfig;
|
||||
use Friendica\Object\EMail;
|
||||
|
||||
/**
|
||||
* Class for creating a Test email for the securemail addon
|
||||
*/
|
||||
class SecureTestEMail extends EMail
|
||||
{
|
||||
public function __construct(App $a, IConfig $config, IPConfig $pConfig, BaseURL $baseUrl)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
$subject = 'Friendica - Secure Mail - Test';
|
||||
$message = 'This is a test message from your Friendica Secure Mail addon.';
|
||||
|
||||
// enable addon for test
|
||||
$pConfig->set(local_user(), 'securemail', 'enable', 1);
|
||||
|
||||
parent::__construct($sitename, $sender_email, $sender_email, $a->user['email'],
|
||||
$subject, "<p>{$message}</p>", $message,
|
||||
'', local_user());
|
||||
}
|
||||
}
|
|
@ -6,12 +6,12 @@
|
|||
* Author: Fabio Comuni <http://kirgroup.com/profile/fabrixxm>
|
||||
*/
|
||||
|
||||
use Friendica\Addon\securemail\SecureTestEMail;
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
use Friendica\Util\Emailer;
|
||||
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
|
@ -88,27 +88,8 @@ function securemail_settings_post(App &$a, array &$b)
|
|||
info(DI::l10n()->t('Secure Mail Settings saved.') . EOL);
|
||||
|
||||
if ($_POST['securemail-submit'] == DI::l10n()->t('Save and send test')) {
|
||||
$sitename = DI::config()->get('config', 'sitename');
|
||||
|
||||
$hostname = DI::baseUrl()->getHostname();
|
||||
if (strpos($hostname, ':')) {
|
||||
$hostname = substr($hostname, 0, strpos($hostname, ':'));
|
||||
}
|
||||
|
||||
$sender_email = DI::config()->get('config', 'sender_email');
|
||||
if (empty($sender_email)) {
|
||||
$sender_email = 'noreply@' . $hostname;
|
||||
}
|
||||
|
||||
$subject = 'Friendica - Secure Mail - Test';
|
||||
$message = 'This is a test message from your Friendica Secure Mail addon.';
|
||||
|
||||
// enable addon for test
|
||||
DI::pConfig()->set(local_user(), 'securemail', 'enable', 1);
|
||||
|
||||
$res = DI::emailer()->send($sitename, $sender_email, $sender_email,
|
||||
$a->user['email'], $subject, "<p>{$message}</p>", $message,
|
||||
'', local_user());
|
||||
$res = DI::emailer()->send(new SecureTestEMail(DI::app(), DI::config(), DI::pConfig(), DI::baseUrl()));
|
||||
|
||||
// revert to saved value
|
||||
DI::pConfig()->set(local_user(), 'securemail', 'enable', $enable);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue