bring phpmailer to core

This commit is contained in:
Mike Macgirvin 2023-12-24 08:02:43 +11:00
parent ea64bec032
commit 0ccfc10253
5 changed files with 553 additions and 110 deletions

View file

@ -812,7 +812,7 @@ class Enotify
$addrs = explode(',', $to_email);
foreach ($addrs as $addr) {
self::send([
z_mail([
'fromName' => $sender_name,
'fromEmail' => $sender_email,
'replyTo' => $reply_email,
@ -828,76 +828,6 @@ class Enotify
pop_lang();
}
/**
* @brief Send a multipart/alternative message with Text and HTML versions.
*
* @param array $params an associative array with:
* * \e string \b fromName name of the sender
* * \e string \b fromEmail email of the sender
* * \e string \b replyTo address to direct responses
* * \e string \b toEmail destination email address
* * \e string \b messageSubject subject of the message
* * \e string \b htmlVersion html version of the message
* * \e string \b textVersion text only version of the message
* * \e string \b additionalMailHeader additions to the smtp mail header
*/
public static function send($params)
{
$params['sent'] = false;
$params['result'] = false;
Hook::call('email_send', $params);
if ($params['sent']) {
logger("notification: enotify::send (addon) returns " . (($params['result']) ? 'success' : 'failure'), LOGGER_DEBUG);
return $params['result'];
}
$fromName = email_header_encode(html_entity_decode($params['fromName'], ENT_QUOTES, 'UTF-8'), 'UTF-8');
$messageSubject = email_header_encode(html_entity_decode($params['messageSubject'], ENT_QUOTES, 'UTF-8'), 'UTF-8');
// generate a mime boundary
$mimeBoundary = rand(0, 9) . "-"
. rand(100000000, 999999999) . "-"
. rand(100000000, 999999999) . "=:"
. rand(10000, 99999);
// generate a multipart/alternative message header
$messageHeader =
$params['additionalMailHeader'] .
"From: $fromName <{$params['fromEmail']}>" . PHP_EOL .
"Reply-To: $fromName <{$params['replyTo']}>" . PHP_EOL .
"MIME-Version: 1.0" . PHP_EOL .
"Content-Type: multipart/alternative; boundary=\"$mimeBoundary\"";
// assemble the final multipart message body with the text and html types included
$textBody = chunk_split(base64_encode($params['textVersion']));
$htmlBody = chunk_split(base64_encode($params['htmlVersion']));
$multipartMessageBody =
"--" . $mimeBoundary . PHP_EOL . // plain text section
"Content-Type: text/plain; charset=UTF-8" . PHP_EOL .
"Content-Transfer-Encoding: base64" . PHP_EOL . PHP_EOL .
$textBody . PHP_EOL .
"--" . $mimeBoundary . PHP_EOL . // text/html section
"Content-Type: text/html; charset=UTF-8" . PHP_EOL .
"Content-Transfer-Encoding: base64" . PHP_EOL . PHP_EOL .
$htmlBody . PHP_EOL .
"--" . $mimeBoundary . "--" . PHP_EOL; // message ending
// send the message
$res = mail(
$params['toEmail'], // send to address
$messageSubject, // subject
$multipartMessageBody, // message body
$messageHeader // message headers
);
logger("notification: enotify::send returns " . (($res) ? 'success' : 'failure'), LOGGER_DEBUG);
return $res;
}
public static function format($item)
{

View file

@ -46,7 +46,10 @@
"indieweb/rel-me": "^0.1.1",
"minishlink/web-push": "^8.0",
"stephenhill/base58": "^1.1",
"mmccook/php-json-canonicalization-scheme": "^1.0"
"mmccook/php-json-canonicalization-scheme": "^1.0",
"phpmailer/phpmailer": "^6.9",
"league/oauth2-google": "^4.0",
"decomplexity/sendoauth2": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "@stable",

381
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "610c29f51dd5ac0f06a87f6e76cd74ca",
"content-hash": "b3868819f32f5a9365680bd913227095",
"packages": [
{
"name": "beberlei/assert",
@ -450,6 +450,56 @@
},
"time": "2017-12-29T00:13:05+00:00"
},
{
"name": "decomplexity/sendoauth2",
"version": "V3.0",
"source": {
"type": "git",
"url": "https://github.com/decomplexity/SendOauth2.git",
"reference": "1b6ff035b10f55bac5393d2b13c4d2efa7b8672e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/decomplexity/SendOauth2/zipball/1b6ff035b10f55bac5393d2b13c4d2efa7b8672e",
"reference": "1b6ff035b10f55bac5393d2b13c4d2efa7b8672e",
"shasum": ""
},
"require": {
"league/oauth2-google": ">=4.0.0",
"php": ">=5.5.0",
"phpmailer/phpmailer": ">=6.6.0",
"thenetworg/oauth2-azure": ">=2.2.1"
},
"type": "library",
"autoload": {
"psr-4": {
"decomplexity\\SendOauth2\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Max Stewart",
"email": "SendOauth2@decomplexity.com",
"homepage": "https://www.decomplexity.com"
}
],
"description": "Wrapper for PHPMailer SMTP",
"homepage": "https://github.com/decomplexity/SendOauth2",
"keywords": [
"oauth2",
"phpmailer"
],
"support": {
"email": "SendOauth2@decomplexity.com",
"issues": "https://github.com/decomplexity/SendOauth2/issues",
"source": "https://github.com/decomplexity/SendOauth2/tree/V3.0"
},
"time": "2023-11-21T20:26:04+00:00"
},
{
"name": "doctrine/collections",
"version": "1.8.0",
@ -849,6 +899,69 @@
"abandoned": true,
"time": "2022-12-19T11:08:26+00:00"
},
{
"name": "firebase/php-jwt",
"version": "v6.10.0",
"source": {
"type": "git",
"url": "https://github.com/firebase/php-jwt.git",
"reference": "a49db6f0a5033aef5143295342f1c95521b075ff"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/firebase/php-jwt/zipball/a49db6f0a5033aef5143295342f1c95521b075ff",
"reference": "a49db6f0a5033aef5143295342f1c95521b075ff",
"shasum": ""
},
"require": {
"php": "^7.4||^8.0"
},
"require-dev": {
"guzzlehttp/guzzle": "^6.5||^7.4",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.5",
"psr/cache": "^1.0||^2.0",
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0"
},
"suggest": {
"ext-sodium": "Support EdDSA (Ed25519) signatures",
"paragonie/sodium_compat": "Support EdDSA (Ed25519) signatures when libsodium is not present"
},
"type": "library",
"autoload": {
"psr-4": {
"Firebase\\JWT\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Neuman Vong",
"email": "neuman+pear@twilio.com",
"role": "Developer"
},
{
"name": "Anant Narayanan",
"email": "anant@php.net",
"role": "Developer"
}
],
"description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.",
"homepage": "https://github.com/firebase/php-jwt",
"keywords": [
"jwt",
"php"
],
"support": {
"issues": "https://github.com/firebase/php-jwt/issues",
"source": "https://github.com/firebase/php-jwt/tree/v6.10.0"
},
"time": "2023-12-01T16:26:39+00:00"
},
{
"name": "forkawesome/fork-awesome",
"version": "1.2",
@ -1462,6 +1575,131 @@
],
"time": "2020-07-01T00:34:03+00:00"
},
{
"name": "league/oauth2-client",
"version": "2.7.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/oauth2-client.git",
"reference": "160d6274b03562ebeb55ed18399281d8118b76c8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/oauth2-client/zipball/160d6274b03562ebeb55ed18399281d8118b76c8",
"reference": "160d6274b03562ebeb55ed18399281d8118b76c8",
"shasum": ""
},
"require": {
"guzzlehttp/guzzle": "^6.0 || ^7.0",
"paragonie/random_compat": "^1 || ^2 || ^9.99",
"php": "^5.6 || ^7.0 || ^8.0"
},
"require-dev": {
"mockery/mockery": "^1.3.5",
"php-parallel-lint/php-parallel-lint": "^1.3.1",
"phpunit/phpunit": "^5.7 || ^6.0 || ^9.5",
"squizlabs/php_codesniffer": "^2.3 || ^3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-2.x": "2.0.x-dev"
}
},
"autoload": {
"psr-4": {
"League\\OAuth2\\Client\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Alex Bilbie",
"email": "hello@alexbilbie.com",
"homepage": "http://www.alexbilbie.com",
"role": "Developer"
},
{
"name": "Woody Gilk",
"homepage": "https://github.com/shadowhand",
"role": "Contributor"
}
],
"description": "OAuth 2.0 Client Library",
"keywords": [
"Authentication",
"SSO",
"authorization",
"identity",
"idp",
"oauth",
"oauth2",
"single sign on"
],
"support": {
"issues": "https://github.com/thephpleague/oauth2-client/issues",
"source": "https://github.com/thephpleague/oauth2-client/tree/2.7.0"
},
"time": "2023-04-16T18:19:15+00:00"
},
{
"name": "league/oauth2-google",
"version": "4.0.1",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/oauth2-google.git",
"reference": "1b01ba18ba31b29e88771e3e0979e5c91d4afe76"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/oauth2-google/zipball/1b01ba18ba31b29e88771e3e0979e5c91d4afe76",
"reference": "1b01ba18ba31b29e88771e3e0979e5c91d4afe76",
"shasum": ""
},
"require": {
"league/oauth2-client": "^2.0",
"php": "^7.3 || ^8.0"
},
"require-dev": {
"eloquent/phony-phpunit": "^6.0 || ^7.1",
"phpunit/phpunit": "^8.0 || ^9.0",
"squizlabs/php_codesniffer": "^3.0"
},
"type": "library",
"autoload": {
"psr-4": {
"League\\OAuth2\\Client\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Woody Gilk",
"email": "hello@shadowhand.com",
"homepage": "https://shadowhand.com"
}
],
"description": "Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client",
"keywords": [
"Authentication",
"authorization",
"client",
"google",
"oauth",
"oauth2"
],
"support": {
"issues": "https://github.com/thephpleague/oauth2-google/issues",
"source": "https://github.com/thephpleague/oauth2-google/tree/4.0.1"
},
"time": "2023-03-17T15:20:52+00:00"
},
{
"name": "masterminds/html5",
"version": "2.8.1",
@ -1931,6 +2169,87 @@
},
"time": "2020-10-15T08:29:30+00:00"
},
{
"name": "phpmailer/phpmailer",
"version": "v6.9.1",
"source": {
"type": "git",
"url": "https://github.com/PHPMailer/PHPMailer.git",
"reference": "039de174cd9c17a8389754d3b877a2ed22743e18"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/039de174cd9c17a8389754d3b877a2ed22743e18",
"reference": "039de174cd9c17a8389754d3b877a2ed22743e18",
"shasum": ""
},
"require": {
"ext-ctype": "*",
"ext-filter": "*",
"ext-hash": "*",
"php": ">=5.5.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"doctrine/annotations": "^1.2.6 || ^1.13.3",
"php-parallel-lint/php-console-highlighter": "^1.0.0",
"php-parallel-lint/php-parallel-lint": "^1.3.2",
"phpcompatibility/php-compatibility": "^9.3.5",
"roave/security-advisories": "dev-latest",
"squizlabs/php_codesniffer": "^3.7.2",
"yoast/phpunit-polyfills": "^1.0.4"
},
"suggest": {
"decomplexity/SendOauth2": "Adapter for using XOAUTH2 authentication",
"ext-mbstring": "Needed to send email in multibyte encoding charset or decode encoded addresses",
"ext-openssl": "Needed for secure SMTP sending and DKIM signing",
"greew/oauth2-azure-provider": "Needed for Microsoft Azure XOAUTH2 authentication",
"hayageek/oauth2-yahoo": "Needed for Yahoo XOAUTH2 authentication",
"league/oauth2-google": "Needed for Google XOAUTH2 authentication",
"psr/log": "For optional PSR-3 debug logging",
"symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)",
"thenetworg/oauth2-azure": "Needed for Microsoft XOAUTH2 authentication"
},
"type": "library",
"autoload": {
"psr-4": {
"PHPMailer\\PHPMailer\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-2.1-only"
],
"authors": [
{
"name": "Marcus Bointon",
"email": "phpmailer@synchromedia.co.uk"
},
{
"name": "Jim Jagielski",
"email": "jimjag@gmail.com"
},
{
"name": "Andy Prevost",
"email": "codeworxtech@users.sourceforge.net"
},
{
"name": "Brent R. Matzelle"
}
],
"description": "PHPMailer is a full-featured email creation and transfer class for PHP",
"support": {
"issues": "https://github.com/PHPMailer/PHPMailer/issues",
"source": "https://github.com/PHPMailer/PHPMailer/tree/v6.9.1"
},
"funding": [
{
"url": "https://github.com/Synchro",
"type": "github"
}
],
"time": "2023-11-25T22:23:28+00:00"
},
{
"name": "phpseclib/phpseclib",
"version": "2.0.44",
@ -4784,6 +5103,66 @@
},
"time": "2023-04-05T11:54:14+00:00"
},
{
"name": "thenetworg/oauth2-azure",
"version": "v2.2.2",
"source": {
"type": "git",
"url": "https://github.com/TheNetworg/oauth2-azure.git",
"reference": "be204a5135f016470a9c33e82ab48785bbc11af2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/TheNetworg/oauth2-azure/zipball/be204a5135f016470a9c33e82ab48785bbc11af2",
"reference": "be204a5135f016470a9c33e82ab48785bbc11af2",
"shasum": ""
},
"require": {
"ext-json": "*",
"ext-openssl": "*",
"firebase/php-jwt": "~3.0||~4.0||~5.0||~6.0",
"league/oauth2-client": "~2.0",
"php": "^7.1|^8.0"
},
"require-dev": {
"phpunit/phpunit": "^9.6"
},
"type": "library",
"autoload": {
"psr-4": {
"TheNetworg\\OAuth2\\Client\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jan Hajek",
"email": "jan.hajek@thenetw.org",
"homepage": "https://thenetw.org"
}
],
"description": "Azure Active Directory OAuth 2.0 Client Provider for The PHP League OAuth2-Client",
"keywords": [
"SSO",
"aad",
"authorization",
"azure",
"azure active directory",
"client",
"microsoft",
"oauth",
"oauth2",
"windows azure"
],
"support": {
"issues": "https://github.com/TheNetworg/oauth2-azure/issues",
"source": "https://github.com/TheNetworg/oauth2-azure/tree/v2.2.2"
},
"time": "2023-12-19T12:10:48+00:00"
},
{
"name": "twbs/bootstrap",
"version": "v5.3.1",

View file

@ -1,5 +1,6 @@
<?php
use Code\Lib\Config;
use Code\Lib\Libzot;
use Code\Lib\Zotfinger;
use Code\Lib\Webfinger;
@ -16,6 +17,11 @@ use Code\Daemon\Run;
use Code\Extend\Hook;
use Code\Storage\Stdio;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
require_once('library/jsonld/jsonld.php');
/**
* @file include/network.php
@ -246,7 +252,7 @@ function validate_url(&$url)
function validate_email($addr)
{
if (get_config('system', 'disable_email_validation')) {
if (Config::Get('system', 'disable_email_validation')) {
return true;
}
@ -280,8 +286,8 @@ function allowed_email($email)
return false;
}
$str_allowed = get_config('system', 'allowed_email');
$str_not_allowed = get_config('system', 'not_allowed_email');
$str_allowed = Config::Get('system', 'allowed_email');
$str_not_allowed = Config::Get('system', 'not_allowed_email');
if (! $str_allowed && ! $str_not_allowed) {
return true;
@ -779,7 +785,7 @@ function do_delivery($deliveries, $force = false)
}
$x = q("select count(outq_hash) as total from outq where outq_delivered = 0");
if (intval($x[0]['total']) > intval(get_config('system', 'force_queue_threshold', 3000)) && (! $force)) {
if (intval($x[0]['total']) > intval(Config::Get('system', 'force_queue_threshold', 3000)) && (! $force)) {
logger('immediate delivery deferred.', LOGGER_DEBUG, LOG_INFO);
foreach ($deliveries as $d) {
Queue::update($d, 'Delivery deferred');
@ -787,8 +793,8 @@ function do_delivery($deliveries, $force = false)
return;
}
$interval = intval(get_config('system', 'delivery_interval',2));
$deliveries_per_process = intval(get_config('system', 'delivery_batch_count'));
$interval = intval(Config::Get('system', 'delivery_interval',2));
$deliveries_per_process = intval(Config::Get('system', 'delivery_batch_count'));
if ($deliveries_per_process <= 0) {
$deliveries_per_process = 1;
@ -841,9 +847,9 @@ function get_site_info()
$admin = false;
}
$def_service_class = get_config('system', 'default_service_class');
$def_service_class = Config::Get('system', 'default_service_class');
if ($def_service_class) {
$service_class = get_config('service_class', $def_service_class);
$service_class = Config::Get('service_class', $def_service_class);
} else {
$service_class = false;
}
@ -857,9 +863,9 @@ function get_site_info()
$commit = '';
}
$site_info = get_config('system', 'info');
$site_name = get_config('system', 'sitename');
if (! get_config('system', 'hidden_version_siteinfo')) {
$site_info = Config::Get('system', 'info');
$site_name = Config::Get('system', 'sitename');
if (! Config::Get('system', 'hidden_version_siteinfo')) {
$version = System::get_project_version();
if (@is_dir('.git') && function_exists('shell_exec')) {
@ -873,7 +879,7 @@ function get_site_info()
$version = $commit = '';
}
$site_expire = intval(get_config('system', 'default_expire_days'));
$site_expire = intval(Config::Get('system', 'default_expire_days'));
load_config('feature_lock');
$locked_features = [];
@ -887,7 +893,7 @@ function get_site_info()
}
$protocols = [ 'nomad', 'zot6' ];
if (get_config('system', 'activitypub', ACTIVITYPUB_ENABLED)) {
if (Config::Get('system', 'activitypub', ACTIVITYPUB_ENABLED)) {
$protocols[] = 'activitypub';
}
@ -900,15 +906,15 @@ function get_site_info()
'commit' => $commit,
'protocols' => $protocols,
'plugins' => $visible_plugins,
'register_policy' => $register_policy[get_config('system', 'register_policy')],
'invitation_only' => (defined('INVITE_WORKING') && intval(get_config('system', 'invitation_only'))),
'language' => get_config('system', 'language'),
'register_policy' => $register_policy[Config::Get('system', 'register_policy')],
'invitation_only' => (defined('INVITE_WORKING') && intval(Config::Get('system', 'invitation_only'))),
'language' => Config::Get('system', 'language'),
'expiration' => $site_expire,
'default_service_restrictions' => $service_class,
'locked_features' => $locked_features,
'admin' => $admin,
'dbdriver' => DBA::$dba->getdriver() . ' ' . ((ACTIVE_DBTYPE == DBTYPE_POSTGRES) ? 'postgres' : 'mysql'),
'lastpoll' => get_config('system', 'lastpoll'),
'lastpoll' => Config::Get('system', 'lastpoll'),
'info' => (($site_info) ? $site_info : '')
];
@ -977,8 +983,8 @@ function check_siteallowed($url)
return $retvalue;
}
$allowed = get_config('system', 'allowed_sites');
$denied = get_config('system', 'denied_sites');
$allowed = Config::Get('system', 'allowed_sites');
$denied = Config::Get('system', 'denied_sites');
return match_access_rule($url, $allowed, $denied, $retvalue);
}
@ -1011,8 +1017,8 @@ function check_pubstream_siteallowed($url)
return $retvalue;
}
$allowed = get_config('system', 'pubstream_allowed_sites');
$denied = get_config('system', 'pubstream_denied_sites');
$allowed = Config::Get('system', 'pubstream_allowed_sites');
$denied = Config::Get('system', 'pubstream_denied_sites');
return match_access_rule($url, $allowed, $denied, $retvalue);
}
@ -1040,8 +1046,8 @@ function check_channelallowed($hash)
return $arr['allowed'];
}
$allowed = get_config('system', 'allowed_channels');
$denied = get_config('system', 'denied_channels');
$allowed = Config::Get('system', 'allowed_channels');
$denied = Config::Get('system', 'denied_channels');
return match_access_rule($hash, $allowed, $denied, $retvalue);
}
@ -1069,8 +1075,8 @@ function check_pubstream_channelallowed($hash)
return $arr['allowed'];
}
$allowed = get_config('system', 'pubstream_allowed_channels');
$denied = get_config('system', 'pubstream_denied_channels');
$allowed = Config::Get('system', 'pubstream_allowed_channels');
$denied = Config::Get('system', 'pubstream_denied_channels');
return match_access_rule($hash, $allowed, $denied, $retvalue);
}
@ -1148,7 +1154,7 @@ function network_to_name($s)
}
/**
* @brief Send a text email message.
* @brief Send an email message.
*
* @param array $params an associative array with:
* * \e string \b fromName name of the sender
@ -1162,21 +1168,20 @@ function network_to_name($s)
*/
function z_mail($params)
{
if (! $params['fromEmail']) {
$params['fromEmail'] = get_config('system', 'from_email');
$params['fromEmail'] = Config::Get('system', 'from_email');
if (! $params['fromEmail']) {
$params['fromEmail'] = 'Administrator' . '@' . App::get_hostname();
}
}
if (! $params['fromName']) {
$params['fromName'] = get_config('system', 'from_email_name');
$params['fromName'] = Config::Get('system', 'from_email_name');
if (! $params['fromName']) {
$params['fromName'] = System::get_site_name();
}
}
if (! $params['replyTo']) {
$params['replyTo'] = get_config('system', 'reply_address');
$params['replyTo'] = Config::Get('system', 'reply_address');
if (! $params['replyTo']) {
$params['replyTo'] = 'noreply' . '@' . App::get_hostname();
}
@ -1196,6 +1201,102 @@ function z_mail($params)
return $params['result'];
}
$mail = new PHPMailer();
$mailer = Config::Get('mail','mailer');
if (!$mailer) {
$mail->isSendmail();
$s = intval(Config::Get('mail','usesendmailoptions'));
if($s) {
$mail->UseSendmailOptions = (boolean)$s;
}
}
else {
$s = intval(Config::Get('mail', 'smtpdebug'));
if ($s) {
// 1: debug client
// 2: debug server (most useful setting)
// 3: debug connection (useful for STARTTLS issues)
// 4: debug lowlevel (very verbose)
$mail->SMTPDebug = intval($s);
$mail->Debugoutput = function ($str, $level) {
logger('phpmailer: ' . $str);
};
}
$mail->Hostname = App::get_hostname();
if (Config::Get('mail', 'mailer') === 'smtp') {
$mail->IsSMTP();
$mail->Mailer = "smtp";
$s = Config::Get('mail', 'host');
if ($s)
$mail->Host = $s;
else
$mail->Host = 'localhost';
$s = Config::Get('mail', 'port');
if ($s)
$mail->Port = $s;
else
$mail->Port = '25';
$s = Config::Get('mail', 'smtpsecure');
if ($s)
$mail->SMTPSecure = $s;
$s = Config::Get('mail', 'smtpauth');
if ($s)
$mail->SMTPAuth = (boolean)$s;
$s = Config::Get('mail', 'username');
if ($s)
$mail->Username = $s;
$s = Config::Get('mail', 'password');
if ($s)
$mail->Password = $s;
$s = intval(Config::Get('mail', 'noverify'));
if ($s) {
$mail->SMTPOptions = ['ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true]
];
}
}
}
try {
$mail->setFrom($x['fromEmail'], $x['fromName']);
$mail->addReplyTo($x['replyTo']);
$mail->addAddress($x['toEmail']);
$mail->Subject = $x['messageSubject'];
$mail->CharSet = 'UTF-8';
if ($x['htmlVersion']) {
$mail->isHTML(true);
$mail->Body = $x['htmlVersion'];
$mail->AltBody = $x['textVersion'];
} else {
$mail->isHTML(false);
$mail->Body = $x['textVersion'];
}
$mail->send();
logger('phpmailer: success');
return true;
} catch (Exception $e) {
logger('phpmailer: failure: ' . $mail->ErrorInfo . '; error: ' . $e, LOGGER_DEBUG);
return false;
}
/*
$fromName = email_header_encode(html_entity_decode($params['fromName'], ENT_QUOTES, 'UTF-8'), 'UTF-8');
$messageSubject = email_header_encode(html_entity_decode($params['messageSubject'], ENT_QUOTES, 'UTF-8'), 'UTF-8');
@ -1215,6 +1316,7 @@ function z_mail($params)
);
logger('notification: z_mail returns ' . (($res) ? 'success' : 'failure'), LOGGER_DEBUG);
return $res;
*/
}

View file

@ -68,7 +68,6 @@ App::$config['system']['verify_email'] = 1;
// as an open hub where anybody may create accounts. Your choice of
// paid, tiered, or free determines how these listings will be presented.
App::$config['system']['access_policy'] = ACCESS_PRIVATE;
// If you operate a public site, you might wish that people are directed
@ -86,19 +85,49 @@ App::$config['system']['max_import_size'] = 200000;
App::$config['system']['php_path'] = '{{$phpath}}';
// Configure how we communicate with directory servers.
// DIRECTORY_MODE_NORMAL = directory client, we will find a directory
// DIRECTORY_MODE_SECONDARY = caching directory or mirror
// DIRECTORY_MODE_PRIMARY = main directory server - one per realm
// DIRECTORY_MODE_STANDALONE = "off the grid" or private directory services
// Deprecated. Please do not change.
App::$config['system']['directory_mode'] = DIRECTORY_MODE_NORMAL;
// default system theme
App::$config['system']['theme'] = 'fresh';
// Allow local test environments with unverified SSL certs using Lando
App::$config['system']['ssl_exceptions'] = 'lndo.site';
// Mail configuration
// By default, uses local sendmail service
// Only change these settings if you require SMTP transport
// App::$config['mail']['mailer'] = 'smtp';
// App::$config['mail']['host'] = 'example.com';
// Leave this line commented if using SSL or STARTTLS and set the port in the next sections
// App::$config['mail']['port'] = 25; // (or 587 or 465 if using ssl)
// If using smtp authentication:
// App::$config['mail']['smtpauth'] = 1;
// App::$config['mail']['uername'] = 'your_username';
// App::$config['mail']['password'] = 'your_secret_password';
// If using starttls:
// App::$config['mail']['smtpsecure'] = 'tls';
// App::$config['mail']['port'] = 587;
// If using ssl:
// App::$config['mail']['smtpsecure'] = 'ssl';
// App::$config['mail']['port'] = 465;
// If the server has a self-signed cert:
// App::$config['mail']['noverify'] = 1;
// For debugging
// App::$config['mail']['smtpdebug'] = 2; // valid values are 0-4
// These settings should work for 99% of use cases
// If you encounter any issues, please see https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
// If you need to extend these configuration options, please submit a pull request with your changes.
// PHP error logging setup
// Before doing this ensure that the webserver has permission
// to create and write to php.out in the top level web directory,